@tanstack/react-query 5.105.0 → 5.105.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/build/legacy/HydrationBoundary.cjs +2 -3
- package/build/legacy/HydrationBoundary.d.cts +0 -2
- package/build/legacy/HydrationBoundary.d.cts.map +1 -1
- package/build/legacy/HydrationBoundary.d.ts +0 -2
- package/build/legacy/HydrationBoundary.d.ts.map +1 -1
- package/build/legacy/HydrationBoundary.js +1 -2
- package/build/legacy/IsRestoringProvider.cjs +2 -3
- package/build/legacy/IsRestoringProvider.d.cts +0 -2
- package/build/legacy/IsRestoringProvider.d.cts.map +1 -1
- package/build/legacy/IsRestoringProvider.d.ts +0 -2
- package/build/legacy/IsRestoringProvider.d.ts.map +1 -1
- package/build/legacy/IsRestoringProvider.js +1 -2
- package/build/legacy/QueryClientProvider.cjs +2 -3
- package/build/legacy/QueryClientProvider.d.cts +0 -2
- package/build/legacy/QueryClientProvider.d.cts.map +1 -1
- package/build/legacy/QueryClientProvider.d.ts +0 -2
- package/build/legacy/QueryClientProvider.d.ts.map +1 -1
- package/build/legacy/QueryClientProvider.js +1 -2
- package/build/legacy/QueryErrorResetBoundary.cjs +2 -3
- package/build/legacy/QueryErrorResetBoundary.d.cts +1 -3
- package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.ts +1 -3
- package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.js +1 -2
- package/build/legacy/errorBoundaryUtils.cjs +2 -3
- package/build/legacy/errorBoundaryUtils.d.cts +0 -2
- package/build/legacy/errorBoundaryUtils.d.cts.map +1 -1
- package/build/legacy/errorBoundaryUtils.d.ts +0 -2
- package/build/legacy/errorBoundaryUtils.d.ts.map +1 -1
- package/build/legacy/errorBoundaryUtils.js +1 -2
- package/build/legacy/index.cjs +1 -2
- package/build/legacy/index.js +1 -2
- package/build/legacy/infiniteQueryOptions.cjs +1 -2
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +16 -16
- package/build/legacy/infiniteQueryOptions.d.cts.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.ts +16 -16
- package/build/legacy/infiniteQueryOptions.d.ts.map +1 -1
- package/build/legacy/infiniteQueryOptions.js +1 -2
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationOptions.cjs +1 -2
- package/build/legacy/mutationOptions.d.cts +0 -2
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +0 -2
- package/build/legacy/mutationOptions.d.ts.map +1 -1
- package/build/legacy/mutationOptions.js +1 -2
- package/build/legacy/queryOptions.cjs +1 -2
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +16 -15
- package/build/legacy/queryOptions.d.cts.map +1 -1
- package/build/legacy/queryOptions.d.ts +16 -15
- package/build/legacy/queryOptions.d.ts.map +1 -1
- package/build/legacy/queryOptions.js +1 -2
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-CmQyd0Gu.cjs} +1 -2
- package/build/legacy/suspense.cjs +1 -2
- package/build/legacy/suspense.d.cts +0 -2
- package/build/legacy/suspense.d.cts.map +1 -1
- package/build/legacy/suspense.d.ts +0 -2
- package/build/legacy/suspense.d.ts.map +1 -1
- package/build/legacy/suspense.js +1 -2
- package/build/legacy/types.cjs +1 -2
- package/build/legacy/types.d.cts +0 -2
- package/build/legacy/types.d.cts.map +1 -1
- package/build/legacy/types.d.ts +0 -2
- package/build/legacy/types.d.ts.map +1 -1
- package/build/legacy/types.js +1 -2
- package/build/legacy/useBaseQuery.cjs +5 -6
- package/build/legacy/useBaseQuery.cjs.map +1 -1
- package/build/legacy/useBaseQuery.d.cts +0 -2
- package/build/legacy/useBaseQuery.d.cts.map +1 -1
- package/build/legacy/useBaseQuery.d.ts +0 -2
- package/build/legacy/useBaseQuery.d.ts.map +1 -1
- package/build/legacy/useBaseQuery.js +4 -5
- package/build/legacy/useBaseQuery.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs +1 -2
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +2 -4
- package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +2 -4
- package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useInfiniteQuery.js +1 -2
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +2 -3
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +1 -3
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +1 -3
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useIsFetching.js +1 -2
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +2 -3
- package/build/legacy/useMutation.d.cts +0 -2
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +0 -2
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutation.js +1 -2
- package/build/legacy/useMutationState.cjs +2 -3
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.d.cts +1 -3
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +1 -3
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/useMutationState.js +1 -2
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs +1 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +0 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +0 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.js +1 -2
- package/build/legacy/usePrefetchQuery.cjs +1 -2
- package/build/legacy/usePrefetchQuery.d.cts +0 -2
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +0 -2
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.js +1 -2
- package/build/legacy/useQueries.cjs +4 -5
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +0 -2
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +0 -2
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js +3 -4
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs +1 -2
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +5 -7
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +5 -7
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js +1 -2
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.cjs +1 -2
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +0 -2
- package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +0 -2
- package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.js +1 -2
- package/build/legacy/useSuspenseQueries.cjs +1 -2
- package/build/legacy/useSuspenseQueries.d.cts +0 -2
- package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
- package/build/legacy/useSuspenseQueries.d.ts +0 -2
- package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
- package/build/legacy/useSuspenseQueries.js +1 -2
- package/build/legacy/useSuspenseQuery.cjs +1 -2
- package/build/legacy/useSuspenseQuery.d.cts +0 -2
- package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseQuery.d.ts +0 -2
- package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseQuery.js +1 -2
- package/build/modern/HydrationBoundary.cjs +2 -3
- package/build/modern/HydrationBoundary.d.cts +0 -2
- package/build/modern/HydrationBoundary.d.cts.map +1 -1
- package/build/modern/HydrationBoundary.d.ts +0 -2
- package/build/modern/HydrationBoundary.d.ts.map +1 -1
- package/build/modern/HydrationBoundary.js +1 -2
- package/build/modern/IsRestoringProvider.cjs +2 -3
- package/build/modern/IsRestoringProvider.d.cts +0 -2
- package/build/modern/IsRestoringProvider.d.cts.map +1 -1
- package/build/modern/IsRestoringProvider.d.ts +0 -2
- package/build/modern/IsRestoringProvider.d.ts.map +1 -1
- package/build/modern/IsRestoringProvider.js +1 -2
- package/build/modern/QueryClientProvider.cjs +2 -3
- package/build/modern/QueryClientProvider.d.cts +0 -2
- package/build/modern/QueryClientProvider.d.cts.map +1 -1
- package/build/modern/QueryClientProvider.d.ts +0 -2
- package/build/modern/QueryClientProvider.d.ts.map +1 -1
- package/build/modern/QueryClientProvider.js +1 -2
- package/build/modern/QueryErrorResetBoundary.cjs +2 -3
- package/build/modern/QueryErrorResetBoundary.d.cts +1 -3
- package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.ts +1 -3
- package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.js +1 -2
- package/build/modern/errorBoundaryUtils.cjs +2 -3
- package/build/modern/errorBoundaryUtils.d.cts +0 -2
- package/build/modern/errorBoundaryUtils.d.cts.map +1 -1
- package/build/modern/errorBoundaryUtils.d.ts +0 -2
- package/build/modern/errorBoundaryUtils.d.ts.map +1 -1
- package/build/modern/errorBoundaryUtils.js +1 -2
- package/build/modern/index.cjs +1 -2
- package/build/modern/index.js +1 -2
- package/build/modern/infiniteQueryOptions.cjs +1 -2
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +16 -16
- package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
- package/build/modern/infiniteQueryOptions.d.ts +16 -16
- package/build/modern/infiniteQueryOptions.d.ts.map +1 -1
- package/build/modern/infiniteQueryOptions.js +1 -2
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationOptions.cjs +1 -2
- package/build/modern/mutationOptions.d.cts +0 -2
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +0 -2
- package/build/modern/mutationOptions.d.ts.map +1 -1
- package/build/modern/mutationOptions.js +1 -2
- package/build/modern/queryOptions.cjs +1 -2
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +16 -15
- package/build/modern/queryOptions.d.cts.map +1 -1
- package/build/modern/queryOptions.d.ts +16 -15
- package/build/modern/queryOptions.d.ts.map +1 -1
- package/build/modern/queryOptions.js +1 -2
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-CmQyd0Gu.cjs} +1 -2
- package/build/modern/suspense.cjs +1 -2
- package/build/modern/suspense.d.cts +0 -2
- package/build/modern/suspense.d.cts.map +1 -1
- package/build/modern/suspense.d.ts +0 -2
- package/build/modern/suspense.d.ts.map +1 -1
- package/build/modern/suspense.js +1 -2
- package/build/modern/types.cjs +1 -2
- package/build/modern/types.d.cts +0 -2
- package/build/modern/types.d.cts.map +1 -1
- package/build/modern/types.d.ts +0 -2
- package/build/modern/types.d.ts.map +1 -1
- package/build/modern/types.js +1 -2
- package/build/modern/useBaseQuery.cjs +5 -6
- package/build/modern/useBaseQuery.cjs.map +1 -1
- package/build/modern/useBaseQuery.d.cts +0 -2
- package/build/modern/useBaseQuery.d.cts.map +1 -1
- package/build/modern/useBaseQuery.d.ts +0 -2
- package/build/modern/useBaseQuery.d.ts.map +1 -1
- package/build/modern/useBaseQuery.js +4 -5
- package/build/modern/useBaseQuery.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs +1 -2
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +2 -4
- package/build/modern/useInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useInfiniteQuery.d.ts +2 -4
- package/build/modern/useInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useInfiniteQuery.js +1 -2
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +2 -3
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +1 -3
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +1 -3
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useIsFetching.js +1 -2
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +2 -3
- package/build/modern/useMutation.d.cts +0 -2
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +0 -2
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutation.js +1 -2
- package/build/modern/useMutationState.cjs +2 -3
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.d.cts +1 -3
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +1 -3
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/useMutationState.js +1 -2
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs +1 -2
- package/build/modern/usePrefetchInfiniteQuery.d.cts +0 -2
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +0 -2
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.js +1 -2
- package/build/modern/usePrefetchQuery.cjs +1 -2
- package/build/modern/usePrefetchQuery.d.cts +0 -2
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +0 -2
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.js +1 -2
- package/build/modern/useQueries.cjs +4 -5
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +0 -2
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +0 -2
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js +3 -4
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs +1 -2
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +5 -7
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +5 -7
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js +1 -2
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.cjs +1 -2
- package/build/modern/useSuspenseInfiniteQuery.d.cts +0 -2
- package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.ts +0 -2
- package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.js +1 -2
- package/build/modern/useSuspenseQueries.cjs +1 -2
- package/build/modern/useSuspenseQueries.d.cts +0 -2
- package/build/modern/useSuspenseQueries.d.cts.map +1 -1
- package/build/modern/useSuspenseQueries.d.ts +0 -2
- package/build/modern/useSuspenseQueries.d.ts.map +1 -1
- package/build/modern/useSuspenseQueries.js +1 -2
- package/build/modern/useSuspenseQuery.cjs +1 -2
- package/build/modern/useSuspenseQuery.d.cts +0 -2
- package/build/modern/useSuspenseQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseQuery.d.ts +0 -2
- package/build/modern/useSuspenseQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseQuery.js +1 -2
- package/package.json +8 -8
- package/src/infiniteQueryOptions.ts +15 -14
- package/src/queryOptions.ts +16 -13
- package/src/useBaseQuery.ts +4 -4
- package/src/useInfiniteQuery.ts +2 -2
- package/src/useIsFetching.ts +1 -1
- package/src/useMutationState.ts +1 -1
- package/src/useQueries.ts +7 -7
- package/src/useQuery.ts +5 -5
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { UseInfiniteQueryOptions } from "./types.js";
|
|
2
2
|
import { DefaultError, InfiniteData, InitialDataFunction, NonUndefinedGuard, OmitKeyof, QueryKey, QueryKeyWithDataTag, SkipToken } from "@tanstack/query-core";
|
|
3
|
-
//#region src/infiniteQueryOptions.d.ts
|
|
4
3
|
/**
|
|
5
|
-
* The options accepted by the `infiniteQueryOptions` overload selected when
|
|
6
|
-
* may be `undefined` while the query is
|
|
4
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is omitted, may be
|
|
5
|
+
* `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is
|
|
6
|
+
* `pending`.
|
|
7
7
|
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
8
8
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
9
9
|
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
@@ -22,9 +22,9 @@ export type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultEr
|
|
|
22
22
|
initialData?: undefined | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | InitialDataFunction<NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>>;
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
|
-
* The options accepted by the `infiniteQueryOptions` overload selected when
|
|
26
|
-
* `
|
|
27
|
-
* `skipToken`.
|
|
25
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when `queryFn` is not `skipToken` and
|
|
26
|
+
* `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as
|
|
27
|
+
* {@link UndefinedInitialDataInfiniteOptions}, but `queryFn` may not be `skipToken`.
|
|
28
28
|
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
29
29
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
30
30
|
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
@@ -34,16 +34,17 @@ export type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultEr
|
|
|
34
34
|
*/
|
|
35
35
|
export type UnusedSkipTokenInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = OmitKeyof<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryFn'> & {
|
|
36
36
|
/**
|
|
37
|
-
* `skipToken` is not allowed as a value here — this overload is selected when
|
|
38
|
-
* you don't intend to run the query yet,
|
|
39
|
-
*
|
|
40
|
-
*
|
|
37
|
+
* `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may
|
|
38
|
+
* be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,
|
|
39
|
+
* set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with "Missing queryFn"
|
|
40
|
+
* unless `enabled` is `false` or a default query function has been defined. A default query function only
|
|
41
|
+
* supplies `queryFn`; it doesn't defer the fetch on its own.
|
|
41
42
|
*/
|
|
42
43
|
queryFn?: Exclude<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>['queryFn'], SkipToken | undefined>;
|
|
43
44
|
};
|
|
44
45
|
/**
|
|
45
|
-
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is
|
|
46
|
-
* never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
46
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is known to be
|
|
47
|
+
* defined — `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
47
48
|
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
48
49
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
49
50
|
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
@@ -59,15 +60,15 @@ export type DefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultErro
|
|
|
59
60
|
* considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the
|
|
60
61
|
* cache.
|
|
61
62
|
*/
|
|
62
|
-
initialData: NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)
|
|
63
|
+
initialData: NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>);
|
|
63
64
|
};
|
|
64
65
|
/**
|
|
65
66
|
* You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.
|
|
66
67
|
* These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
|
|
67
68
|
* `options.queryKey` is required and is the query key to generate options for.
|
|
68
69
|
*
|
|
69
|
-
* This overload is selected when `initialData` is
|
|
70
|
-
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData`
|
|
70
|
+
* This overload is selected when `initialData` is known to be defined.
|
|
71
|
+
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` known to be defined.
|
|
71
72
|
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
72
73
|
* @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or
|
|
73
74
|
* automatically as the user scrolls.
|
|
@@ -175,5 +176,4 @@ export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError
|
|
|
175
176
|
* ```
|
|
176
177
|
*/
|
|
177
178
|
export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
|
|
178
|
-
//#endregion
|
|
179
179
|
//# sourceMappingURL=infiniteQueryOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infiniteQueryOptions.d.ts","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"infiniteQueryOptions.d.ts","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"mappings":";;;;;;;;;;;;;YAuBY,oCACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,wBACF,cACA,QACA,OACA,WACA;;;;;;;;EASA,0BAEI,kBAAkB,aAAa,cAAc,eAC7C,oBACE,kBAAkB,aAAa,cAAc;;;;;;;;;;;;;YAezC,+BACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,UACF,wBAAwB,cAAc,QAAQ,OAAO,WAAW;;;;;;;;EAUhE,UAAU,QACR,wBACE,cACA,QACA,OACA,WACA,wBAEF;;;;;;;;;;;;YAcQ,kCACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,wBACF,cACA,QACA,OACA,WACA;;;;;;;;EASA,aACI,kBAAkB,aAAa,cAAc,sBACtC,kBAAkB,aAAa,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0C1C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,kCACP,cACA,QACA,OACA,WACA,cAED,kCACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsC7C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,+BACP,cACA,QACA,OACA,WACA,cAED,+BACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsC7C,qBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,oCACP,cACA,QACA,OACA,WACA,cAED,oCACD,cACA,QACA,OACA,WACA,cAEA,oBAAoB,WAAW,aAAa,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infiniteQueryOptions.js","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InfiniteData,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions } from './types'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`\n * may be `undefined` while the query is `pending`.\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | InitialDataFunction<\n NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n >\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set and\n * `queryFn` is not `skipToken` — same as {@link UndefinedInitialDataInfiniteOptions}, but `queryFn` may not be\n * `skipToken`.\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = OmitKeyof<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If\n * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a\n * fetch that fails with \"Missing queryFn\" unless `enabled` is `false` or a default query function has been\n * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is\n * never `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n | undefined\n}\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or\n * automatically as the user scrolls.\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @example\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * function Projects() {\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery(projectsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.pages.map((page) => page.projects.map((p) => <li key={p.id}>{p.name}</li>))}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or\n * automatically as the user scrolls.\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments({ postId }: { postId: string }) {\n * const { data, isPending, isError, error } = useInfiniteQuery(commentsOptions(postId))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.pages.map((page) => page.comments.map((c) => <li key={c.id}>{c.text}</li>))}\n * </ul>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages (from a button click or\n * automatically as the user scrolls) and that use `skipToken` to disable the query until `postId` is set.\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments({ postId }: { postId: string }) {\n * const { data, isPending, isError, error } = useInfiniteQuery(commentsOptions(postId))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.pages.map((page) => page.comments.map((c) => <li key={c.id}>{c.text}</li>))}\n * </ul>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AAiTA,SAAgB,qBAAqB,SAAkB;CACrD,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"infiniteQueryOptions.js","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InfiniteData,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions } from './types'\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is omitted, may be\n * `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is\n * `pending`.\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | InitialDataFunction<\n NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n >\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `queryFn` is not `skipToken` and\n * `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as\n * {@link UndefinedInitialDataInfiniteOptions}, but `queryFn` may not be `skipToken`.\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = OmitKeyof<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may\n * be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,\n * set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with \"Missing queryFn\"\n * unless `enabled` is `false` or a default query function has been defined. A default query function only\n * supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is known to be\n * defined — `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,\n * the shape of all fetched pages plus their page params.\n * @template TQueryKey - The type of your `queryKey`.\n * @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n}\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is known to be defined.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` known to be defined.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or\n * automatically as the user scrolls.\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @example\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n *\n * function Projects() {\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery(projectsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.pages.map((page) => page.projects.map((p) => <li key={p.id}>{p.name}</li>))}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or\n * automatically as the user scrolls.\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments({ postId }: { postId: string }) {\n * const { data, isPending, isError, error } = useInfiniteQuery(commentsOptions(postId))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.pages.map((page) => page.comments.map((c) => <li key={c.id}>{c.text}</li>))}\n * </ul>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UnusedSkipTokenInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\n/**\n * You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.\n * These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.\n * `options.queryKey` is required and is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks See {@link useInfiniteQuery} for examples that fetch further pages (from a button click or\n * automatically as the user scrolls) and that use `skipToken` to disable the query until `postId` is set.\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @example\n * A parameterized factory, so the same options object can be reused per `postId`:\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'\n *\n * export const commentsOptions = (postId: string) =>\n * infiniteQueryOptions({\n * queryKey: ['post', postId, 'comments'],\n * queryFn: ({ pageParam }) => fetchComments(postId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * function Comments({ postId }: { postId: string }) {\n * const { data, isPending, isError, error } = useInfiniteQuery(commentsOptions(postId))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.pages.map((page) => page.comments.map((c) => <li key={c.id}>{c.text}</li>))}\n * </ul>\n * )\n * }\n * ```\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> &\n QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>\n\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AAkTA,SAAgB,qBAAqB,SAAkB;CACrD,OAAO;AACT"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// src/mutationOptions.ts
|
|
3
3
|
function mutationOptions(options) {
|
|
4
4
|
return options;
|
|
5
5
|
}
|
|
6
|
-
//#endregion
|
|
7
6
|
exports.mutationOptions = mutationOptions;
|
|
8
7
|
|
|
9
8
|
//# sourceMappingURL=mutationOptions.cjs.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UseMutationOptions } from "./types.cjs";
|
|
2
2
|
import { DefaultError, WithRequired } from "@tanstack/query-core";
|
|
3
|
-
//#region src/mutationOptions.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A
|
|
6
5
|
* `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with
|
|
@@ -54,5 +53,4 @@ export declare function mutationOptions<TData = unknown, TError = DefaultError,
|
|
|
54
53
|
* ```
|
|
55
54
|
*/
|
|
56
55
|
export declare function mutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>(options: Omit<UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>): Omit<UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>;
|
|
57
|
-
//#endregion
|
|
58
56
|
//# sourceMappingURL=mutationOptions.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutationOptions.d.cts","names":[],"sources":["../../src/mutationOptions.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mutationOptions.d.cts","names":[],"sources":["../../src/mutationOptions.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA8BgB,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,aACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,aACD,mBAAmB,OAAO,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BhC,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,KACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,KACD,mBAAmB,OAAO,QAAQ,YAAY"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UseMutationOptions } from "./types.js";
|
|
2
2
|
import { DefaultError, WithRequired } from "@tanstack/query-core";
|
|
3
|
-
//#region src/mutationOptions.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A
|
|
6
5
|
* `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with
|
|
@@ -54,5 +53,4 @@ export declare function mutationOptions<TData = unknown, TError = DefaultError,
|
|
|
54
53
|
* ```
|
|
55
54
|
*/
|
|
56
55
|
export declare function mutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>(options: Omit<UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>): Omit<UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>;
|
|
57
|
-
//#endregion
|
|
58
56
|
//# sourceMappingURL=mutationOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutationOptions.d.ts","names":[],"sources":["../../src/mutationOptions.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mutationOptions.d.ts","names":[],"sources":["../../src/mutationOptions.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA8BgB,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,aACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,aACD,mBAAmB,OAAO,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BhC,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,KACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,KACD,mBAAmB,OAAO,QAAQ,YAAY"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// src/queryOptions.ts
|
|
3
3
|
function queryOptions(options) {
|
|
4
4
|
return options;
|
|
5
5
|
}
|
|
6
|
-
//#endregion
|
|
7
6
|
exports.queryOptions = queryOptions;
|
|
8
7
|
|
|
9
8
|
//# sourceMappingURL=queryOptions.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryOptions.cjs","names":[],"sources":["../../src/queryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryFunction,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseQueryOptions } from './types'\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be\n * `undefined` while the query is `pending`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = UseQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n | NonUndefinedGuard<TQueryFnData>\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set and `queryFn` is\n * not `skipToken` — same as {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UnusedSkipTokenOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If\n * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a\n * fetch that fails with \"Missing queryFn\" unless `enabled` is `false` or a default query function has been\n * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n /**\n * Optional here, but omitting it is only safe when no fetch will be attempted — for example with\n * `enabled: false`, or when a default query function has been defined. Otherwise, an enabled query with no\n * `queryFn` still tries to fetch and fails with a \"Missing queryFn\" error; `initialData` does not prevent this.\n */\n queryFn?: QueryFunction<TQueryFnData, TQueryKey>\n}\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * function Posts() {\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery(postsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks This is the only overload that accepts `queryFn: skipToken`, shown below.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n * @example\n * A factory that disables the query, type safe, until `postId` is set:\n * ```tsx\n * import { queryOptions, skipToken, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (postId: number | undefined) =>\n * queryOptions({\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * })\n *\n * function Post({ postId }: { postId: number | undefined }) {\n * const { data, isLoading, isError, error } = useQuery(postOptions(postId))\n *\n * if (postId == null) return 'Select a post'\n * if (isLoading) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";;AAuPA,SAAgB,aAAa,SAAkB;CAC7C,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"queryOptions.cjs","names":[],"sources":["../../src/queryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryFunction,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseQueryOptions } from './types'\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is omitted, may be\n * `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is\n * `pending`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = UseQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n | NonUndefinedGuard<TQueryFnData>\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `queryFn` is not `skipToken` and\n * `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as\n * {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UnusedSkipTokenOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may\n * be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,\n * set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with \"Missing queryFn\"\n * unless `enabled` is `false` or a default query function has been defined. A default query function only\n * supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is known to be defined —\n * `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n /**\n * Optional here, but omitting it is only safe when no fetch will be attempted — for example with\n * `enabled: false`, or when a default query function has been defined. Otherwise, an enabled query with no\n * `queryFn` still tries to fetch and fails with a \"Missing queryFn\" error; `initialData` does not prevent this.\n */\n queryFn?: QueryFunction<TQueryFnData, TQueryKey>\n}\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * function Posts() {\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery(postsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks This is the only overload that accepts `queryFn: skipToken`, shown below.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n * @example\n * A factory that disables the query, type safe, until `postId` is set:\n * ```tsx\n * import { queryOptions, skipToken, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (postId: number | undefined) =>\n * queryOptions({\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * })\n *\n * function Post({ postId }: { postId: number | undefined }) {\n * const { data, isLoading, isError, error } = useQuery(postOptions(postId))\n *\n * if (postId == null) return 'Select a post'\n * if (isLoading) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";;AA0PA,SAAgB,aAAa,SAAkB;CAC7C,OAAO;AACT"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { UseQueryOptions } from "./types.cjs";
|
|
2
2
|
import { DefaultError, InitialDataFunction, NonUndefinedGuard, OmitKeyof, QueryFunction, QueryKey, QueryKeyWithDataTag, SkipToken } from "@tanstack/query-core";
|
|
3
|
-
//#region src/queryOptions.d.ts
|
|
4
3
|
/**
|
|
5
|
-
* The options accepted by the `queryOptions` overload selected when
|
|
6
|
-
* `undefined` while the query is
|
|
4
|
+
* The options accepted by the `queryOptions` overload selected when `initialData` is omitted, may be
|
|
5
|
+
* `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is
|
|
6
|
+
* `pending`.
|
|
7
7
|
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
8
8
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
9
9
|
* @template TData - The type `data` ends up as after `select` runs.
|
|
@@ -20,8 +20,9 @@ export type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = Default
|
|
|
20
20
|
initialData?: undefined | InitialDataFunction<NonUndefinedGuard<TQueryFnData>> | NonUndefinedGuard<TQueryFnData>;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
|
-
* The options accepted by the `queryOptions` overload selected when
|
|
24
|
-
*
|
|
23
|
+
* The options accepted by the `queryOptions` overload selected when `queryFn` is not `skipToken` and
|
|
24
|
+
* `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as
|
|
25
|
+
* {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.
|
|
25
26
|
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
26
27
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
27
28
|
* @template TData - The type `data` ends up as after `select` runs.
|
|
@@ -29,16 +30,17 @@ export type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = Default
|
|
|
29
30
|
*/
|
|
30
31
|
export type UnusedSkipTokenOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {
|
|
31
32
|
/**
|
|
32
|
-
* `skipToken` is not allowed as a value here — this overload is selected when
|
|
33
|
-
* you don't intend to run the query yet,
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may
|
|
34
|
+
* be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,
|
|
35
|
+
* set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with "Missing queryFn"
|
|
36
|
+
* unless `enabled` is `false` or a default query function has been defined. A default query function only
|
|
37
|
+
* supplies `queryFn`; it doesn't defer the fetch on its own.
|
|
36
38
|
*/
|
|
37
39
|
queryFn?: Exclude<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'], SkipToken | undefined>;
|
|
38
40
|
};
|
|
39
41
|
/**
|
|
40
|
-
* The options accepted by the `queryOptions` overload selected when `initialData` is
|
|
41
|
-
* `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
42
|
+
* The options accepted by the `queryOptions` overload selected when `initialData` is known to be defined —
|
|
43
|
+
* `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
42
44
|
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
43
45
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
44
46
|
* @template TData - The type `data` ends up as after `select` runs.
|
|
@@ -65,9 +67,9 @@ export type DefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultEr
|
|
|
65
67
|
* be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and
|
|
66
68
|
* is the query key to generate options for.
|
|
67
69
|
*
|
|
68
|
-
* This overload is selected when `initialData` is
|
|
69
|
-
* a `select` changes `TData` to include `undefined`).
|
|
70
|
-
* @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData`
|
|
70
|
+
* This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
|
|
71
|
+
* `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
72
|
+
* @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined.
|
|
71
73
|
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
72
74
|
* @see {@link useQuery} to run a query with these options.
|
|
73
75
|
* @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.
|
|
@@ -180,5 +182,4 @@ export declare function queryOptions<TQueryFnData = unknown, TError = DefaultErr
|
|
|
180
182
|
* ```
|
|
181
183
|
*/
|
|
182
184
|
export declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>;
|
|
183
|
-
//#endregion
|
|
184
185
|
//# sourceMappingURL=queryOptions.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryOptions.d.cts","names":[],"sources":["../../src/queryOptions.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"queryOptions.d.cts","names":[],"sources":["../../src/queryOptions.ts"],"mappings":";;;;;;;;;;;YAqBY,4BACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAQ/C,0BAEI,oBAAoB,kBAAkB,iBACtC,kBAAkB;;;;;;;;;;;YAYZ,uBACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,UACF,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAU7C,UAAU,QACR,gBAAgB,cAAc,QAAQ,OAAO,uBAC7C;;;;;;;;;;YAYQ,0BACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,KAAK,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAQpD,aACI,kBAAkB,uBACX,kBAAkB;;;;;;EAM7B,UAAU,cAAc,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCxB,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,0BAA0B,cAAc,QAAQ,OAAO,aAC/D,0BAA0B,cAAc,QAAQ,OAAO,aACxD,oBAAoB,WAAW,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA+B/B,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,uBAAuB,cAAc,QAAQ,OAAO,aAC5D,uBAAuB,cAAc,QAAQ,OAAO,aACrD,oBAAoB,WAAW,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqD/B,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,4BAA4B,cAAc,QAAQ,OAAO,aACjE,4BAA4B,cAAc,QAAQ,OAAO,aAC1D,oBAAoB,WAAW,cAAc"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { UseQueryOptions } from "./types.js";
|
|
2
2
|
import { DefaultError, InitialDataFunction, NonUndefinedGuard, OmitKeyof, QueryFunction, QueryKey, QueryKeyWithDataTag, SkipToken } from "@tanstack/query-core";
|
|
3
|
-
//#region src/queryOptions.d.ts
|
|
4
3
|
/**
|
|
5
|
-
* The options accepted by the `queryOptions` overload selected when
|
|
6
|
-
* `undefined` while the query is
|
|
4
|
+
* The options accepted by the `queryOptions` overload selected when `initialData` is omitted, may be
|
|
5
|
+
* `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is
|
|
6
|
+
* `pending`.
|
|
7
7
|
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
8
8
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
9
9
|
* @template TData - The type `data` ends up as after `select` runs.
|
|
@@ -20,8 +20,9 @@ export type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = Default
|
|
|
20
20
|
initialData?: undefined | InitialDataFunction<NonUndefinedGuard<TQueryFnData>> | NonUndefinedGuard<TQueryFnData>;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
|
-
* The options accepted by the `queryOptions` overload selected when
|
|
24
|
-
*
|
|
23
|
+
* The options accepted by the `queryOptions` overload selected when `queryFn` is not `skipToken` and
|
|
24
|
+
* `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as
|
|
25
|
+
* {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.
|
|
25
26
|
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
26
27
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
27
28
|
* @template TData - The type `data` ends up as after `select` runs.
|
|
@@ -29,16 +30,17 @@ export type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = Default
|
|
|
29
30
|
*/
|
|
30
31
|
export type UnusedSkipTokenOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {
|
|
31
32
|
/**
|
|
32
|
-
* `skipToken` is not allowed as a value here — this overload is selected when
|
|
33
|
-
* you don't intend to run the query yet,
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may
|
|
34
|
+
* be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,
|
|
35
|
+
* set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with "Missing queryFn"
|
|
36
|
+
* unless `enabled` is `false` or a default query function has been defined. A default query function only
|
|
37
|
+
* supplies `queryFn`; it doesn't defer the fetch on its own.
|
|
36
38
|
*/
|
|
37
39
|
queryFn?: Exclude<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'], SkipToken | undefined>;
|
|
38
40
|
};
|
|
39
41
|
/**
|
|
40
|
-
* The options accepted by the `queryOptions` overload selected when `initialData` is
|
|
41
|
-
* `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
42
|
+
* The options accepted by the `queryOptions` overload selected when `initialData` is known to be defined —
|
|
43
|
+
* `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
42
44
|
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
43
45
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
44
46
|
* @template TData - The type `data` ends up as after `select` runs.
|
|
@@ -65,9 +67,9 @@ export type DefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultEr
|
|
|
65
67
|
* be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and
|
|
66
68
|
* is the query key to generate options for.
|
|
67
69
|
*
|
|
68
|
-
* This overload is selected when `initialData` is
|
|
69
|
-
* a `select` changes `TData` to include `undefined`).
|
|
70
|
-
* @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData`
|
|
70
|
+
* This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
|
|
71
|
+
* `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
72
|
+
* @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined.
|
|
71
73
|
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
72
74
|
* @see {@link useQuery} to run a query with these options.
|
|
73
75
|
* @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.
|
|
@@ -180,5 +182,4 @@ export declare function queryOptions<TQueryFnData = unknown, TError = DefaultErr
|
|
|
180
182
|
* ```
|
|
181
183
|
*/
|
|
182
184
|
export declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>;
|
|
183
|
-
//#endregion
|
|
184
185
|
//# sourceMappingURL=queryOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryOptions.d.ts","names":[],"sources":["../../src/queryOptions.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"queryOptions.d.ts","names":[],"sources":["../../src/queryOptions.ts"],"mappings":";;;;;;;;;;;YAqBY,4BACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAQ/C,0BAEI,oBAAoB,kBAAkB,iBACtC,kBAAkB;;;;;;;;;;;YAYZ,uBACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,UACF,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAU7C,UAAU,QACR,gBAAgB,cAAc,QAAQ,OAAO,uBAC7C;;;;;;;;;;YAYQ,0BACV,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,YAC3B,KAAK,gBAAgB,cAAc,QAAQ,OAAO;;;;;;;;EAQpD,aACI,kBAAkB,uBACX,kBAAkB;;;;;;EAM7B,UAAU,cAAc,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwCxB,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,0BAA0B,cAAc,QAAQ,OAAO,aAC/D,0BAA0B,cAAc,QAAQ,OAAO,aACxD,oBAAoB,WAAW,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA+B/B,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,uBAAuB,cAAc,QAAQ,OAAO,aAC5D,uBAAuB,cAAc,QAAQ,OAAO,aACrD,oBAAoB,WAAW,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqD/B,aACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,4BAA4B,cAAc,QAAQ,OAAO,aACjE,4BAA4B,cAAc,QAAQ,OAAO,aAC1D,oBAAoB,WAAW,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryOptions.js","names":[],"sources":["../../src/queryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryFunction,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseQueryOptions } from './types'\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be\n * `undefined` while the query is `pending`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = UseQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n | NonUndefinedGuard<TQueryFnData>\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set and `queryFn` is\n * not `skipToken` — same as {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UnusedSkipTokenOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If\n * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a\n * fetch that fails with \"Missing queryFn\" unless `enabled` is `false` or a default query function has been\n * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n /**\n * Optional here, but omitting it is only safe when no fetch will be attempted — for example with\n * `enabled: false`, or when a default query function has been defined. Otherwise, an enabled query with no\n * `queryFn` still tries to fetch and fails with a \"Missing queryFn\" error; `initialData` does not prevent this.\n */\n queryFn?: QueryFunction<TQueryFnData, TQueryKey>\n}\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * function Posts() {\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery(postsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks This is the only overload that accepts `queryFn: skipToken`, shown below.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n * @example\n * A factory that disables the query, type safe, until `postId` is set:\n * ```tsx\n * import { queryOptions, skipToken, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (postId: number | undefined) =>\n * queryOptions({\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * })\n *\n * function Post({ postId }: { postId: number | undefined }) {\n * const { data, isLoading, isError, error } = useQuery(postOptions(postId))\n *\n * if (postId == null) return 'Select a post'\n * if (isLoading) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AAuPA,SAAgB,aAAa,SAAkB;CAC7C,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"queryOptions.js","names":[],"sources":["../../src/queryOptions.ts"],"sourcesContent":["import type {\n DefaultError,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryFunction,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { UseQueryOptions } from './types'\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is omitted, may be\n * `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is\n * `pending`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = UseQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n | NonUndefinedGuard<TQueryFnData>\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `queryFn` is not `skipToken` and\n * `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as\n * {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UnusedSkipTokenOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may\n * be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,\n * set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with \"Missing queryFn\"\n * unless `enabled` is `false` or a default query function has been defined. A default query function only\n * supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is known to be defined —\n * `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n /**\n * Optional here, but omitting it is only safe when no fetch will be attempted — for example with\n * `enabled: false`, or when a default query function has been defined. Otherwise, an enabled query with no\n * `queryFn` still tries to fetch and fails with a \"Missing queryFn\" error; `initialData` does not prevent this.\n */\n queryFn?: QueryFunction<TQueryFnData, TQueryKey>\n}\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n *\n * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * function Posts() {\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery(postsOptions)\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can\n * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and\n * is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks This is the only overload that accepts `queryFn: skipToken`, shown below.\n * @see {@link useQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * function Post({ id }: { id: string }) {\n * const { data, isPending, isError, error } = useQuery(postOptions(id))\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data.title}</h1>\n * }\n * ```\n * @example\n * A factory that disables the query, type safe, until `postId` is set:\n * ```tsx\n * import { queryOptions, skipToken, useQuery } from '@tanstack/react-query'\n *\n * export const postOptions = (postId: number | undefined) =>\n * queryOptions({\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * })\n *\n * function Post({ postId }: { postId: number | undefined }) {\n * const { data, isLoading, isError, error } = useQuery(postOptions(postId))\n *\n * if (postId == null) return 'Select a post'\n * if (isLoading) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AA0PA,SAAgB,aAAa,SAAkB;CAC7C,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -19,7 +19,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
19
19
|
value: mod,
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
22
|
-
//#endregion
|
|
23
22
|
Object.defineProperty(exports, "__toESM", {
|
|
24
23
|
enumerable: true,
|
|
25
24
|
get: function() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// src/suspense.ts
|
|
3
3
|
/**
|
|
4
4
|
* The default `throwOnError` of the suspense hooks: throws the error to the nearest error boundary
|
|
5
5
|
* only if the query has no data to show.
|
|
@@ -41,7 +41,6 @@ const shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense &
|
|
|
41
41
|
const fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
|
42
42
|
errorResetBoundary.clearReset();
|
|
43
43
|
});
|
|
44
|
-
//#endregion
|
|
45
44
|
exports.defaultThrowOnError = defaultThrowOnError;
|
|
46
45
|
exports.ensureSuspenseTimers = ensureSuspenseTimers;
|
|
47
46
|
exports.fetchOptimistic = fetchOptimistic;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { QueryErrorResetBoundaryValue } from "./QueryErrorResetBoundary.cjs";
|
|
2
2
|
import { DefaultError, DefaultedQueryObserverOptions, Query, QueryKey, QueryObserver, QueryObserverResult } from "@tanstack/query-core";
|
|
3
|
-
//#region src/suspense.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* The default `throwOnError` of the suspense hooks: throws the error to the nearest error boundary
|
|
6
5
|
* only if the query has no data to show.
|
|
@@ -32,5 +31,4 @@ export declare const shouldSuspend: (defaultedOptions: DefaultedQueryObserverOpt
|
|
|
32
31
|
* @returns A promise that resolves once the fetch settles. It never rejects.
|
|
33
32
|
*/
|
|
34
33
|
export declare const fetchOptimistic: <TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(defaultedOptions: DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>, errorResetBoundary: QueryErrorResetBoundaryValue) => Promise<void | QueryObserverResult<TData, TError>>;
|
|
35
|
-
//#endregion
|
|
36
34
|
//# sourceMappingURL=suspense.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suspense.d.cts","names":[],"sources":["../../src/suspense.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"suspense.d.cts","names":[],"sources":["../../src/suspense.ts"],"mappings":";;;;;;;;;qBAiBa,sBACX,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,QAAQ,QACR,OAAO,MAAM,cAAc,QAAQ,OAAO;;;;;;;qBAS/B,uBACX,kBAAkB;;;;;;;qBAiCP,gBACX,kBACI,oEAEJ,QAAQ;;;;;;;;;qBAWG,kBACX,cACA,QACA,OACA,YACA,kBAAkB,UAElB,kBAAkB,8BAChB,cACA,QACA,OACA,YACA,YAEF,UAAU,cAAc,cAAc,QAAQ,OAAO,YAAY,YACjE,oBAAoB,iCAA4B,eAAA,oBAAA,OAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { QueryErrorResetBoundaryValue } from "./QueryErrorResetBoundary.js";
|
|
2
2
|
import { DefaultError, DefaultedQueryObserverOptions, Query, QueryKey, QueryObserver, QueryObserverResult } from "@tanstack/query-core";
|
|
3
|
-
//#region src/suspense.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* The default `throwOnError` of the suspense hooks: throws the error to the nearest error boundary
|
|
6
5
|
* only if the query has no data to show.
|
|
@@ -32,5 +31,4 @@ export declare const shouldSuspend: (defaultedOptions: DefaultedQueryObserverOpt
|
|
|
32
31
|
* @returns A promise that resolves once the fetch settles. It never rejects.
|
|
33
32
|
*/
|
|
34
33
|
export declare const fetchOptimistic: <TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(defaultedOptions: DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, observer: QueryObserver<TQueryFnData, TError, TData, TQueryData, TQueryKey>, errorResetBoundary: QueryErrorResetBoundaryValue) => Promise<void | QueryObserverResult<TData, TError>>;
|
|
35
|
-
//#endregion
|
|
36
34
|
//# sourceMappingURL=suspense.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suspense.d.ts","names":[],"sources":["../../src/suspense.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"suspense.d.ts","names":[],"sources":["../../src/suspense.ts"],"mappings":";;;;;;;;;qBAiBa,sBACX,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,QAAQ,QACR,OAAO,MAAM,cAAc,QAAQ,OAAO;;;;;;;qBAS/B,uBACX,kBAAkB;;;;;;;qBAiCP,gBACX,kBACI,oEAEJ,QAAQ;;;;;;;;;qBAWG,kBACX,cACA,QACA,OACA,YACA,kBAAkB,UAElB,kBAAkB,8BAChB,cACA,QACA,OACA,YACA,YAEF,UAAU,cAAc,cAAc,QAAQ,OAAO,YAAY,YACjE,oBAAoB,iCAA4B,eAAA,oBAAA,OAAA"}
|