@tanstack/preact-query 5.102.3 → 5.102.5
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 +43 -0
- package/build/legacy/HydrationBoundary.cjs.map +1 -1
- package/build/legacy/HydrationBoundary.d.cts +61 -0
- package/build/legacy/HydrationBoundary.d.cts.map +1 -1
- package/build/legacy/HydrationBoundary.d.ts +61 -0
- package/build/legacy/HydrationBoundary.d.ts.map +1 -1
- package/build/legacy/HydrationBoundary.js +43 -0
- package/build/legacy/HydrationBoundary.js.map +1 -1
- package/build/legacy/IsRestoringProvider.cjs +11 -0
- package/build/legacy/IsRestoringProvider.cjs.map +1 -1
- package/build/legacy/IsRestoringProvider.d.cts +11 -0
- package/build/legacy/IsRestoringProvider.d.cts.map +1 -1
- package/build/legacy/IsRestoringProvider.d.ts +11 -0
- package/build/legacy/IsRestoringProvider.d.ts.map +1 -1
- package/build/legacy/IsRestoringProvider.js +11 -0
- package/build/legacy/IsRestoringProvider.js.map +1 -1
- package/build/legacy/QueryClientProvider.cjs +30 -0
- package/build/legacy/QueryClientProvider.cjs.map +1 -1
- package/build/legacy/QueryClientProvider.d.cts +41 -0
- package/build/legacy/QueryClientProvider.d.cts.map +1 -1
- package/build/legacy/QueryClientProvider.d.ts +41 -0
- package/build/legacy/QueryClientProvider.d.ts.map +1 -1
- package/build/legacy/QueryClientProvider.js +30 -0
- package/build/legacy/QueryClientProvider.js.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.cjs +77 -0
- package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.cts +108 -0
- package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.ts +108 -0
- package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.js +77 -0
- package/build/legacy/QueryErrorResetBoundary.js.map +1 -1
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +187 -0
- package/build/legacy/infiniteQueryOptions.d.cts.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.ts +187 -0
- package/build/legacy/infiniteQueryOptions.d.ts.map +1 -1
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationOptions.cjs.map +1 -1
- package/build/legacy/mutationOptions.d.cts +68 -0
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +68 -0
- package/build/legacy/mutationOptions.d.ts.map +1 -1
- package/build/legacy/mutationOptions.js.map +1 -1
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +198 -0
- package/build/legacy/queryOptions.d.cts.map +1 -1
- package/build/legacy/queryOptions.d.ts +198 -0
- package/build/legacy/queryOptions.d.ts.map +1 -1
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +228 -2
- package/build/legacy/types.d.cts.map +1 -1
- package/build/legacy/types.d.ts +228 -2
- package/build/legacy/types.d.ts.map +1 -1
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +120 -0
- package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +120 -0
- package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +34 -0
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +34 -0
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +34 -0
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useIsFetching.js +34 -0
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +170 -0
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.d.cts +170 -0
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +170 -0
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutation.js +170 -0
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useMutationState.cjs +74 -0
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.d.cts +74 -0
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +74 -0
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/useMutationState.js +74 -0
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs +44 -0
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +44 -0
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +44 -0
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.js +44 -0
- package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/legacy/usePrefetchQuery.cjs +35 -0
- package/build/legacy/usePrefetchQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +35 -0
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +35 -0
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.js +35 -0
- package/build/legacy/usePrefetchQuery.js.map +1 -1
- package/build/legacy/useQueries.cjs +50 -0
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +85 -2
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +85 -2
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js +50 -0
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +186 -0
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +186 -0
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.cjs +56 -0
- package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +56 -0
- package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +56 -0
- package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.js +56 -0
- package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -1
- package/build/legacy/useSuspenseQueries.cjs.map +1 -1
- package/build/legacy/useSuspenseQueries.d.cts +196 -2
- package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
- package/build/legacy/useSuspenseQueries.d.ts +196 -2
- package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
- package/build/legacy/useSuspenseQueries.js.map +1 -1
- package/build/legacy/useSuspenseQuery.cjs +47 -0
- package/build/legacy/useSuspenseQuery.cjs.map +1 -1
- package/build/legacy/useSuspenseQuery.d.cts +47 -0
- package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseQuery.d.ts +47 -0
- package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseQuery.js +47 -0
- package/build/legacy/useSuspenseQuery.js.map +1 -1
- package/build/modern/HydrationBoundary.cjs +43 -0
- package/build/modern/HydrationBoundary.cjs.map +1 -1
- package/build/modern/HydrationBoundary.d.cts +61 -0
- package/build/modern/HydrationBoundary.d.cts.map +1 -1
- package/build/modern/HydrationBoundary.d.ts +61 -0
- package/build/modern/HydrationBoundary.d.ts.map +1 -1
- package/build/modern/HydrationBoundary.js +43 -0
- package/build/modern/HydrationBoundary.js.map +1 -1
- package/build/modern/IsRestoringProvider.cjs +11 -0
- package/build/modern/IsRestoringProvider.cjs.map +1 -1
- package/build/modern/IsRestoringProvider.d.cts +11 -0
- package/build/modern/IsRestoringProvider.d.cts.map +1 -1
- package/build/modern/IsRestoringProvider.d.ts +11 -0
- package/build/modern/IsRestoringProvider.d.ts.map +1 -1
- package/build/modern/IsRestoringProvider.js +11 -0
- package/build/modern/IsRestoringProvider.js.map +1 -1
- package/build/modern/QueryClientProvider.cjs +30 -0
- package/build/modern/QueryClientProvider.cjs.map +1 -1
- package/build/modern/QueryClientProvider.d.cts +41 -0
- package/build/modern/QueryClientProvider.d.cts.map +1 -1
- package/build/modern/QueryClientProvider.d.ts +41 -0
- package/build/modern/QueryClientProvider.d.ts.map +1 -1
- package/build/modern/QueryClientProvider.js +30 -0
- package/build/modern/QueryClientProvider.js.map +1 -1
- package/build/modern/QueryErrorResetBoundary.cjs +77 -0
- package/build/modern/QueryErrorResetBoundary.cjs.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.cts +108 -0
- package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.ts +108 -0
- package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.js +77 -0
- package/build/modern/QueryErrorResetBoundary.js.map +1 -1
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +187 -0
- package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
- package/build/modern/infiniteQueryOptions.d.ts +187 -0
- package/build/modern/infiniteQueryOptions.d.ts.map +1 -1
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationOptions.cjs.map +1 -1
- package/build/modern/mutationOptions.d.cts +68 -0
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +68 -0
- package/build/modern/mutationOptions.d.ts.map +1 -1
- package/build/modern/mutationOptions.js.map +1 -1
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +198 -0
- package/build/modern/queryOptions.d.cts.map +1 -1
- package/build/modern/queryOptions.d.ts +198 -0
- package/build/modern/queryOptions.d.ts.map +1 -1
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +228 -2
- package/build/modern/types.d.cts.map +1 -1
- package/build/modern/types.d.ts +228 -2
- package/build/modern/types.d.ts.map +1 -1
- package/build/modern/types.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +120 -0
- package/build/modern/useInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useInfiniteQuery.d.ts +120 -0
- package/build/modern/useInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +34 -0
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +34 -0
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +34 -0
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useIsFetching.js +34 -0
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +170 -0
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.d.cts +170 -0
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +170 -0
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutation.js +170 -0
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useMutationState.cjs +74 -0
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.d.cts +74 -0
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +74 -0
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/useMutationState.js +74 -0
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs +44 -0
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +44 -0
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +44 -0
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.js +44 -0
- package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/modern/usePrefetchQuery.cjs +35 -0
- package/build/modern/usePrefetchQuery.cjs.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +35 -0
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +35 -0
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.js +35 -0
- package/build/modern/usePrefetchQuery.js.map +1 -1
- package/build/modern/useQueries.cjs +50 -0
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +85 -2
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +85 -2
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js +50 -0
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +186 -0
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +186 -0
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.cjs +56 -0
- package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.cts +56 -0
- package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.ts +56 -0
- package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.js +56 -0
- package/build/modern/useSuspenseInfiniteQuery.js.map +1 -1
- package/build/modern/useSuspenseQueries.cjs.map +1 -1
- package/build/modern/useSuspenseQueries.d.cts +196 -2
- package/build/modern/useSuspenseQueries.d.cts.map +1 -1
- package/build/modern/useSuspenseQueries.d.ts +196 -2
- package/build/modern/useSuspenseQueries.d.ts.map +1 -1
- package/build/modern/useSuspenseQueries.js.map +1 -1
- package/build/modern/useSuspenseQuery.cjs +47 -0
- package/build/modern/useSuspenseQuery.cjs.map +1 -1
- package/build/modern/useSuspenseQuery.d.cts +47 -0
- package/build/modern/useSuspenseQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseQuery.d.ts +47 -0
- package/build/modern/useSuspenseQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseQuery.js +47 -0
- package/build/modern/useSuspenseQuery.js.map +1 -1
- package/package.json +3 -3
- package/src/HydrationBoundary.tsx +61 -0
- package/src/IsRestoringProvider.ts +12 -0
- package/src/QueryClientProvider.tsx +41 -0
- package/src/QueryErrorResetBoundary.tsx +111 -0
- package/src/infiniteQueryOptions.ts +187 -0
- package/src/mutationOptions.ts +68 -0
- package/src/queryOptions.ts +198 -0
- package/src/types.ts +228 -2
- package/src/useInfiniteQuery.ts +120 -0
- package/src/useIsFetching.ts +34 -0
- package/src/useMutation.ts +170 -0
- package/src/useMutationState.ts +74 -0
- package/src/usePrefetchInfiniteQuery.tsx +44 -0
- package/src/usePrefetchQuery.tsx +35 -0
- package/src/useQueries.ts +85 -2
- package/src/useQuery.ts +186 -0
- package/src/useSuspenseInfiniteQuery.ts +56 -0
- package/src/useSuspenseQueries.ts +196 -2
- package/src/useSuspenseQuery.ts +47 -0
|
@@ -1,17 +1,204 @@
|
|
|
1
1
|
import { UseInfiniteQueryOptions } from "./types.cjs";
|
|
2
2
|
import { DefaultError, InfiniteData, InitialDataFunction, NonUndefinedGuard, OmitKeyof, QueryKey, QueryKeyWithDataTag, SkipToken } from "@tanstack/query-core";
|
|
3
3
|
//#region src/infiniteQueryOptions.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`
|
|
6
|
+
* may be `undefined` while the query is `pending`.
|
|
7
|
+
*
|
|
8
|
+
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
9
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
10
|
+
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
11
|
+
* the shape of all fetched pages plus their page params.
|
|
12
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
13
|
+
* @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
|
|
14
|
+
*/
|
|
4
15
|
type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
16
|
+
/**
|
|
17
|
+
* If set, this value will be used as the initial data for the query cache (as long as the query hasn't been
|
|
18
|
+
* created or cached yet). If set to a function, the function will be called **once** during the shared/root
|
|
19
|
+
* query initialization, and be expected to synchronously return the initial data. Initial data is
|
|
20
|
+
* considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the
|
|
21
|
+
* cache.
|
|
22
|
+
*/
|
|
5
23
|
initialData?: undefined | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | InitialDataFunction<NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>>;
|
|
6
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set and
|
|
27
|
+
* `queryFn` is not `skipToken` — same as {@link UndefinedInitialDataInfiniteOptions}, but `queryFn` may not be
|
|
28
|
+
* `skipToken`.
|
|
29
|
+
*
|
|
30
|
+
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
31
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
32
|
+
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
33
|
+
* the shape of all fetched pages plus their page params.
|
|
34
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
35
|
+
* @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
|
|
36
|
+
*/
|
|
7
37
|
type UnusedSkipTokenInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = OmitKeyof<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryFn'> & {
|
|
38
|
+
/**
|
|
39
|
+
* `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If
|
|
40
|
+
* you don't intend to run the query yet, omit `queryFn` or use a default query function instead.
|
|
41
|
+
*/
|
|
8
42
|
queryFn?: Exclude<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>['queryFn'], SkipToken | undefined>;
|
|
9
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is
|
|
46
|
+
* never `undefined`.
|
|
47
|
+
*
|
|
48
|
+
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
49
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
50
|
+
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
51
|
+
* the shape of all fetched pages plus their page params.
|
|
52
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
53
|
+
* @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
|
|
54
|
+
*/
|
|
10
55
|
type DefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
56
|
+
/**
|
|
57
|
+
* If set, this value will be used as the initial data for the query cache (as long as the query hasn't been
|
|
58
|
+
* created or cached yet). If set to a function, the function will be called **once** during the shared/root
|
|
59
|
+
* query initialization, and be expected to synchronously return the initial data. Initial data is
|
|
60
|
+
* considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the
|
|
61
|
+
* cache.
|
|
62
|
+
*/
|
|
11
63
|
initialData: NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>) | undefined;
|
|
12
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.
|
|
67
|
+
* These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
|
|
68
|
+
* `options.queryKey` is required and is the query key to generate options for.
|
|
69
|
+
*
|
|
70
|
+
* This overload is selected when `initialData` is set.
|
|
71
|
+
*
|
|
72
|
+
* @see {@link useInfiniteQuery} to run an infinite query with these options.
|
|
73
|
+
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.
|
|
74
|
+
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/preact-query'
|
|
79
|
+
*
|
|
80
|
+
* export const projectsOptions = infiniteQueryOptions({
|
|
81
|
+
* queryKey: ['projects'],
|
|
82
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
83
|
+
* initialPageParam: 0,
|
|
84
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
85
|
+
* initialData: { pages: [], pageParams: [] },
|
|
86
|
+
* })
|
|
87
|
+
*
|
|
88
|
+
* function Projects() {
|
|
89
|
+
* const { data } = useInfiniteQuery(projectsOptions)
|
|
90
|
+
* return <>{data.pages.map((page) => page.projects.map((p) => <p key={p.id}>{p.name}</p>))}</>
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
13
94
|
declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
|
|
95
|
+
/**
|
|
96
|
+
* You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.
|
|
97
|
+
* These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
|
|
98
|
+
* `options.queryKey` is required and is the query key to generate options for.
|
|
99
|
+
*
|
|
100
|
+
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```tsx
|
|
104
|
+
* import { infiniteQueryOptions } from '@tanstack/preact-query'
|
|
105
|
+
*
|
|
106
|
+
* export const projectsOptions = infiniteQueryOptions({
|
|
107
|
+
* queryKey: ['projects'],
|
|
108
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
109
|
+
* initialPageParam: 0,
|
|
110
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
111
|
+
* })
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* A parameterized factory, reused across a hook and an imperative call with the same cache entry:
|
|
116
|
+
* ```tsx
|
|
117
|
+
* import {
|
|
118
|
+
* infiniteQueryOptions,
|
|
119
|
+
* noop,
|
|
120
|
+
* useInfiniteQuery,
|
|
121
|
+
* } from '@tanstack/preact-query'
|
|
122
|
+
*
|
|
123
|
+
* export const commentsOptions = (postId: string) =>
|
|
124
|
+
* infiniteQueryOptions({
|
|
125
|
+
* queryKey: ['post', postId, 'comments'],
|
|
126
|
+
* queryFn: ({ pageParam }) => fetchComments(postId, pageParam),
|
|
127
|
+
* initialPageParam: 0,
|
|
128
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
129
|
+
* })
|
|
130
|
+
*
|
|
131
|
+
* function Comments({ postId }: { postId: string }) {
|
|
132
|
+
* const result = useInfiniteQuery(commentsOptions(postId))
|
|
133
|
+
* if (!result.isSuccess) return 'Loading...'
|
|
134
|
+
* return (
|
|
135
|
+
* <>
|
|
136
|
+
* {result.data.pages.map((page) => page.comments.map((c) => <p key={c.id}>{c.text}</p>))}
|
|
137
|
+
* </>
|
|
138
|
+
* )
|
|
139
|
+
* }
|
|
140
|
+
*
|
|
141
|
+
* // Elsewhere, e.g. to warm the cache before rendering `<Comments>`:
|
|
142
|
+
* queryClient.infiniteQuery(commentsOptions(postId)).catch(noop)
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @see {@link useInfiniteQuery} to run an infinite query with these options.
|
|
146
|
+
* @param options - The {@link UnusedSkipTokenInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.
|
|
147
|
+
*/
|
|
14
148
|
declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
|
|
149
|
+
/**
|
|
150
|
+
* You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.
|
|
151
|
+
* These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
|
|
152
|
+
* `options.queryKey` is required and is the query key to generate options for.
|
|
153
|
+
*
|
|
154
|
+
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```tsx
|
|
158
|
+
* import { infiniteQueryOptions } from '@tanstack/preact-query'
|
|
159
|
+
*
|
|
160
|
+
* export const projectsOptions = infiniteQueryOptions({
|
|
161
|
+
* queryKey: ['projects'],
|
|
162
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
163
|
+
* initialPageParam: 0,
|
|
164
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
165
|
+
* })
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* A parameterized factory, reused across a hook and an imperative call with the same cache entry:
|
|
170
|
+
* ```tsx
|
|
171
|
+
* import {
|
|
172
|
+
* infiniteQueryOptions,
|
|
173
|
+
* noop,
|
|
174
|
+
* useInfiniteQuery,
|
|
175
|
+
* } from '@tanstack/preact-query'
|
|
176
|
+
*
|
|
177
|
+
* export const commentsOptions = (postId: string) =>
|
|
178
|
+
* infiniteQueryOptions({
|
|
179
|
+
* queryKey: ['post', postId, 'comments'],
|
|
180
|
+
* queryFn: ({ pageParam }) => fetchComments(postId, pageParam),
|
|
181
|
+
* initialPageParam: 0,
|
|
182
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
183
|
+
* })
|
|
184
|
+
*
|
|
185
|
+
* function Comments({ postId }: { postId: string }) {
|
|
186
|
+
* const result = useInfiniteQuery(commentsOptions(postId))
|
|
187
|
+
* if (!result.isSuccess) return 'Loading...'
|
|
188
|
+
* return (
|
|
189
|
+
* <>
|
|
190
|
+
* {result.data.pages.map((page) => page.comments.map((c) => <p key={c.id}>{c.text}</p>))}
|
|
191
|
+
* </>
|
|
192
|
+
* )
|
|
193
|
+
* }
|
|
194
|
+
*
|
|
195
|
+
* // Elsewhere, e.g. to warm the cache before rendering `<Comments>`:
|
|
196
|
+
* queryClient.infiniteQuery(commentsOptions(postId)).catch(noop)
|
|
197
|
+
* ```
|
|
198
|
+
*
|
|
199
|
+
* @see {@link useInfiniteQuery} to run an infinite query with these options.
|
|
200
|
+
* @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.
|
|
201
|
+
*/
|
|
15
202
|
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>;
|
|
16
203
|
//#endregion
|
|
17
204
|
export { DefinedInitialDataInfiniteOptions, UndefinedInitialDataInfiniteOptions, UnusedSkipTokenInfiniteOptions, infiniteQueryOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infiniteQueryOptions.d.cts","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"infiniteQueryOptions.d.cts","names":[],"sources":["../../src/infiniteQueryOptions.ts"],"mappings":";;;;;;;;;;;;;;KAwBY,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;;;;;;;;;;;;;;KAgBzC,+BACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,UACF,wBAAwB,cAAc,QAAQ,OAAO,WAAW;;;;;EAOhE,UAAU,QACR,wBACE,cACA,QACA,OACA,WACA,wBAEF;;;;;;;;;;;;;KAeQ,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiC1C,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuD7C,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuD7C,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,17 +1,204 @@
|
|
|
1
1
|
import { UseInfiniteQueryOptions } from "./types.js";
|
|
2
2
|
import { DefaultError, InfiniteData, InitialDataFunction, NonUndefinedGuard, OmitKeyof, QueryKey, QueryKeyWithDataTag, SkipToken } from "@tanstack/query-core";
|
|
3
3
|
//#region src/infiniteQueryOptions.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data`
|
|
6
|
+
* may be `undefined` while the query is `pending`.
|
|
7
|
+
*
|
|
8
|
+
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
9
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
10
|
+
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
11
|
+
* the shape of all fetched pages plus their page params.
|
|
12
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
13
|
+
* @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
|
|
14
|
+
*/
|
|
4
15
|
type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
16
|
+
/**
|
|
17
|
+
* If set, this value will be used as the initial data for the query cache (as long as the query hasn't been
|
|
18
|
+
* created or cached yet). If set to a function, the function will be called **once** during the shared/root
|
|
19
|
+
* query initialization, and be expected to synchronously return the initial data. Initial data is
|
|
20
|
+
* considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the
|
|
21
|
+
* cache.
|
|
22
|
+
*/
|
|
5
23
|
initialData?: undefined | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | InitialDataFunction<NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>>;
|
|
6
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set and
|
|
27
|
+
* `queryFn` is not `skipToken` — same as {@link UndefinedInitialDataInfiniteOptions}, but `queryFn` may not be
|
|
28
|
+
* `skipToken`.
|
|
29
|
+
*
|
|
30
|
+
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
31
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
32
|
+
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
33
|
+
* the shape of all fetched pages plus their page params.
|
|
34
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
35
|
+
* @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
|
|
36
|
+
*/
|
|
7
37
|
type UnusedSkipTokenInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = OmitKeyof<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryFn'> & {
|
|
38
|
+
/**
|
|
39
|
+
* `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If
|
|
40
|
+
* you don't intend to run the query yet, omit `queryFn` or use a default query function instead.
|
|
41
|
+
*/
|
|
8
42
|
queryFn?: Exclude<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>['queryFn'], SkipToken | undefined>;
|
|
9
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is
|
|
46
|
+
* never `undefined`.
|
|
47
|
+
*
|
|
48
|
+
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
49
|
+
* @template TError - The type of errors your `queryFn` may throw.
|
|
50
|
+
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
51
|
+
* the shape of all fetched pages plus their page params.
|
|
52
|
+
* @template TQueryKey - The type of your `queryKey`.
|
|
53
|
+
* @template TPageParam - The type of the parameter passed to `queryFn` to fetch a given page.
|
|
54
|
+
*/
|
|
10
55
|
type DefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
56
|
+
/**
|
|
57
|
+
* If set, this value will be used as the initial data for the query cache (as long as the query hasn't been
|
|
58
|
+
* created or cached yet). If set to a function, the function will be called **once** during the shared/root
|
|
59
|
+
* query initialization, and be expected to synchronously return the initial data. Initial data is
|
|
60
|
+
* considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the
|
|
61
|
+
* cache.
|
|
62
|
+
*/
|
|
11
63
|
initialData: NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>) | undefined;
|
|
12
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.
|
|
67
|
+
* These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
|
|
68
|
+
* `options.queryKey` is required and is the query key to generate options for.
|
|
69
|
+
*
|
|
70
|
+
* This overload is selected when `initialData` is set.
|
|
71
|
+
*
|
|
72
|
+
* @see {@link useInfiniteQuery} to run an infinite query with these options.
|
|
73
|
+
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set.
|
|
74
|
+
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/preact-query'
|
|
79
|
+
*
|
|
80
|
+
* export const projectsOptions = infiniteQueryOptions({
|
|
81
|
+
* queryKey: ['projects'],
|
|
82
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
83
|
+
* initialPageParam: 0,
|
|
84
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
85
|
+
* initialData: { pages: [], pageParams: [] },
|
|
86
|
+
* })
|
|
87
|
+
*
|
|
88
|
+
* function Projects() {
|
|
89
|
+
* const { data } = useInfiniteQuery(projectsOptions)
|
|
90
|
+
* return <>{data.pages.map((page) => page.projects.map((p) => <p key={p.id}>{p.name}</p>))}</>
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
13
94
|
declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
|
|
95
|
+
/**
|
|
96
|
+
* You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.
|
|
97
|
+
* These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
|
|
98
|
+
* `options.queryKey` is required and is the query key to generate options for.
|
|
99
|
+
*
|
|
100
|
+
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```tsx
|
|
104
|
+
* import { infiniteQueryOptions } from '@tanstack/preact-query'
|
|
105
|
+
*
|
|
106
|
+
* export const projectsOptions = infiniteQueryOptions({
|
|
107
|
+
* queryKey: ['projects'],
|
|
108
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
109
|
+
* initialPageParam: 0,
|
|
110
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
111
|
+
* })
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* A parameterized factory, reused across a hook and an imperative call with the same cache entry:
|
|
116
|
+
* ```tsx
|
|
117
|
+
* import {
|
|
118
|
+
* infiniteQueryOptions,
|
|
119
|
+
* noop,
|
|
120
|
+
* useInfiniteQuery,
|
|
121
|
+
* } from '@tanstack/preact-query'
|
|
122
|
+
*
|
|
123
|
+
* export const commentsOptions = (postId: string) =>
|
|
124
|
+
* infiniteQueryOptions({
|
|
125
|
+
* queryKey: ['post', postId, 'comments'],
|
|
126
|
+
* queryFn: ({ pageParam }) => fetchComments(postId, pageParam),
|
|
127
|
+
* initialPageParam: 0,
|
|
128
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
129
|
+
* })
|
|
130
|
+
*
|
|
131
|
+
* function Comments({ postId }: { postId: string }) {
|
|
132
|
+
* const result = useInfiniteQuery(commentsOptions(postId))
|
|
133
|
+
* if (!result.isSuccess) return 'Loading...'
|
|
134
|
+
* return (
|
|
135
|
+
* <>
|
|
136
|
+
* {result.data.pages.map((page) => page.comments.map((c) => <p key={c.id}>{c.text}</p>))}
|
|
137
|
+
* </>
|
|
138
|
+
* )
|
|
139
|
+
* }
|
|
140
|
+
*
|
|
141
|
+
* // Elsewhere, e.g. to warm the cache before rendering `<Comments>`:
|
|
142
|
+
* queryClient.infiniteQuery(commentsOptions(postId)).catch(noop)
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @see {@link useInfiniteQuery} to run an infinite query with these options.
|
|
146
|
+
* @param options - The {@link UnusedSkipTokenInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.
|
|
147
|
+
*/
|
|
14
148
|
declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & QueryKeyWithDataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
|
|
149
|
+
/**
|
|
150
|
+
* You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`.
|
|
151
|
+
* These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
|
|
152
|
+
* `options.queryKey` is required and is the query key to generate options for.
|
|
153
|
+
*
|
|
154
|
+
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```tsx
|
|
158
|
+
* import { infiniteQueryOptions } from '@tanstack/preact-query'
|
|
159
|
+
*
|
|
160
|
+
* export const projectsOptions = infiniteQueryOptions({
|
|
161
|
+
* queryKey: ['projects'],
|
|
162
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
163
|
+
* initialPageParam: 0,
|
|
164
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
165
|
+
* })
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* A parameterized factory, reused across a hook and an imperative call with the same cache entry:
|
|
170
|
+
* ```tsx
|
|
171
|
+
* import {
|
|
172
|
+
* infiniteQueryOptions,
|
|
173
|
+
* noop,
|
|
174
|
+
* useInfiniteQuery,
|
|
175
|
+
* } from '@tanstack/preact-query'
|
|
176
|
+
*
|
|
177
|
+
* export const commentsOptions = (postId: string) =>
|
|
178
|
+
* infiniteQueryOptions({
|
|
179
|
+
* queryKey: ['post', postId, 'comments'],
|
|
180
|
+
* queryFn: ({ pageParam }) => fetchComments(postId, pageParam),
|
|
181
|
+
* initialPageParam: 0,
|
|
182
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
183
|
+
* })
|
|
184
|
+
*
|
|
185
|
+
* function Comments({ postId }: { postId: string }) {
|
|
186
|
+
* const result = useInfiniteQuery(commentsOptions(postId))
|
|
187
|
+
* if (!result.isSuccess) return 'Loading...'
|
|
188
|
+
* return (
|
|
189
|
+
* <>
|
|
190
|
+
* {result.data.pages.map((page) => page.comments.map((c) => <p key={c.id}>{c.text}</p>))}
|
|
191
|
+
* </>
|
|
192
|
+
* )
|
|
193
|
+
* }
|
|
194
|
+
*
|
|
195
|
+
* // Elsewhere, e.g. to warm the cache before rendering `<Comments>`:
|
|
196
|
+
* queryClient.infiniteQuery(commentsOptions(postId)).catch(noop)
|
|
197
|
+
* ```
|
|
198
|
+
*
|
|
199
|
+
* @see {@link useInfiniteQuery} to run an infinite query with these options.
|
|
200
|
+
* @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.
|
|
201
|
+
*/
|
|
15
202
|
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>;
|
|
16
203
|
//#endregion
|
|
17
204
|
export { DefinedInitialDataInfiniteOptions, UndefinedInitialDataInfiniteOptions, UnusedSkipTokenInfiniteOptions, infiniteQueryOptions };
|
|
@@ -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":";;;;;;;;;;;;;;KAwBY,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;;;;;;;;;;;;;;KAgBzC,+BACV,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,wBACE,UACF,wBAAwB,cAAc,QAAQ,OAAO,WAAW;;;;;EAOhE,UAAU,QACR,wBACE,cACA,QACA,OACA,WACA,wBAEF;;;;;;;;;;;;;KAeQ,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiC1C,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuD7C,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuD7C,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'\n\nimport type { UseInfiniteQueryOptions } from './types'\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 initialData?:\n | undefined\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | InitialDataFunction<\n NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n >\n}\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 queryFn?: Exclude<\n UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >['queryFn'],\n SkipToken | undefined\n >\n}\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 initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n | undefined\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\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\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":";AAgJA,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'\n\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 *\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 *\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, omit `queryFn` or use a default query function instead.\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`.\n *\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 *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\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 *\n * @example\n * ```tsx\n * import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/preact-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 * const { data } = useInfiniteQuery(projectsOptions)\n * return <>{data.pages.map((page) => page.projects.map((p) => <p key={p.id}>{p.name}</p>))}</>\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 *\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```tsx\n * import { infiniteQueryOptions } from '@tanstack/preact-query'\n *\n * export const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n * ```\n *\n * @example\n * A parameterized factory, reused across a hook and an imperative call with the same cache entry:\n * ```tsx\n * import {\n * infiniteQueryOptions,\n * noop,\n * useInfiniteQuery,\n * } from '@tanstack/preact-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 result = useInfiniteQuery(commentsOptions(postId))\n * if (!result.isSuccess) return 'Loading...'\n * return (\n * <>\n * {result.data.pages.map((page) => page.comments.map((c) => <p key={c.id}>{c.text}</p>))}\n * </>\n * )\n * }\n *\n * // Elsewhere, e.g. to warm the cache before rendering `<Comments>`:\n * queryClient.infiniteQuery(commentsOptions(postId)).catch(noop)\n * ```\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UnusedSkipTokenInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\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 *\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n *\n * @example\n * ```tsx\n * import { infiniteQueryOptions } from '@tanstack/preact-query'\n *\n * export const projectsOptions = infiniteQueryOptions({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n * ```\n *\n * @example\n * A parameterized factory, reused across a hook and an imperative call with the same cache entry:\n * ```tsx\n * import {\n * infiniteQueryOptions,\n * noop,\n * useInfiniteQuery,\n * } from '@tanstack/preact-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 result = useInfiniteQuery(commentsOptions(postId))\n * if (!result.isSuccess) return 'Loading...'\n * return (\n * <>\n * {result.data.pages.map((page) => page.comments.map((c) => <p key={c.id}>{c.text}</p>))}\n * </>\n * )\n * }\n *\n * // Elsewhere, e.g. to warm the cache before rendering `<Comments>`:\n * queryClient.infiniteQuery(commentsOptions(postId)).catch(noop)\n * ```\n *\n * @see {@link useInfiniteQuery} to run an infinite query with these options.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`.\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":";AA2UA,SAAgB,qBAAqB,SAAkB;CACrD,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutationOptions.cjs","names":[],"sources":["../../src/mutationOptions.ts"],"sourcesContent":["import type { DefaultError, WithRequired } from '@tanstack/query-core'\n\nimport type { UseMutationOptions } from './types'\n\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: WithRequired<\n UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n): WithRequired<\n UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n>\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: Omit<\n UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n): Omit<\n UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n>\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n): UseMutationOptions<TData, TError, TVariables, TOnMutateResult> {\n return options\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"mutationOptions.cjs","names":[],"sources":["../../src/mutationOptions.ts"],"sourcesContent":["import type { DefaultError, WithRequired } from '@tanstack/query-core'\n\nimport type { UseMutationOptions } from './types'\n\n/**\n * You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A\n * `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with\n * `useMutationState`.\n *\n * @see {@link useMutation} to run the mutation these options describe.\n * @param options - The mutation options to use, identical to what you'd pass to `useMutation`, with a\n * required `mutationKey`.\n * @returns The same options object, unchanged.\n *\n * @example\n * ```tsx\n * import { mutationOptions, useMutation } from '@tanstack/preact-query'\n *\n * export const createPostOptions = mutationOptions({\n * mutationKey: ['posts', 'create'],\n * mutationFn: createPost,\n * })\n *\n * function CreatePost() {\n * const mutation = useMutation(createPostOptions)\n * return <button onClick={() => mutation.mutate({ title: 'Hello' })}>Create</button>\n * }\n * ```\n *\n * @example\n * Looking the mutation up elsewhere via its `mutationKey`, e.g. for a global \"saving…\" indicator:\n * ```tsx\n * import { mutationOptions, useMutationState } from '@tanstack/preact-query'\n *\n * const createPostOptions = mutationOptions({\n * mutationKey: ['posts', 'create'],\n * mutationFn: createPost,\n * })\n *\n * function SavingIndicator() {\n * const isCreatingPost = useMutationState({\n * filters: { mutationKey: createPostOptions.mutationKey, status: 'pending' },\n * }).length > 0\n *\n * return isCreatingPost ? <span>Saving…</span> : null\n * }\n * ```\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: WithRequired<\n UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n): WithRequired<\n UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n>\n/**\n * You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. No\n * `mutationKey` is required on this overload — use this when you don't need to look the mutation up later\n * (e.g. with `useMutationState`).\n *\n * @see {@link useMutation} to run the mutation these options describe.\n * @param options - The mutation options to use, identical to what you'd pass to `useMutation`, without a\n * `mutationKey`.\n * @returns The same options object, unchanged.\n *\n * @example\n * ```tsx\n * import { mutationOptions, useMutation } from '@tanstack/preact-query'\n *\n * export const createPostOptions = mutationOptions({\n * mutationFn: createPost,\n * })\n *\n * function CreatePost() {\n * const mutation = useMutation(createPostOptions)\n * return <button onClick={() => mutation.mutate({ title: 'Hello' })}>Create</button>\n * }\n * ```\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: Omit<\n UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n >,\n): Omit<\n UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n 'mutationKey'\n>\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n): UseMutationOptions<TData, TError, TVariables, TOnMutateResult> {\n return options\n}\n"],"mappings":";;AAoGA,SAAgB,gBAMd,SACgE;CAChE,OAAO;AACT"}
|
|
@@ -1,7 +1,75 @@
|
|
|
1
1
|
import { UseMutationOptions } from "./types.cjs";
|
|
2
2
|
import { DefaultError, WithRequired } from "@tanstack/query-core";
|
|
3
3
|
//#region src/mutationOptions.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A
|
|
6
|
+
* `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with
|
|
7
|
+
* `useMutationState`.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link useMutation} to run the mutation these options describe.
|
|
10
|
+
* @param options - The mutation options to use, identical to what you'd pass to `useMutation`, with a
|
|
11
|
+
* required `mutationKey`.
|
|
12
|
+
* @returns The same options object, unchanged.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { mutationOptions, useMutation } from '@tanstack/preact-query'
|
|
17
|
+
*
|
|
18
|
+
* export const createPostOptions = mutationOptions({
|
|
19
|
+
* mutationKey: ['posts', 'create'],
|
|
20
|
+
* mutationFn: createPost,
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* function CreatePost() {
|
|
24
|
+
* const mutation = useMutation(createPostOptions)
|
|
25
|
+
* return <button onClick={() => mutation.mutate({ title: 'Hello' })}>Create</button>
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* Looking the mutation up elsewhere via its `mutationKey`, e.g. for a global "saving…" indicator:
|
|
31
|
+
* ```tsx
|
|
32
|
+
* import { mutationOptions, useMutationState } from '@tanstack/preact-query'
|
|
33
|
+
*
|
|
34
|
+
* const createPostOptions = mutationOptions({
|
|
35
|
+
* mutationKey: ['posts', 'create'],
|
|
36
|
+
* mutationFn: createPost,
|
|
37
|
+
* })
|
|
38
|
+
*
|
|
39
|
+
* function SavingIndicator() {
|
|
40
|
+
* const isCreatingPost = useMutationState({
|
|
41
|
+
* filters: { mutationKey: createPostOptions.mutationKey, status: 'pending' },
|
|
42
|
+
* }).length > 0
|
|
43
|
+
*
|
|
44
|
+
* return isCreatingPost ? <span>Saving…</span> : null
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
4
48
|
declare function mutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>(options: WithRequired<UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>): WithRequired<UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>;
|
|
49
|
+
/**
|
|
50
|
+
* You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. No
|
|
51
|
+
* `mutationKey` is required on this overload — use this when you don't need to look the mutation up later
|
|
52
|
+
* (e.g. with `useMutationState`).
|
|
53
|
+
*
|
|
54
|
+
* @see {@link useMutation} to run the mutation these options describe.
|
|
55
|
+
* @param options - The mutation options to use, identical to what you'd pass to `useMutation`, without a
|
|
56
|
+
* `mutationKey`.
|
|
57
|
+
* @returns The same options object, unchanged.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* import { mutationOptions, useMutation } from '@tanstack/preact-query'
|
|
62
|
+
*
|
|
63
|
+
* export const createPostOptions = mutationOptions({
|
|
64
|
+
* mutationFn: createPost,
|
|
65
|
+
* })
|
|
66
|
+
*
|
|
67
|
+
* function CreatePost() {
|
|
68
|
+
* const mutation = useMutation(createPostOptions)
|
|
69
|
+
* return <button onClick={() => mutation.mutate({ title: 'Hello' })}>Create</button>
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
5
73
|
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'>;
|
|
6
74
|
//#endregion
|
|
7
75
|
export { mutationOptions };
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgDgB,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,aACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,aACD,mBAAmB,OAAO,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;iBA2BhC,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,KACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,KACD,mBAAmB,OAAO,QAAQ,YAAY"}
|
|
@@ -1,7 +1,75 @@
|
|
|
1
1
|
import { UseMutationOptions } from "./types.js";
|
|
2
2
|
import { DefaultError, WithRequired } from "@tanstack/query-core";
|
|
3
3
|
//#region src/mutationOptions.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A
|
|
6
|
+
* `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with
|
|
7
|
+
* `useMutationState`.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link useMutation} to run the mutation these options describe.
|
|
10
|
+
* @param options - The mutation options to use, identical to what you'd pass to `useMutation`, with a
|
|
11
|
+
* required `mutationKey`.
|
|
12
|
+
* @returns The same options object, unchanged.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { mutationOptions, useMutation } from '@tanstack/preact-query'
|
|
17
|
+
*
|
|
18
|
+
* export const createPostOptions = mutationOptions({
|
|
19
|
+
* mutationKey: ['posts', 'create'],
|
|
20
|
+
* mutationFn: createPost,
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* function CreatePost() {
|
|
24
|
+
* const mutation = useMutation(createPostOptions)
|
|
25
|
+
* return <button onClick={() => mutation.mutate({ title: 'Hello' })}>Create</button>
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* Looking the mutation up elsewhere via its `mutationKey`, e.g. for a global "saving…" indicator:
|
|
31
|
+
* ```tsx
|
|
32
|
+
* import { mutationOptions, useMutationState } from '@tanstack/preact-query'
|
|
33
|
+
*
|
|
34
|
+
* const createPostOptions = mutationOptions({
|
|
35
|
+
* mutationKey: ['posts', 'create'],
|
|
36
|
+
* mutationFn: createPost,
|
|
37
|
+
* })
|
|
38
|
+
*
|
|
39
|
+
* function SavingIndicator() {
|
|
40
|
+
* const isCreatingPost = useMutationState({
|
|
41
|
+
* filters: { mutationKey: createPostOptions.mutationKey, status: 'pending' },
|
|
42
|
+
* }).length > 0
|
|
43
|
+
*
|
|
44
|
+
* return isCreatingPost ? <span>Saving…</span> : null
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
4
48
|
declare function mutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>(options: WithRequired<UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>): WithRequired<UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>;
|
|
49
|
+
/**
|
|
50
|
+
* You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. No
|
|
51
|
+
* `mutationKey` is required on this overload — use this when you don't need to look the mutation up later
|
|
52
|
+
* (e.g. with `useMutationState`).
|
|
53
|
+
*
|
|
54
|
+
* @see {@link useMutation} to run the mutation these options describe.
|
|
55
|
+
* @param options - The mutation options to use, identical to what you'd pass to `useMutation`, without a
|
|
56
|
+
* `mutationKey`.
|
|
57
|
+
* @returns The same options object, unchanged.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* import { mutationOptions, useMutation } from '@tanstack/preact-query'
|
|
62
|
+
*
|
|
63
|
+
* export const createPostOptions = mutationOptions({
|
|
64
|
+
* mutationFn: createPost,
|
|
65
|
+
* })
|
|
66
|
+
*
|
|
67
|
+
* function CreatePost() {
|
|
68
|
+
* const mutation = useMutation(createPostOptions)
|
|
69
|
+
* return <button onClick={() => mutation.mutate({ title: 'Hello' })}>Create</button>
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
5
73
|
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'>;
|
|
6
74
|
//#endregion
|
|
7
75
|
export { mutationOptions };
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgDgB,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,aACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,aACD,mBAAmB,OAAO,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;iBA2BhC,gBACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,KACP,mBAAmB,OAAO,QAAQ,YAAY,mCAG/C,KACD,mBAAmB,OAAO,QAAQ,YAAY"}
|