# Mutation options (https://0758e0c7.effetch-query.pages.dev/docs/mutations/options)

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

| Option        | What it does                                                                                                 | Default                                        |
| ------------- | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------- |
| `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                                           |
| `invalidates` | Targets to invalidate after `onSuccess`, or `(value, variables) => targets`.                                 | None, or the route's with `"route"`            |
| `retry`       | A `Schedule` to retry a failed run with. Defects aren't retried.                                             | The client's `mutations.defaults`, else none   |
| `concurrent`  | How one use's runs overlap: `true`, `false`, `"queue"` or `"drop"` ([Run modes](https://0758e0c7.effetch-query.pages.dev/docs/mutations/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](https://0758e0c7.effetch-query.pages.dev/docs/client/defaults)).