MutationDefaults class Client
Mutation options that apply to many mutations at once: client-wide through DefaultOptions.mutations, or per mutation-key prefix through QueryClient.setMutationDefaults.
Every field is optional; a mutation's own options win field by field,
then key defaults, then client-wide defaults, then the built-in default
named on each field. Callbacks (onMutate, onSuccess, …) have no
default here: they belong to a mutation's own options, or to the
MutationCache for app-wide handling.
client.setMutationDefaults(
QueryKey(['addTask']),
MutationDefaults(
mutationFn: (variables) => api.addTask(variables! as String),
retry: const RetryPolicy.times(2),
),
);
- Annotations
-
- @immutable
Constructors
-
MutationDefaults({MutationFn<
Object?, Object?> ? mutationFn, RetryPolicy? retry, RetryDelay? retryDelay, NetworkMode? networkMode, GcTime? gcTime, MutationScope? scope, Object? meta}) -
Creates a set of defaults; every field is optional, and an unset one
defers to the next layer down.
const
Properties
- gcTime → GcTime?
-
Default for
gcTime: how long a settled, unobserved mutation stays in the cache. Built-in: GcTime.defaultValue, five minutes.final - hashCode → int
-
The hash code for this object.
no setteroverride
- meta → Object?
-
Default for
meta: opaque data readable off the mutation. No built-in default.final -
mutationFn
→ MutationFn<
Object?, Object?> ? -
A default mutation function for every mutation under this key, used
when a mutation's own options set none. No built-in default.
final
- networkMode → NetworkMode?
-
Default for
networkMode: when a mutation may run relative to the online state. Built-in: NetworkMode.online.final - retry → RetryPolicy?
-
Default for
retry: whether and how often a failed mutation is retried. Built-in: RetryPolicy.never — mutations are not retried unless asked.final - retryDelay → RetryDelay?
-
Default for
retryDelay: the backoff between retries. Built-in: RetryDelay.defaultValue.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scope → MutationScope?
-
Default for
scope: mutations sharing a scope run one at a time, in submission order. No built-in default: unscoped mutations run in parallel.final
Methods
-
mergedWith(
MutationDefaults? other) → MutationDefaults -
These defaults with
other's laid over them, field by field; anullotherreturns this unchanged. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override