Skip to main content
Version: 1.x

getQueryKey(...)

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

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

Argumentsโ€‹

    • parameters: { path, query, header } | undefined
      • Optional, OpenAPI request parameters for the query, strictly-typed โœจ
      • parameters will be used to generate the QueryKey
      • If not specified, returns a QueryKey with {} as a Query parameters

Returnsโ€‹

QueryKey - a query key for the operation parameters

Exampleโ€‹

const queryKey = qraft.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' },
{
header: { 'x-monite-version': '1.0.0' },
query: { id__in: ['1', '2'] }
}
]);