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

cancelQueries(...)

The method can be used to cancel outgoing queries. Refer to the TanStack queryClient.cancelQueries ๐ŸŒด and Query Cancellation ๐ŸŒด guide for more information.

Cancels queries for the specified endpoint using the provided filters.

api.<service>.<operation>.cancelQueries(filters)

Argumentsโ€‹

  1. filters: QueryFiltersByParameters | QueryFiltersByQueryKey
    • Required, represents the Query Filters ๐ŸŒด to be used, strictly-typed โœจ
    • filters.parameters: { path, query, header } will be used for filtering queries by parameters
    • filters.infinite?: boolean will be used to filter infinite or normal queries, Required if predicate is provided
    • filters.queryKey?: QueryKey will be used for filtering queries by QueryKey instead of parameters
      • filters.queryKey and filters.parameters are mutually exclusive
    • filters.predicate?: (query: Query) => boolean will be used for filtering queries by custom predicate
    • If not provided
      • All queries for the specified endpoint will be canceled

Returnsโ€‹

Promise<void>: A promise that resolves once the cancellation is complete.

Examplesโ€‹

Queries cancellation with the specified parameters:

import { createAPIClient } from './api'; // generated by OpenAPI Qraft CLI
import { requestFn } from '@openapi-qraft/react';

const queryClient = new QueryClient();

const api = createAPIClient({
requestFn,
queryClient,
baseUrl: 'https://api.sandbox.monite.com/v1',
});

/**
* Will cancel the active queries with the specified parameters:
* ###
* GET /entities/3e3e-3e3e-3e3e
* x-monite-version: 2023-09-01
**/
api.entities.getEntities.cancelQueries(
{
infinite: false,
parameters: {
header: {
'x-monite-version': '2023-09-01',
},
path: {
entity_id: '3e3e-3e3e-3e3e',
},
}
}
);