Skip to content
0

katanakit-js / MutationOptions

Interface: MutationOptions<TData, TError, TVariables, TOnMutateResult> ​

Defined in: node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2567

Extended by ​

Type Parameters ​

Type ParameterDefault type
TDataunknown
TErrorDefaultError
TVariablesvoid
TOnMutateResultunknown

Properties ​

PropertyTypeDefault valueDescriptionDefined in
gcTime?numberundefinedThe 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.node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2636
meta?Record<string, unknown>undefinedAdditional payload to be stored on the mutation cache entry. Use it to pass information that can be read wherever the mutation is available, such as the onError and onSuccess callbacks of the MutationCache.node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2644
mutationFn?(variables, context) => Promise<TData>undefinedThe function that performs the asynchronous task this mutation runs. Required, unless a default mutation function has been set for the matching mutationKey via queryClient.setMutationDefaults. Receives the variables passed to mutate, and a MutationFunctionContext holding the QueryClient, the mutationKey and meta. Must return a promise that resolves the mutation's data.node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2576
mutationKey?readonly unknown[]undefinedThe key to use for this mutation. Optional, but required to inherit defaults registered with queryClient.setMutationDefaults, and to match this mutation with useMutationState or queryClient.isMutating.node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2582
networkMode?"always" | "online" | "offlineFirst"'online'Controls whether a mutation is allowed to run based on the current network connectivity. See Network Mode for more information.node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2629
onError?(error, variables, onMutateResult, context) => unknownundefinedThis function fires when the mutation encounters an error, and is passed the error. If a promise is returned, it is awaited before onSettled runs.node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2600
onMutate?(variables, context) => TOnMutateResult | Promise<TOnMutateResult>undefinedThis function fires before the mutation function runs, and receives the same variables. Useful for optimistic updates applied in the hope that the mutation succeeds. The value it returns is passed to onSuccess, onError and onSettled as onMutateResult, which is where an optimistic update is usually rolled back. If a promise is returned, it is awaited before the mutation function runs.node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2590
onSettled?(data, error, variables, onMutateResult, context) => unknownundefinedThis function fires when the mutation either succeeds or errors, and is passed either the data or the error. If a promise is returned, it is awaited before the mutation settles.node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2606
onSuccess?(data, variables, onMutateResult, context) => unknownundefinedThis function fires when the mutation succeeds, and is passed the mutation's result. If a promise is returned, it is awaited before onSettled runs.node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2595
retry?number | false | true | ((failureCount, error) => boolean)0If 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.node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2615
retryDelay?number | ((failureCount, error) => number)undefinedThis 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.node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2622
scope?MutationScopeundefinedControls whether this mutation runs alongside others or waits its turn. Mutations sharing the same scope.id run serially, in the order they were started. Without a scope, a mutation runs as soon as it is triggered.node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2650

Released under the MIT License.