Skip to content

API reference > @kontsedal/olas-core > MutationSpec

MutationSpec type ​

The configuration object passed to createMutation(ctx, spec). See spec §20.5 for the full lifecycle semantics. onMutate may return a Snapshot (fromquery.setData(...)) to enable automatic rollback on error.

Signature:

typescript
type MutationSpec<V, R> = {
  id?: string;
  mutate: (vars: V, ctx: MutateCtx) => Promise<R>;
  onMutate?: (vars: V) => Snapshot | void;
  onSuccess?: (result: R, vars: V) => void;
  onError?: (err: unknown, vars: V, snapshot: Snapshot | undefined) => void;
  onSettled?: (result: R | undefined, err: unknown | undefined, vars: V) => void;
  concurrency?: MutationConcurrency;
  retry?: RetryPolicy;
  retryDelay?: RetryDelay;
  meta?: MutationMeta;
  detached?: boolean;
};

References: MutateCtx, Snapshot, MutationConcurrency, RetryPolicy, RetryDelay, MutationMeta

Released under the MIT License.