Open History to see the last commit
1import type {
2 DataTag,
3 DefaultError,
4 InfiniteData,
5 InfiniteQueryMode,
6 InfiniteQueryObserverOptions,
7 QueryKey,
8} from '@tanstack/query-core'
9β
10/**
11 * Brands infinite query options so the `queryKey` carries the infinite query
12 * data and error types across TanStack Query APIs.
13 * @param options - Infinite query options to preserve and brand.
14 * @returns The same options object with a typed `queryKey`.
15 * @example
16 * ```ts
17 * import { infiniteQueryOptions } from '@tanstack/lit-query'
18 *
19 * const projectsOptions = infiniteQueryOptions({
20 * queryKey: ['projects'],
21 * queryFn: ({ pageParam }) => fetchProjects(pageParam),
22 * initialPageParam: 0,
23 * getNextPageParam: (lastPage) => lastPage.nextCursor,
24 * })
25 * ```
26 */
27export function infiniteQueryOptions<
28 TQueryFnData = unknown,
29 TError = DefaultError,
30 TData = InfiniteData<TQueryFnData>,
31 TQueryKey extends QueryKey = QueryKey,
32 TPageParam = unknown,
33>(
34 options: InfiniteQueryObserverOptions<
35 TQueryFnData,
36 TError,
37 TData,
38 TQueryKey,
39 TPageParam,
40 undefined
41 >,
42): InfiniteQueryObserverOptions<
43 TQueryFnData,
44 TError,
45 TData,
46 TQueryKey,
47 TPageParam,
48 undefined
49> & {
50 queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
51}
52export function infiniteQueryOptions<
53 TQueryFnData = unknown,
54 TError = DefaultError,
55 TData = InfiniteData<TQueryFnData>,
56 TQueryKey extends QueryKey = QueryKey,
57 TPageParam = unknown,
58>(
59 options: InfiniteQueryObserverOptions<
60 TQueryFnData,
61 TError,
62 TData,
63 TQueryKey,
64 TPageParam,
65 InfiniteQueryMode
66 >,
67): InfiniteQueryObserverOptions<
68 TQueryFnData,
69 TError,
70 TData,
71 TQueryKey,
72 TPageParam,
73 InfiniteQueryMode
74> & {
75 queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
76}
77β
78export function infiniteQueryOptions(options: unknown) {
79 return options
80}