MutationHandle
Exposes the public state and operations of a mutation.
Table of contents
Category
Value
Import
jsimport { MutationHandle } from "valyrian.js/query";Public signature
tsclient.mutation<TPayload, TResult>(config: MutationConfig<TPayload, TResult>): MutationHandle<TPayload, TResult>API form
MutationHandle is a class instance returned by QueryClient.mutation(...). Application code obtains it from the client instead of calling its infrastructure constructor.
Configuration
tstype MutationConfig<TPayload, TResult> = {
execute: (payload: TPayload) => Promise<TResult> | TResult;
onSuccess?: (result: TResult) => void;
onError?: (error: unknown) => void;
};Properties and methods
tstype QueryState<TResult> = {
status: "idle" | "loading" | "success" | "error";
loading: boolean;
success: boolean;
error: unknown;
data: TResult | null;
updatedAt: number;
};
readonly state: QueryState<TResult>
execute(payload: TPayload): Promise<TResult>
reset(): voidExecution outcomes
execute() updates mutation state and invokes the matching success or error callback. A rejected operation leaves its error in state and rejects execute(). reset() restores idle state and clears result and error.