API/qubeeQueryOptions()
qubeeQueryOptions()
functionsrc/utils/qubee-query-options.ts2 parameters
The TanStack Query options that fetch the page a request asks for.
It returns what TanStack’s own queryOptions() returns, with two things set: the queryKey —
['qubee', uri, headers] — and a queryFn that calls fetchQubeePage with TanStack’s
abort signal. Everything else is yours to add, so the object works with useQuery,
useSuspenseQuery, useQueries, prefetchQuery and ensureQueryData.
It is a plain function that also runs outside React — in a loader, on the server — so it takes
the fetcher as an argument and does not read QubeeFetchProvider.
Import
Section titled “Import”import { qubeeQueryOptions } from '@qubeejs/react/tanstack-query';Signature
Section titled “Signature”function qubeeQueryOptions<T extends object>(request: ListRequest, options?: { … }): OmitKeyof<UseQueryOptions<PaginatedResult<T>, Error, PaginatedResult<T>, QubeeQueryKey>, 'queryFn'> & { … } & { … }function qubeeQueryOptions<T extends object>(request: ListRequest | null, options?: { … }): UseQueryOptions<PaginatedResult<T>, Error, PaginatedResult<T>, QubeeQueryKey> & { … } & { … }Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
request |
ListRequest |
The page to fetch: list.request, or core’s buildListRequest() |
options |
{ … } |
fetcher: what performs the request, the global fetch by default |
Returns
Section titled “Returns”The options, typed so that data is core’s PaginatedResult<T>
Example
Section titled “Example”const list = useQubeeList(articleList);const articles = useQuery({ ...qubeeQueryOptions<Article>(list.request), placeholderData: keepPreviousData,});