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:
optimistic, whose cache writes are recorded;- the client's
mutations.onMutate; run, retried onretry;- on success:
onSuccess,invalidates, then the client'smutations.onSuccess; - on failure: the optimistic writes are rolled back, then
onFailure, then the client'smutations.onFailure; onSettled, then the client'smutations.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.
Related pages
- Entry points: what each entry point exports.
@monarcode/effetch-query: the core entry point's namespaces and top-level names.Query: defining queries, keys and targets, and the cache from Effect.InfiniteQuery: queries that load a list one page at a time.Entity: records whose every cached copy a write updates.QueryClient: the client, its options and hooks, and server rendering.Signals: where a client hears about focus and reconnects.@monarcode/effetch-query/react: the provider, the hooks and the boundaries.@monarcode/effetch-query/effetch: queries and mutations from Effetch endpoints.@monarcode/effetch-query/react-native: focus and online signals for React Native.@monarcode/effetch-query/react/tanstack-router: connecting a client to TanStack Router and Start.