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 theQueryKey
- If not specified, returns a
QueryKey
with{}
as a Query parameters
Returnsโ
QueryKey
- a query key for the operation parameters
Exampleโ
- With
parameters
- Without
parameters
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'] }
}
]);
const queryKey = qraft.files.getFiles.getQueryKey();
// `queryKey` will be an array of objects
expect(queryKey).toEqual([
{ method: 'get', url: '/files' },
{}
]);