getInfiniteQueryData(...)
The method enables direct access to the QueryClient
cache to retrieve the data for a specific InfiniteQuery.
See the TanStack queryClient.getQueryData ๐ด documentation.
const data = api.<service>.<operation>.getInfiniteQueryData(parameters);
Argumentsโ
parameters: { path, query, header } | QueryKey | void
- Required parameters to retrieve the data from the cache.
- Instead of an object with
{ path, query, header }
, you can pass aQueryKey
as an array which is also strictly-typed โจ
Returnsโ
The data from the Query Cache for the specific query, strictly-typed โจ
Exampleโ
import { createAPIClient } from './api'; // generated by OpenAPI Qraft CLI
import { requestFn } from '@openapi-qraft/react';
import { QueryClient } from '@tanstack/react-query';
const api = createAPIClient({
requestFn,
queryClient: new QueryClient(),
baseUrl: 'https://api.sandbox.monite.com/v1',
});
const fileListPages = api.files.getFiles.getInfiniteQueryData();
expect(fileListPages).toEqual({
pageParams: [
{ page: 1 },
{ page: 2 },
],
pages: [
[file1, file2],
[file3, file4]
],
});