ensureInfiniteQueryData(...)
The ensureInfiniteQueryData method is designed to fetch or retrieve cached data for an infinite query.
If the specified query data is not already cached, it will automatically call fetchInfiniteQuery
to fetch the data and return the result.
To understand how ensureInfiniteQueryData manages infinite queries, refer to the TanStack
queryClient.ensureInfiniteQueryData ๐ด documentation.
const result = api.<service>.<operation>.ensureInfiniteQueryData({
parameters,
requestFn,
baseUrl,
revalidateIfStale: false,
...fetchInfiniteQueryOptions,
});
Argumentsโ
-
parameters: { path, query, header } | QueryKey | void- OpenAPI request parameters for the query, strictly-typed โจ
parameterswill be used to generate theQueryKey
fetchInfiniteQueryOptions?: FetchInfiniteQueryOptionsrequestFn?: RequestFn- Optional, a function that will be used to execute the request
- The function should be provided, otherwise it will throw an error if default
queryFnis not set previously usingQueryClient.setDefaultOptions(...)method
baseUrl?: string- Optional, the base URL of the API
revalidateIfStale?: boolean- Optional, defaults to
false. Iftrue, stale data will be revalidated in the background while returning cached data immediately.
- Optional, defaults to
...fetchInfiniteQueryOptions?: FetchInfiniteQueryOptions- Optional, represents the rest options of the fetchInfiniteQuery(...) ๐ด method
queryOptions.queryFncould be provided instead ofrequestFnqueryOptions.queryKeycould be provided instead ofparameters
Returnsโ
Promise<InfiniteData<T>> - A promise of the paginated data and page parameters