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

getQueryKey(...)

The method provides a standardized way to generate QueryKey for Queries. See TanStack Query Keys ๐ŸŒด guide for more information.

const queryKey = api.<service>.<operation>.getQueryKey(parameters);

Argumentsโ€‹

    • parameters: { path, query, header } | void
      • Optional, OpenAPI request parameters for the query, strictly-typed โœจ
      • parameters will be used to generate the QueryKey

Returnsโ€‹

QueryKey - a query key for the operation parameters

Exampleโ€‹

const queryKey = api.files.getFiles.getQueryKey({
header: { 'x-monite-version': '1.0.0' },
query: { id__in: ['1', '2'] },
});

// `queryKey` will be an array of objects
expect(queryKey).toEqual([
{ method: 'get', url: '/files', infinite: false, },
{
header: { 'x-monite-version': '1.0.0' },
query: { id__in: ['1', '2'] }
}
]);