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

isFetching(...)

This method returns an integer representing how many queries, if any, in the cache are currently fetching. Refer to the TanStack queryClient.isFetching ๐ŸŒด guide for more information.

Checks if any queries are fetching with the specified parameters.

qraft.<service>.<operation>.isFetching(
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
    • 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 checked

Returnsโ€‹

number: Number of queries fetching.

Examplesโ€‹

Check if any queries are fetching with the specified parameters:

/**
* Will check if the query with the specified parameters is fetching:
* ###
* GET /entities/3e3e-3e3e-3e3e
* x-monite-version: 2023-09-01
**/
const numberOfFetchingEntities = qraft.entities.getEntities.isFetching(
{
infinite: false,
parameters: {
header: {
'x-monite-version': '2023-09-01',
},
path: {
entity_id: '3e3e-3e3e-3e3e',
},
},
}
);

expect(numberOfFetchingEntities).toEqual(1);