Open History to see the last commit
1---
2id: MutationCacheConfig
3title: MutationCacheConfig
4---
5β
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7β
8Defined in: [packages/query-core/src/mutationCache.ts:26](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L26)
9β
10Global callbacks that fire for every mutation handled by a `MutationCache`, regardless of which
11component or observer triggered it. They differ from the `defaultOptions` provided to a
12`QueryClient` in two ways: `defaultOptions` can be overridden by each mutation, while these
13callbacks are always called, and `onMutate` here does not allow returning a result.
14β
15If a callback returns a promise, it will be awaited before the mutation continues.
16β
17## Properties
18β
19| Property | Type | Description |
20| ------ | ------ | ------ |
21| <a id="property-onerror"></a> `onError?` | (`error`: `Error`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache encounters an error. |
22| <a id="property-onmutate"></a> `onMutate?` | (`variables`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called before any mutation in the cache executes. |
23| <a id="property-onsettled"></a> `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is settled, either successfully or with an error. |
24| <a id="property-onsuccess"></a> `onSuccess?` | (`data`: `unknown`, `variables`: `unknown`, `onMutateResult`: `unknown`, `mutation`: [`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\>, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | Called when any mutation in the cache is successful. |