Open History to see the last commit
1---
2id: matchMutation
3title: matchMutation
4---
5β
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7β
8```ts
9function matchMutation(filters: MutationFilters, mutation: Mutation<any, any>): boolean;
10```
11β
12Defined in: [packages/query-core/src/utils.ts:269](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L269)
13β
14Checks whether a mutation matches the given [MutationFilters](../interfaces/MutationFilters.md).
15Every filter that is specified must match; filters that are left unspecified are ignored.
16If a `mutationKey` filter is provided but the mutation has no `mutationKey` of its own, it does not match.
17β
18## Parameters
19β
20### filters
21β
22[`MutationFilters`](../interfaces/MutationFilters.md)
23β
24The filters to check the mutation against.
25β
26<a id="filters-properties"></a>
27β
28#### `filters` properties
29β
30| Property | Type | Description |
31| ------ | ------ | ------ |
32| <a id="filters-property-exact"></a> `exact?` | `boolean` | Match mutation key exactly |
33| <a id="filters-property-mutationkey"></a> `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key |
34| <a id="filters-property-predicate"></a> `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function |
35| <a id="filters-property-status"></a> `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status |
36β
37### mutation
38β
39[`Mutation`](../classes/Mutation.md)\<`any`, `any`\>
40β
41The mutation to check.
42β
43## Returns
44β
45`boolean`
46β
47`true` if the mutation matches every specified filter.
48β
49## Example
50β
51```ts
52const mutationCache = queryClient.getMutationCache()
53β
54const matchingMutations = mutationCache
55 .getAll()
56 .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation))
57```