Skip to Content
Effetch Query
Mutations

Mutation options

Every option a mutation takes.

api.mutation and Mutation.make take the following options:

OptionWhat it doesDefault
run(variables) => Effect: performs the mutation. api.mutation takes none: the endpoint is the run.Required by Mutation.make
optimistic(variables) => Effect: cache writes to show at once, undone if the run fails.None
onSuccess(value, variables) => Effect, after a success, before invalidates.None
onFailure(cause, variables) => Effect, after a failure and the rollback.None
onSettled(exit, variables) => Effect, after either.None
invalidatesTargets to invalidate after onSuccess, or (value, variables) => targets.None, or the route's with "route"
retryA Schedule to retry a failed run with. Defects aren't retried.The client's mutations.defaults, else none
concurrentHow one use's runs overlap: true, false, "queue" or "drop" (Run modes).The client's mutations.defaults, else true

run and the callbacks run with your services and the client, so they can use the cache. optimistic runs with the client only. The callbacks can't fail: they return an Effect whose error type is never.

retry and concurrent can be set once for every mutation, in the client's mutations.defaults, and a mutation's own options override them (Defaults and app-wide hooks).