Skip to main content
Version: 2.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
)

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

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',
},
}
);

expect(numberOfFetchingEntities).toEqual(1);