Skip to main content
Version: 1.x

isMutating(...)

This method returns an integer representing how many mutations are currently in the loading state. Refer to the TanStack queryClient.isMutating ๐ŸŒด guide for more information.

Checks if any mutations are fetching with the specified filters.

const mutationNumber = qraft.<service>.<operation>.isMutating(
filters,
queryClient,
)

Argumentsโ€‹

  1. filters: UseMutationStateFiltersByParameters | UseMutationStateFiltersByMutationKey,
    • Required, represents the Mutation Filters ๐ŸŒด to be used, strictly-typed โœจ
    • filters.parameters: { path, query, header } will be used for filtering mutations by parameters
    • filters.mutationKey: MutationKey will be used for filtering mutations by MutationKey instead of parameters
      • filters.mutationKey and filters.parameters are mutually exclusive
    • filters.predicate?: (mutation: Mutation) => boolean will be used for filtering mutations by custom predicate
  2. queryClient?: QueryClient

Returnsโ€‹

mutationsNumber: The number of mutations that are matching the provided filters and are in the loading state

Examplesโ€‹

Check if any mutations are pending with the specified parameters:

/**
* Checks if the mutation with the specified parameters is fetching:
* ###
* POST /entities/3e3e-3e3e-3e3e
* x-monite-version: 2023-09-01
**/
const numberOfFetchingEntities = qraft.entities.postEntities.isMutating(
{
header: {
'x-monite-version': '2023-09-01',
},
path: {
entity_id: '3e3e-3e3e-3e3e',
},
},
queryClient
);

expect(numberOfFetchingEntities).toEqual(1);