0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-16 22:50:20 +00:00
query/docs/framework/angular/reference/functions/matchMutation.md

1.1 KiB

id title
matchMutation matchMutation
function matchMutation(filters: MutationFilters, mutation: Mutation<any, any>): boolean;

Defined in: packages/query-core/src/utils.ts:269

Checks whether a mutation matches the given MutationFilters. Every filter that is specified must match; filters that are left unspecified are ignored. If a mutationKey filter is provided but the mutation has no mutationKey of its own, it does not match.

Parameters

filters

MutationFilters

The filters to check the mutation against.

mutation

Mutation<any, any>

The mutation to check.

Returns

boolean

true if the mutation matches every specified filter.

Example

const mutationCache = queryClient.getMutationCache()

const matchingMutations = mutationCache
  .getAll()
  .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation))