Skip to content

Latest commit

 

History

History
46 lines (39 loc) · 2.3 KB

File metadata and controls

46 lines (39 loc) · 2.3 KB
sidebar_label ensureInfiniteQueryData()

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, body } | InfiniteQueryKey | void
    • OpenAPI request parameters for the query, strictly-typed ✨
    • parameters will be used to generate the Infinite Query Key
    • For operations generated with --queryable-write-operations, query parameters may also include body
    • In that mode, body is part of the infinite query key and cache identity
    • Mutation calls keep body as a separate top-level argument
    • fetchInfiniteQueryOptions?: FetchInfiniteQueryOptions
      • requestFn?: 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 queryFn is not set previously using QueryClient.setDefaultOptions(...) method
      • baseUrl?: string
        • Optional, the base URL of the API
      • revalidateIfStale?: boolean
        • Optional, defaults to false. If true, stale data will be revalidated in the background while returning cached data immediately.
      • ...fetchInfiniteQueryOptions?: FetchInfiniteQueryOptions
      • Optional, represents the rest options of the fetchInfiniteQuery(...) 🌴 method
        • queryOptions.queryFn could be provided instead of requestFn
        • queryOptions.queryKey could be provided instead of parameters

Returns

Promise<InfiniteData<T>> - A promise of the paginated data and page parameters