@tanstack/react-query 5.102.8 → 5.103.1
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/build/legacy/HydrationBoundary.cjs +44 -1
- package/build/legacy/HydrationBoundary.cjs.map +1 -1
- package/build/legacy/HydrationBoundary.d.cts +61 -0
- package/build/legacy/HydrationBoundary.d.cts.map +1 -1
- package/build/legacy/HydrationBoundary.d.ts +61 -0
- package/build/legacy/HydrationBoundary.d.ts.map +1 -1
- package/build/legacy/HydrationBoundary.js +44 -1
- package/build/legacy/HydrationBoundary.js.map +1 -1
- package/build/legacy/IsRestoringProvider.cjs +11 -0
- package/build/legacy/IsRestoringProvider.cjs.map +1 -1
- package/build/legacy/IsRestoringProvider.d.cts +11 -0
- package/build/legacy/IsRestoringProvider.d.cts.map +1 -1
- package/build/legacy/IsRestoringProvider.d.ts +11 -0
- package/build/legacy/IsRestoringProvider.d.ts.map +1 -1
- package/build/legacy/IsRestoringProvider.js +11 -0
- package/build/legacy/IsRestoringProvider.js.map +1 -1
- package/build/legacy/QueryClientProvider.cjs +30 -0
- package/build/legacy/QueryClientProvider.cjs.map +1 -1
- package/build/legacy/QueryClientProvider.d.cts +41 -0
- package/build/legacy/QueryClientProvider.d.cts.map +1 -1
- package/build/legacy/QueryClientProvider.d.ts +41 -0
- package/build/legacy/QueryClientProvider.d.ts.map +1 -1
- package/build/legacy/QueryClientProvider.js +30 -0
- package/build/legacy/QueryClientProvider.js.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.cjs +76 -0
- package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.cts +77 -0
- package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.ts +77 -0
- package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.js +76 -0
- package/build/legacy/QueryErrorResetBoundary.js.map +1 -1
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +173 -0
- package/build/legacy/infiniteQueryOptions.d.cts.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.ts +173 -0
- package/build/legacy/infiniteQueryOptions.d.ts.map +1 -1
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationOptions.cjs.map +1 -1
- package/build/legacy/mutationOptions.d.cts +55 -0
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +55 -0
- package/build/legacy/mutationOptions.d.ts.map +1 -1
- package/build/legacy/mutationOptions.js.map +1 -1
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +175 -0
- package/build/legacy/queryOptions.d.cts.map +1 -1
- package/build/legacy/queryOptions.d.ts +175 -0
- package/build/legacy/queryOptions.d.ts.map +1 -1
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +228 -2
- package/build/legacy/types.d.cts.map +1 -1
- package/build/legacy/types.d.ts +228 -2
- package/build/legacy/types.d.ts.map +1 -1
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +292 -0
- package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +292 -0
- package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +36 -0
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +36 -0
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +36 -0
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useIsFetching.js +36 -0
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +172 -0
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.d.cts +172 -0
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +172 -0
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutation.js +172 -0
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useMutationState.cjs +94 -0
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.d.cts +94 -0
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +94 -0
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/useMutationState.js +94 -0
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs +44 -0
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +44 -0
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +44 -0
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.js +44 -0
- package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/legacy/usePrefetchQuery.cjs +35 -0
- package/build/legacy/usePrefetchQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +35 -0
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +35 -0
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.js +35 -0
- package/build/legacy/usePrefetchQuery.js.map +1 -1
- package/build/legacy/useQueries.cjs +130 -0
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +165 -2
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +165 -2
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js +130 -0
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +246 -0
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +246 -0
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.cjs +86 -0
- package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +86 -0
- package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +86 -0
- package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.js +86 -0
- package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -1
- package/build/legacy/useSuspenseQueries.cjs.map +1 -1
- package/build/legacy/useSuspenseQueries.d.cts +320 -2
- package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
- package/build/legacy/useSuspenseQueries.d.ts +320 -2
- package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
- package/build/legacy/useSuspenseQueries.js.map +1 -1
- package/build/legacy/useSuspenseQuery.cjs +67 -0
- package/build/legacy/useSuspenseQuery.cjs.map +1 -1
- package/build/legacy/useSuspenseQuery.d.cts +67 -0
- package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseQuery.d.ts +67 -0
- package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseQuery.js +67 -0
- package/build/legacy/useSuspenseQuery.js.map +1 -1
- package/build/modern/HydrationBoundary.cjs +44 -1
- package/build/modern/HydrationBoundary.cjs.map +1 -1
- package/build/modern/HydrationBoundary.d.cts +61 -0
- package/build/modern/HydrationBoundary.d.cts.map +1 -1
- package/build/modern/HydrationBoundary.d.ts +61 -0
- package/build/modern/HydrationBoundary.d.ts.map +1 -1
- package/build/modern/HydrationBoundary.js +44 -1
- package/build/modern/HydrationBoundary.js.map +1 -1
- package/build/modern/IsRestoringProvider.cjs +11 -0
- package/build/modern/IsRestoringProvider.cjs.map +1 -1
- package/build/modern/IsRestoringProvider.d.cts +11 -0
- package/build/modern/IsRestoringProvider.d.cts.map +1 -1
- package/build/modern/IsRestoringProvider.d.ts +11 -0
- package/build/modern/IsRestoringProvider.d.ts.map +1 -1
- package/build/modern/IsRestoringProvider.js +11 -0
- package/build/modern/IsRestoringProvider.js.map +1 -1
- package/build/modern/QueryClientProvider.cjs +30 -0
- package/build/modern/QueryClientProvider.cjs.map +1 -1
- package/build/modern/QueryClientProvider.d.cts +41 -0
- package/build/modern/QueryClientProvider.d.cts.map +1 -1
- package/build/modern/QueryClientProvider.d.ts +41 -0
- package/build/modern/QueryClientProvider.d.ts.map +1 -1
- package/build/modern/QueryClientProvider.js +30 -0
- package/build/modern/QueryClientProvider.js.map +1 -1
- package/build/modern/QueryErrorResetBoundary.cjs +76 -0
- package/build/modern/QueryErrorResetBoundary.cjs.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.cts +77 -0
- package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.ts +77 -0
- package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.js +76 -0
- package/build/modern/QueryErrorResetBoundary.js.map +1 -1
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +173 -0
- package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
- package/build/modern/infiniteQueryOptions.d.ts +173 -0
- package/build/modern/infiniteQueryOptions.d.ts.map +1 -1
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationOptions.cjs.map +1 -1
- package/build/modern/mutationOptions.d.cts +55 -0
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +55 -0
- package/build/modern/mutationOptions.d.ts.map +1 -1
- package/build/modern/mutationOptions.js.map +1 -1
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +175 -0
- package/build/modern/queryOptions.d.cts.map +1 -1
- package/build/modern/queryOptions.d.ts +175 -0
- package/build/modern/queryOptions.d.ts.map +1 -1
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +228 -2
- package/build/modern/types.d.cts.map +1 -1
- package/build/modern/types.d.ts +228 -2
- package/build/modern/types.d.ts.map +1 -1
- package/build/modern/types.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +292 -0
- package/build/modern/useInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useInfiniteQuery.d.ts +292 -0
- package/build/modern/useInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +36 -0
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +36 -0
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +36 -0
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useIsFetching.js +36 -0
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +172 -0
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.d.cts +172 -0
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +172 -0
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutation.js +172 -0
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useMutationState.cjs +94 -0
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.d.cts +94 -0
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +94 -0
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/useMutationState.js +94 -0
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs +44 -0
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +44 -0
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +44 -0
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.js +44 -0
- package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/modern/usePrefetchQuery.cjs +35 -0
- package/build/modern/usePrefetchQuery.cjs.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +35 -0
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +35 -0
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.js +35 -0
- package/build/modern/usePrefetchQuery.js.map +1 -1
- package/build/modern/useQueries.cjs +130 -0
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +165 -2
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +165 -2
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js +130 -0
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +246 -0
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +246 -0
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.cjs +86 -0
- package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.cts +86 -0
- package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.ts +86 -0
- package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.js +86 -0
- package/build/modern/useSuspenseInfiniteQuery.js.map +1 -1
- package/build/modern/useSuspenseQueries.cjs.map +1 -1
- package/build/modern/useSuspenseQueries.d.cts +320 -2
- package/build/modern/useSuspenseQueries.d.cts.map +1 -1
- package/build/modern/useSuspenseQueries.d.ts +320 -2
- package/build/modern/useSuspenseQueries.d.ts.map +1 -1
- package/build/modern/useSuspenseQueries.js.map +1 -1
- package/build/modern/useSuspenseQuery.cjs +67 -0
- package/build/modern/useSuspenseQuery.cjs.map +1 -1
- package/build/modern/useSuspenseQuery.d.cts +67 -0
- package/build/modern/useSuspenseQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseQuery.d.ts +67 -0
- package/build/modern/useSuspenseQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseQuery.js +67 -0
- package/build/modern/useSuspenseQuery.js.map +1 -1
- package/build/query-codemods/eslint.config.js +7 -0
- package/build/query-codemods/root.eslint.config.js +45 -0
- package/package.json +11 -11
- package/src/HydrationBoundary.tsx +61 -1
- package/src/IsRestoringProvider.ts +12 -0
- package/src/QueryClientProvider.tsx +41 -0
- package/src/QueryErrorResetBoundary.tsx +89 -0
- package/src/infiniteQueryOptions.ts +173 -0
- package/src/mutationOptions.ts +55 -0
- package/src/queryOptions.ts +175 -0
- package/src/types.ts +228 -2
- package/src/useInfiniteQuery.ts +292 -0
- package/src/useIsFetching.ts +36 -0
- package/src/useMutation.ts +172 -0
- package/src/useMutationState.ts +94 -0
- package/src/usePrefetchInfiniteQuery.tsx +44 -0
- package/src/usePrefetchQuery.tsx +35 -0
- package/src/useQueries.ts +165 -2
- package/src/useQuery.ts +246 -0
- package/src/useSuspenseInfiniteQuery.ts +86 -0
- package/src/useSuspenseQueries.ts +320 -2
- package/src/useSuspenseQuery.ts +67 -0
package/src/types.ts
CHANGED
|
@@ -21,6 +21,10 @@ import type {
|
|
|
21
21
|
SkipToken,
|
|
22
22
|
} from '@tanstack/query-core'
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* {@link UseBaseQueryOptions} with all type parameters set to `any`, useful when the specific types aren't
|
|
26
|
+
* relevant, e.g. when accepting options for any query in a helper function.
|
|
27
|
+
*/
|
|
24
28
|
export type AnyUseBaseQueryOptions = UseBaseQueryOptions<
|
|
25
29
|
any,
|
|
26
30
|
any,
|
|
@@ -28,6 +32,18 @@ export type AnyUseBaseQueryOptions = UseBaseQueryOptions<
|
|
|
28
32
|
any,
|
|
29
33
|
any
|
|
30
34
|
>
|
|
35
|
+
/**
|
|
36
|
+
* The options shared by `useQuery` and `useSuspenseQuery`. Extends {@link QueryObserverOptions} from
|
|
37
|
+
* `@tanstack/query-core` with the `react-query`-specific `subscribed` option.
|
|
38
|
+
*
|
|
39
|
+
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
40
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
41
|
+
* @template TData - The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when no
|
|
42
|
+
* `select` is used.
|
|
43
|
+
* @template TQueryData - The type of the data actually held in the query cache — the input to `select` and
|
|
44
|
+
* `placeholderData`. Defaults to, and is usually the same as, `TQueryFnData`.
|
|
45
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
46
|
+
*/
|
|
31
47
|
export interface UseBaseQueryOptions<
|
|
32
48
|
TQueryFnData = unknown,
|
|
33
49
|
TError = DefaultError,
|
|
@@ -43,11 +59,24 @@ export interface UseBaseQueryOptions<
|
|
|
43
59
|
> {
|
|
44
60
|
/**
|
|
45
61
|
* Set this to `false` to unsubscribe this observer from updates to the query cache.
|
|
46
|
-
*
|
|
62
|
+
*
|
|
63
|
+
* @defaultValue true
|
|
47
64
|
*/
|
|
48
65
|
subscribed?: boolean
|
|
49
66
|
}
|
|
50
67
|
|
|
68
|
+
/**
|
|
69
|
+
* The options accepted by `usePrefetchQuery` — everything you can pass to `queryClient.query`, except `queryFn`
|
|
70
|
+
* is required unless a default query function has been defined.
|
|
71
|
+
*
|
|
72
|
+
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
73
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
74
|
+
* @template TData - The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when no
|
|
75
|
+
* `select` is used.
|
|
76
|
+
* @template TQueryData - The type of the data actually held in the query cache — the input to `select` and
|
|
77
|
+
* `placeholderData`. Defaults to, and is usually the same as, `TQueryFnData`.
|
|
78
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
79
|
+
*/
|
|
51
80
|
export type UsePrefetchQueryOptions<
|
|
52
81
|
TQueryFnData = unknown,
|
|
53
82
|
TError = DefaultError,
|
|
@@ -58,6 +87,10 @@ export type UsePrefetchQueryOptions<
|
|
|
58
87
|
QueryExecuteOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>,
|
|
59
88
|
'queryFn'
|
|
60
89
|
> & {
|
|
90
|
+
/**
|
|
91
|
+
* `skipToken` is not allowed as a value here — a prefetch always needs a query function to actually run,
|
|
92
|
+
* unless a default query function has been defined.
|
|
93
|
+
*/
|
|
61
94
|
queryFn?: Exclude<
|
|
62
95
|
QueryExecuteOptions<
|
|
63
96
|
TQueryFnData,
|
|
@@ -70,6 +103,18 @@ export type UsePrefetchQueryOptions<
|
|
|
70
103
|
>
|
|
71
104
|
}
|
|
72
105
|
|
|
106
|
+
/**
|
|
107
|
+
* The options accepted by `usePrefetchInfiniteQuery` — everything you can pass to `queryClient.infiniteQuery`,
|
|
108
|
+
* except `queryFn` is required unless a default query function has been defined.
|
|
109
|
+
*
|
|
110
|
+
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
111
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
112
|
+
* @template TData - The type `data` ends up as after `select` runs. Defaults to `InfiniteData<TQueryFnData>`,
|
|
113
|
+
* the shape of all fetched pages plus their page params — a prefetch never reads `data` back out, so this
|
|
114
|
+
* parameter only matters if you reuse these options elsewhere with `select` applied.
|
|
115
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
116
|
+
* @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
|
|
117
|
+
*/
|
|
73
118
|
export type UsePrefetchInfiniteQueryOptions<
|
|
74
119
|
TQueryFnData = unknown,
|
|
75
120
|
TError = DefaultError,
|
|
@@ -86,6 +131,10 @@ export type UsePrefetchInfiniteQueryOptions<
|
|
|
86
131
|
>,
|
|
87
132
|
'queryFn'
|
|
88
133
|
> & {
|
|
134
|
+
/**
|
|
135
|
+
* `skipToken` is not allowed as a value here — a prefetch always needs a query function to actually run,
|
|
136
|
+
* unless a default query function has been defined.
|
|
137
|
+
*/
|
|
89
138
|
queryFn?: Exclude<
|
|
90
139
|
InfiniteQueryExecuteOptions<
|
|
91
140
|
TQueryFnData,
|
|
@@ -98,7 +147,21 @@ export type UsePrefetchInfiniteQueryOptions<
|
|
|
98
147
|
>
|
|
99
148
|
}
|
|
100
149
|
|
|
150
|
+
/**
|
|
151
|
+
* {@link UseQueryOptions} with all type parameters set to `any`, useful when the specific types aren't
|
|
152
|
+
* relevant, e.g. when accepting options for any query in a helper function.
|
|
153
|
+
*/
|
|
101
154
|
export type AnyUseQueryOptions = UseQueryOptions<any, any, any, any>
|
|
155
|
+
/**
|
|
156
|
+
* The options accepted by `useQuery`. Same as {@link UseBaseQueryOptions}, minus `suspense` (which
|
|
157
|
+
* `react-query` derives from which hook you call rather than exposing as an option).
|
|
158
|
+
*
|
|
159
|
+
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
160
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
161
|
+
* @template TData - The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when no
|
|
162
|
+
* `select` is used.
|
|
163
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
164
|
+
*/
|
|
102
165
|
export interface UseQueryOptions<
|
|
103
166
|
TQueryFnData = unknown,
|
|
104
167
|
TError = DefaultError,
|
|
@@ -109,12 +172,27 @@ export interface UseQueryOptions<
|
|
|
109
172
|
'suspense'
|
|
110
173
|
> {}
|
|
111
174
|
|
|
175
|
+
/**
|
|
176
|
+
* {@link UseSuspenseQueryOptions} with all type parameters set to `any`, useful when the specific types aren't
|
|
177
|
+
* relevant, e.g. when accepting options for any query in a helper function.
|
|
178
|
+
*/
|
|
112
179
|
export type AnyUseSuspenseQueryOptions = UseSuspenseQueryOptions<
|
|
113
180
|
any,
|
|
114
181
|
any,
|
|
115
182
|
any,
|
|
116
183
|
any
|
|
117
184
|
>
|
|
185
|
+
/**
|
|
186
|
+
* The options accepted by `useSuspenseQuery`. Same as {@link UseQueryOptions}, minus `enabled`, `throwOnError`,
|
|
187
|
+
* and `placeholderData` — Suspense hooks cannot render a "disabled" or "placeholder" state, so those options
|
|
188
|
+
* don't apply.
|
|
189
|
+
*
|
|
190
|
+
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
191
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
192
|
+
* @template TData - The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when no
|
|
193
|
+
* `select` is used.
|
|
194
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
195
|
+
*/
|
|
118
196
|
export interface UseSuspenseQueryOptions<
|
|
119
197
|
TQueryFnData = unknown,
|
|
120
198
|
TError = DefaultError,
|
|
@@ -124,12 +202,20 @@ export interface UseSuspenseQueryOptions<
|
|
|
124
202
|
UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
|
|
125
203
|
'queryFn' | 'enabled' | 'throwOnError' | 'placeholderData'
|
|
126
204
|
> {
|
|
205
|
+
/**
|
|
206
|
+
* `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function
|
|
207
|
+
* must always be provided, unless a default query function has been defined.
|
|
208
|
+
*/
|
|
127
209
|
queryFn?: Exclude<
|
|
128
210
|
UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],
|
|
129
211
|
SkipToken
|
|
130
212
|
>
|
|
131
213
|
}
|
|
132
214
|
|
|
215
|
+
/**
|
|
216
|
+
* {@link UseInfiniteQueryOptions} with all type parameters set to `any`, useful when the specific types aren't
|
|
217
|
+
* relevant, e.g. when accepting options for any query in a helper function.
|
|
218
|
+
*/
|
|
133
219
|
export type AnyUseInfiniteQueryOptions = UseInfiniteQueryOptions<
|
|
134
220
|
any,
|
|
135
221
|
any,
|
|
@@ -137,6 +223,18 @@ export type AnyUseInfiniteQueryOptions = UseInfiniteQueryOptions<
|
|
|
137
223
|
any,
|
|
138
224
|
any
|
|
139
225
|
>
|
|
226
|
+
/**
|
|
227
|
+
* The options accepted by `useInfiniteQuery`. Extends {@link InfiniteQueryObserverOptions} from
|
|
228
|
+
* `@tanstack/query-core` with the `react-query`-specific `subscribed` option, minus `suspense` (which
|
|
229
|
+
* `react-query` derives from which hook you call rather than exposing as an option).
|
|
230
|
+
*
|
|
231
|
+
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
232
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
233
|
+
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
234
|
+
* the shape of all fetched pages plus their page params.
|
|
235
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
236
|
+
* @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
|
|
237
|
+
*/
|
|
140
238
|
export interface UseInfiniteQueryOptions<
|
|
141
239
|
TQueryFnData = unknown,
|
|
142
240
|
TError = DefaultError,
|
|
@@ -155,13 +253,30 @@ export interface UseInfiniteQueryOptions<
|
|
|
155
253
|
> {
|
|
156
254
|
/**
|
|
157
255
|
* Set this to `false` to unsubscribe this observer from updates to the query cache.
|
|
158
|
-
*
|
|
256
|
+
*
|
|
257
|
+
* @defaultValue true
|
|
159
258
|
*/
|
|
160
259
|
subscribed?: boolean
|
|
161
260
|
}
|
|
162
261
|
|
|
262
|
+
/**
|
|
263
|
+
* {@link UseSuspenseInfiniteQueryOptions} with all type parameters set to `any`, useful when the specific types
|
|
264
|
+
* aren't relevant, e.g. when accepting options for any query in a helper function.
|
|
265
|
+
*/
|
|
163
266
|
export type AnyUseSuspenseInfiniteQueryOptions =
|
|
164
267
|
UseSuspenseInfiniteQueryOptions<any, any, any, any, any>
|
|
268
|
+
/**
|
|
269
|
+
* The options accepted by `useSuspenseInfiniteQuery`. Same as {@link UseInfiniteQueryOptions}, minus `enabled`,
|
|
270
|
+
* `throwOnError`, and `placeholderData` — Suspense hooks cannot render a "disabled" or "placeholder" state, so
|
|
271
|
+
* those options don't apply.
|
|
272
|
+
*
|
|
273
|
+
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
274
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
275
|
+
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
276
|
+
* the shape of all fetched pages plus their page params.
|
|
277
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
278
|
+
* @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
|
|
279
|
+
*/
|
|
165
280
|
export interface UseSuspenseInfiniteQueryOptions<
|
|
166
281
|
TQueryFnData = unknown,
|
|
167
282
|
TError = DefaultError,
|
|
@@ -172,6 +287,10 @@ export interface UseSuspenseInfiniteQueryOptions<
|
|
|
172
287
|
UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,
|
|
173
288
|
'queryFn' | 'enabled' | 'throwOnError' | 'placeholderData'
|
|
174
289
|
> {
|
|
290
|
+
/**
|
|
291
|
+
* `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function
|
|
292
|
+
* must always be provided, unless a default query function has been defined.
|
|
293
|
+
*/
|
|
175
294
|
queryFn?: Exclude<
|
|
176
295
|
UseInfiniteQueryOptions<
|
|
177
296
|
TQueryFnData,
|
|
@@ -184,16 +303,37 @@ export interface UseSuspenseInfiniteQueryOptions<
|
|
|
184
303
|
>
|
|
185
304
|
}
|
|
186
305
|
|
|
306
|
+
/**
|
|
307
|
+
* The result of `useQuery` when `initialData` isn't set — `data` may be `undefined` while the query is
|
|
308
|
+
* `pending`. Re-exports {@link QueryObserverResult} from `@tanstack/query-core`. `useInfiniteQuery` returns
|
|
309
|
+
* {@link UseInfiniteQueryResult} instead.
|
|
310
|
+
*
|
|
311
|
+
* @template TData - The type `data` ends up as after `select` runs.
|
|
312
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
313
|
+
*/
|
|
187
314
|
export type UseBaseQueryResult<
|
|
188
315
|
TData = unknown,
|
|
189
316
|
TError = DefaultError,
|
|
190
317
|
> = QueryObserverResult<TData, TError>
|
|
191
318
|
|
|
319
|
+
/**
|
|
320
|
+
* The result of `useQuery`. Same as {@link UseBaseQueryResult}.
|
|
321
|
+
*
|
|
322
|
+
* @template TData - The type `data` ends up as after `select` runs.
|
|
323
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
324
|
+
*/
|
|
192
325
|
export type UseQueryResult<
|
|
193
326
|
TData = unknown,
|
|
194
327
|
TError = DefaultError,
|
|
195
328
|
> = UseBaseQueryResult<TData, TError>
|
|
196
329
|
|
|
330
|
+
/**
|
|
331
|
+
* The result of `useSuspenseQuery`. Same as {@link DefinedUseQueryResult}, minus `isPlaceholderData` — always
|
|
332
|
+
* `false` on that type, so this drops the dead field rather than an active state.
|
|
333
|
+
*
|
|
334
|
+
* @template TData - The type `data` ends up as after `select` runs.
|
|
335
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
336
|
+
*/
|
|
197
337
|
export type UseSuspenseQueryResult<
|
|
198
338
|
TData = unknown,
|
|
199
339
|
TError = DefaultError,
|
|
@@ -202,21 +342,50 @@ export type UseSuspenseQueryResult<
|
|
|
202
342
|
'isPlaceholderData'
|
|
203
343
|
>
|
|
204
344
|
|
|
345
|
+
/**
|
|
346
|
+
* The result of `useQuery` when `initialData` is set, or of `useSuspenseQuery` before the `isPlaceholderData`
|
|
347
|
+
* omission — `data` is never `undefined`. Re-exports {@link DefinedQueryObserverResult} from
|
|
348
|
+
* `@tanstack/query-core`.
|
|
349
|
+
*
|
|
350
|
+
* @template TData - The type `data` ends up as after `select` runs.
|
|
351
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
352
|
+
*/
|
|
205
353
|
export type DefinedUseQueryResult<
|
|
206
354
|
TData = unknown,
|
|
207
355
|
TError = DefaultError,
|
|
208
356
|
> = DefinedQueryObserverResult<TData, TError>
|
|
209
357
|
|
|
358
|
+
/**
|
|
359
|
+
* The result of `useInfiniteQuery` when `initialData` isn't set — `data` may be `undefined` while the query is
|
|
360
|
+
* `pending`. Re-exports {@link InfiniteQueryObserverResult} from `@tanstack/query-core`.
|
|
361
|
+
*
|
|
362
|
+
* @template TData - The type `data` ends up as after `select` runs.
|
|
363
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
364
|
+
*/
|
|
210
365
|
export type UseInfiniteQueryResult<
|
|
211
366
|
TData = unknown,
|
|
212
367
|
TError = DefaultError,
|
|
213
368
|
> = InfiniteQueryObserverResult<TData, TError>
|
|
214
369
|
|
|
370
|
+
/**
|
|
371
|
+
* The result of `useInfiniteQuery` when `initialData` is set — `data` is never `undefined`. Re-exports
|
|
372
|
+
* {@link DefinedInfiniteQueryObserverResult} from `@tanstack/query-core`.
|
|
373
|
+
*
|
|
374
|
+
* @template TData - The type `data` ends up as after `select` runs.
|
|
375
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
376
|
+
*/
|
|
215
377
|
export type DefinedUseInfiniteQueryResult<
|
|
216
378
|
TData = unknown,
|
|
217
379
|
TError = DefaultError,
|
|
218
380
|
> = DefinedInfiniteQueryObserverResult<TData, TError>
|
|
219
381
|
|
|
382
|
+
/**
|
|
383
|
+
* The result of `useSuspenseInfiniteQuery`. Same as {@link DefinedUseInfiniteQueryResult}, minus
|
|
384
|
+
* `isPlaceholderData` — Suspense hooks never render placeholder data.
|
|
385
|
+
*
|
|
386
|
+
* @template TData - The type `data` ends up as after `select` runs.
|
|
387
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
388
|
+
*/
|
|
220
389
|
export type UseSuspenseInfiniteQueryResult<
|
|
221
390
|
TData = unknown,
|
|
222
391
|
TError = DefaultError,
|
|
@@ -225,7 +394,21 @@ export type UseSuspenseInfiniteQueryResult<
|
|
|
225
394
|
'isPlaceholderData'
|
|
226
395
|
>
|
|
227
396
|
|
|
397
|
+
/**
|
|
398
|
+
* {@link UseMutationOptions} with all type parameters set to `any`, useful when the specific types aren't
|
|
399
|
+
* relevant, e.g. when accepting options for any mutation in a helper function.
|
|
400
|
+
*/
|
|
228
401
|
export type AnyUseMutationOptions = UseMutationOptions<any, any, any, any>
|
|
402
|
+
/**
|
|
403
|
+
* The options accepted by `useMutation`. Same as {@link MutationObserverOptions} from `@tanstack/query-core`,
|
|
404
|
+
* minus the internal `_defaulted` flag.
|
|
405
|
+
*
|
|
406
|
+
* @template TData - The type your mutation function resolves to.
|
|
407
|
+
* @template TError - The type of errors your mutation function may throw.
|
|
408
|
+
* @template TVariables - The type of the variable passed to `mutate`/`mutateAsync`.
|
|
409
|
+
* @template TOnMutateResult - The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as
|
|
410
|
+
* their `onMutateResult` parameter — useful for optimistic-update rollback data.
|
|
411
|
+
*/
|
|
229
412
|
export interface UseMutationOptions<
|
|
230
413
|
TData = unknown,
|
|
231
414
|
TError = DefaultError,
|
|
@@ -236,6 +419,17 @@ export interface UseMutationOptions<
|
|
|
236
419
|
'_defaulted'
|
|
237
420
|
> {}
|
|
238
421
|
|
|
422
|
+
/**
|
|
423
|
+
* The type of `mutate`, as returned by `useMutation`. Forwards the variables (and an optional per-call
|
|
424
|
+
* `onSuccess`/`onError`/`onSettled`) to the underlying `mutate` call. Fire-and-forget — errors are surfaced
|
|
425
|
+
* through the mutation result, not thrown.
|
|
426
|
+
*
|
|
427
|
+
* @template TData - The type your mutation function resolves to.
|
|
428
|
+
* @template TError - The type of errors your mutation function may throw.
|
|
429
|
+
* @template TVariables - The type of the variable passed to `mutate`.
|
|
430
|
+
* @template TOnMutateResult - The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as
|
|
431
|
+
* their `onMutateResult` parameter — useful for optimistic-update rollback data.
|
|
432
|
+
*/
|
|
239
433
|
export type UseMutateFunction<
|
|
240
434
|
TData = unknown,
|
|
241
435
|
TError = DefaultError,
|
|
@@ -247,6 +441,16 @@ export type UseMutateFunction<
|
|
|
247
441
|
>
|
|
248
442
|
) => void
|
|
249
443
|
|
|
444
|
+
/**
|
|
445
|
+
* The type of `mutateAsync`, as returned by `useMutation`. Similar to {@link UseMutateFunction}, but returns a
|
|
446
|
+
* promise which can be awaited.
|
|
447
|
+
*
|
|
448
|
+
* @template TData - The type your mutation function resolves to.
|
|
449
|
+
* @template TError - The type of errors your mutation function may throw.
|
|
450
|
+
* @template TVariables - The type of the variable passed to `mutateAsync`.
|
|
451
|
+
* @template TOnMutateResult - The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as
|
|
452
|
+
* their `onMutateResult` parameter — useful for optimistic-update rollback data.
|
|
453
|
+
*/
|
|
250
454
|
export type UseMutateAsyncFunction<
|
|
251
455
|
TData = unknown,
|
|
252
456
|
TError = DefaultError,
|
|
@@ -254,6 +458,16 @@ export type UseMutateAsyncFunction<
|
|
|
254
458
|
TOnMutateResult = unknown,
|
|
255
459
|
> = MutateFunction<TData, TError, TVariables, TOnMutateResult>
|
|
256
460
|
|
|
461
|
+
/**
|
|
462
|
+
* The result of `useMutation`. Same as {@link MutationObserverResult} from `@tanstack/query-core`, with
|
|
463
|
+
* `mutate` narrowed to the fire-and-forget {@link UseMutateFunction} signature, plus the added `mutateAsync`.
|
|
464
|
+
*
|
|
465
|
+
* @template TData - The type your mutation function resolves to.
|
|
466
|
+
* @template TError - The type of errors your mutation function may throw.
|
|
467
|
+
* @template TVariables - The type of the variable passed to `mutate`/`mutateAsync`.
|
|
468
|
+
* @template TOnMutateResult - The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as
|
|
469
|
+
* their `onMutateResult` parameter — useful for optimistic-update rollback data.
|
|
470
|
+
*/
|
|
257
471
|
export type UseBaseMutationResult<
|
|
258
472
|
TData = unknown,
|
|
259
473
|
TError = DefaultError,
|
|
@@ -263,6 +477,9 @@ export type UseBaseMutationResult<
|
|
|
263
477
|
MutationObserverResult<TData, TError, TVariables, TOnMutateResult>,
|
|
264
478
|
{ mutate: UseMutateFunction<TData, TError, TVariables, TOnMutateResult> }
|
|
265
479
|
> & {
|
|
480
|
+
/**
|
|
481
|
+
* Similar to `mutate`, but returns a promise which can be awaited.
|
|
482
|
+
*/
|
|
266
483
|
mutateAsync: UseMutateAsyncFunction<
|
|
267
484
|
TData,
|
|
268
485
|
TError,
|
|
@@ -271,6 +488,15 @@ export type UseBaseMutationResult<
|
|
|
271
488
|
>
|
|
272
489
|
}
|
|
273
490
|
|
|
491
|
+
/**
|
|
492
|
+
* The result of `useMutation`. Same as {@link UseBaseMutationResult}.
|
|
493
|
+
*
|
|
494
|
+
* @template TData - The type your mutation function resolves to.
|
|
495
|
+
* @template TError - The type of errors your mutation function may throw.
|
|
496
|
+
* @template TVariables - The type of the variable passed to `mutate`/`mutateAsync`.
|
|
497
|
+
* @template TOnMutateResult - The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as
|
|
498
|
+
* their `onMutateResult` parameter — useful for optimistic-update rollback data.
|
|
499
|
+
*/
|
|
274
500
|
export type UseMutationResult<
|
|
275
501
|
TData = unknown,
|
|
276
502
|
TError = DefaultError,
|