@octanejs/tanstack-query 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +81 -0
- package/package.json +44 -0
- package/src/HydrationBoundary.tsrx +74 -0
- package/src/HydrationBoundary.tsrx.d.ts +9 -0
- package/src/QueryClientProvider.tsrx +16 -0
- package/src/QueryClientProvider.tsrx.d.ts +10 -0
- package/src/QueryErrorResetBoundary.tsrx +21 -0
- package/src/QueryErrorResetBoundary.tsrx.d.ts +4 -0
- package/src/context.ts +29 -0
- package/src/errorResetBoundary.ts +28 -0
- package/src/index.ts +74 -0
- package/src/infiniteQueryOptions.ts +94 -0
- package/src/internal.ts +115 -0
- package/src/isRestoring.ts +13 -0
- package/src/mutationOptions.ts +33 -0
- package/src/queries-types.ts +167 -0
- package/src/queryOptions.ts +83 -0
- package/src/suspense-queries-types.ts +141 -0
- package/src/types.ts +232 -0
- package/src/useBaseQuery.ts +153 -0
- package/src/useInfiniteQuery.ts +52 -0
- package/src/useIsFetching.ts +25 -0
- package/src/useMutation.ts +65 -0
- package/src/useMutationState.ts +78 -0
- package/src/usePrefetch.ts +48 -0
- package/src/useQueries.ts +134 -0
- package/src/useQuery.ts +47 -0
- package/src/useSuspenseQueries.ts +38 -0
- package/src/useSuspenseQuery.ts +71 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { InfiniteQueryObserver, QueryObserver, skipToken } from '@tanstack/query-core';
|
|
2
|
+
import type { DefaultError, InfiniteData, QueryClient, QueryKey } from '@tanstack/query-core';
|
|
3
|
+
import { useBaseQuery } from './useBaseQuery';
|
|
4
|
+
import { defaultThrowOnError, splitSlot } from './internal';
|
|
5
|
+
import type {
|
|
6
|
+
UseSuspenseInfiniteQueryOptions,
|
|
7
|
+
UseSuspenseInfiniteQueryResult,
|
|
8
|
+
UseSuspenseQueryOptions,
|
|
9
|
+
UseSuspenseQueryResult,
|
|
10
|
+
} from './types';
|
|
11
|
+
|
|
12
|
+
// Signatures match @tanstack/react-query's useSuspenseQuery.ts /
|
|
13
|
+
// useSuspenseInfiniteQuery.ts (data is always defined; no placeholderData /
|
|
14
|
+
// enabled / throwOnError options). The untyped implementation signature also
|
|
15
|
+
// accepts the compiler-injected trailing slot symbol.
|
|
16
|
+
export function useSuspenseQuery<
|
|
17
|
+
TQueryFnData = unknown,
|
|
18
|
+
TError = DefaultError,
|
|
19
|
+
TData = TQueryFnData,
|
|
20
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
21
|
+
>(
|
|
22
|
+
options: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
23
|
+
queryClient?: QueryClient,
|
|
24
|
+
): UseSuspenseQueryResult<TData, TError>;
|
|
25
|
+
|
|
26
|
+
export function useSuspenseQuery(options: any, ...rest: any[]): any {
|
|
27
|
+
const [user, slot] = splitSlot(rest);
|
|
28
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
29
|
+
if (options.queryFn === skipToken) {
|
|
30
|
+
console.error('skipToken is not allowed for useSuspenseQuery');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return useBaseQuery(
|
|
34
|
+
{
|
|
35
|
+
...options,
|
|
36
|
+
enabled: true,
|
|
37
|
+
suspense: true,
|
|
38
|
+
throwOnError: defaultThrowOnError,
|
|
39
|
+
placeholderData: undefined,
|
|
40
|
+
},
|
|
41
|
+
QueryObserver,
|
|
42
|
+
user[0],
|
|
43
|
+
slot,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function useSuspenseInfiniteQuery<
|
|
48
|
+
TQueryFnData,
|
|
49
|
+
TError = DefaultError,
|
|
50
|
+
TData = InfiniteData<TQueryFnData>,
|
|
51
|
+
TQueryKey extends QueryKey = QueryKey,
|
|
52
|
+
TPageParam = unknown,
|
|
53
|
+
>(
|
|
54
|
+
options: UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,
|
|
55
|
+
queryClient?: QueryClient,
|
|
56
|
+
): UseSuspenseInfiniteQueryResult<TData, TError>;
|
|
57
|
+
|
|
58
|
+
export function useSuspenseInfiniteQuery(options: any, ...rest: any[]): any {
|
|
59
|
+
const [user, slot] = splitSlot(rest);
|
|
60
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
61
|
+
if (options.queryFn === skipToken) {
|
|
62
|
+
console.error('skipToken is not allowed for useSuspenseInfiniteQuery');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return useBaseQuery(
|
|
66
|
+
{ ...options, enabled: true, suspense: true, throwOnError: defaultThrowOnError },
|
|
67
|
+
InfiniteQueryObserver,
|
|
68
|
+
user[0],
|
|
69
|
+
slot,
|
|
70
|
+
);
|
|
71
|
+
}
|