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/interfaces/CreateMutationOptions.md
Wonsuk Choi 992c94234c
docs(query-core): inline option type aliases in generated reference docs (#11534)
* docs(query-core): inline option type aliases in generated reference docs

* docs(query-core): inline retry, notify and remaining option aliases
2026-09-18 17:08:56 +09:00

4.3 KiB

id title
CreateMutationOptions CreateMutationOptions

Defined in: packages/angular-query-experimental/src/types.ts:224

The options accepted by injectMutation. Same as MutationObserverOptions from @tanstack/query-core, minus the internal _defaulted flag.

Extends

Type Parameters

TData

TData = unknown

The type your mutation function resolves to.

TError

TError = DefaultError

The type of errors your mutation function may throw.

TVariables

TVariables = void

The type of the variable passed to mutate/mutateAsync.

TOnMutateResult

TOnMutateResult = unknown

The type returned by onMutate, passed to onSuccess/onError/onSettled as their onMutateResult parameter — useful for optimistic-update rollback data.

Properties

Property Type Description
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.
meta? Record<string, unknown> -
mutationFn? (variables: TVariables, context: MutationFunctionContext) => Promise<TData> -
mutationKey? readonly unknown[] -
networkMode? "online" | "always" | "offlineFirst" Controls whether a mutation is allowed to run based on the current network connectivity. Defaults to 'online'. See Network Mode for more information.
onError? (error: TError, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => unknown -
onMutate? (variables: TVariables, context: MutationFunctionContext) => TOnMutateResult | Promise<TOnMutateResult> -
onSettled? (data: TData | undefined, error: TError | null, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => unknown -
onSuccess? (data: TData, variables: TVariables, onMutateResult: TOnMutateResult, context: MutationFunctionContext) => unknown -
retry? | number | false | true | (failureCount: number, error: TError) => boolean 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.
retryDelay? number | (failureCount: number, error: TError) => number 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.
scope? MutationScope -
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.