Skip to main content
Version: 2.x ๐Ÿšง

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โ€‹

  1. 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 a QueryKey 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]
],
});