Skip to Content
Effetch Query
Reference

Mutation

Every member of the Mutation namespace: defining and running mutations.

Mutation defines mutations, and runs them from Effect. Import it from the core entry point:

import {  } from "@monarcode/effetch-query";

Its exports follow, grouped by the guide that covers them. Each one has the first paragraph of its docs, and what it needs and how it fails; your editor shows the rest, with an example, when you hover the name.

Define a mutation

Guide: Define a mutation.

Mutation.make

Defines a mutation. Nothing runs until it's used, with run or useMutation. Its types come from run: annotate run's parameter to type the variables. Explicit type arguments must give all three, since the value and error types left out are never.

Mutation.isMutation

Checks whether a value is a Mutation. A mutation's variables can't be known from the value, so it narrows to Mutation<never, unknown, unknown>, which every mutation is.

Mutation.TypeId

The property that marks a Mutation.

Mutation.Mutation

A mutation's definition: what a run does with its Variables, succeeding with A or failing with E. Create one with make, and run it with run or useMutation.

Mutation options

Guide: Mutation options.

Mutation.MakeOptions

Options for make. A run calls them in this order:

  1. optimistic, whose cache writes are recorded;
  2. the client's mutations.onMutate;
  3. run, retried on retry;
  4. on success: onSuccess, invalidates, then the client's mutations.onSuccess;
  5. on failure: the optimistic writes are rolled back, then onFailure, then the client's mutations.onFailure;
  6. onSettled, then the client's mutations.onSettled.

Prop

Type

Run a mutation

Guide: Run a mutation.

Mutation.run

Runs a mutation from Effect code, with the steps MakeOptions lists, and succeeds or fails as its run did. A mutation whose run takes no variables runs without them. Each call is a run of its own: concurrent applies to one use's runs, such as a component's useMutation, so calls never interrupt each other.

On this page