Open History to see the last commit
1---
2id: MutationObserverOptions
3title: MutationObserverOptions
4---
5β
6Defined in: packages/query-core/dist-ts/src/types.d.ts:788
7β
8## Extends
9β
10- [`MutationOptions`](MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>
11β
12## Type Parameters
13β
14### TData
15β
16`TData` = `unknown`
17β
18### TError
19β
20`TError` = [`DefaultError`](../type-aliases/DefaultError.md)
21β
22### TVariables
23β
24`TVariables` = `void`
25β
26### TOnMutateResult
27β
28`TOnMutateResult` = `unknown`
29β
30## Properties
31β
32| Property | Type | Description |
33| ------ | ------ | ------ |
34| <a id="gctime"></a> `gcTime?` | `number` | The time in milliseconds that an unused/inactive mutation remains in memory before it is garbage collected. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. |
35| <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> | - |
36| <a id="mutationfn"></a> `mutationFn?` | [`MutationFunction`](../type-aliases/MutationFunction.md)\<`TData`, `TVariables`\> | - |
37| <a id="mutationkey"></a> `mutationKey?` | readonly `unknown`[] | - |
38| <a id="networkmode"></a> `networkMode?` | [`NetworkMode`](../type-aliases/NetworkMode.md) | Controls whether a mutation is allowed to run based on the current network connectivity. Defaults to `'online'`. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. |
39| <a id="onerror"></a> `onError?` | (`error`: `TError`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | - |
40| <a id="onmutate"></a> `onMutate?` | (`variables`: `TVariables`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> | - |
41| <a id="onsettled"></a> `onSettled?` | (`data`: `TData` \| `undefined`, `error`: `TError` \| `null`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult` \| `undefined`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | - |
42| <a id="onsuccess"></a> `onSuccess?` | (`data`: `TData`, `variables`: `TVariables`, `onMutateResult`: `TOnMutateResult`, `context`: [`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md)) => `unknown` | - |
43| <a id="retry"></a> `retry?` | `RetryValue`\<`TError`\> | If `false`, failed mutations will not retry by default. If `true`, failed mutations will retry infinitely. If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. Defaults to `0`. |
44| <a id="retrydelay"></a> `retryDelay?` | `RetryDelayValue`\<`TError`\> | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. Defaults to a function that applies exponential backoff, capped at 30 seconds. |
45| <a id="scope"></a> `scope?` | [`MutationScope`](../type-aliases/MutationScope.md) | - |
46| <a id="throwonerror"></a> `throwOnError?` | `boolean` \| (`error`: `TError`) => `boolean` | Whether errors should be thrown instead of setting the `error` property. If set to `true`, all errors will be thrown to the nearest error boundary. If set to a function, it will be passed the error and should return a boolean indicating whether to throw the error (`true`) or return it as state (`false`). Defaults to `false`. |