@vue/apollo-composable / useMutation / MutateOptions
Interface: MutateOptions ​
Options when calling the mutate function.
1. Operation options ​
errorPolicy? ​
optionalerrorPolicy:ErrorPolicy
Specifies how the mutation handles a response that returns both GraphQL errors and partial results.
The default value is none, meaning that the mutation result includes error details but not partial results.
optimisticResponse? ​
optionaloptimisticResponse:object| (vars) =>object
By providing either an object or a callback function that, when invoked after a mutation, allows you to return optimistic data and optionally skip updates via the IGNORE sentinel object, Apollo Client caches this temporary (and potentially incorrect) response until the mutation completes, enabling more responsive UI updates.
variables? ​
optionalvariables:OperationVariables
Variables for this mutation call.
2. Networking options ​
context? ​
optionalcontext:DefaultContext| (hookContext) =>DefaultContext
Context can be a callback or object.
3. Caching options ​
awaitRefetchQueries? ​
optionalawaitRefetchQueries:boolean
If true, makes sure all queries included in refetchQueries are completed before the mutation is considered complete.
Default ​
falsefetchPolicy? ​
optionalfetchPolicy:MutationFetchPolicy
Provide no-cache if the mutation's result should not be written to the Apollo Client cache.
The default value is network-only (which means the result is written to the cache).
keepRootFields? ​
optionalkeepRootFields:boolean
If true, keeps ROOT_MUTATION fields in the cache after mutation completes. By default, Apollo Client clears these to avoid retaining sensitive data.
onQueryUpdated()? ​
optionalonQueryUpdated: (observableQuery) =>boolean|Promise<unknown>
Optional callback for intercepting queries whose cache data has been updated by the mutation, as well as any queries specified in the refetchQueries: [...] list passed to client.mutate.
Returning a Promise from onQueryUpdated will cause the final mutation Promise to await the returned Promise. Returning false causes the query to be ignored.
Parameters ​
observableQuery ​
object
Returns ​
boolean | Promise<unknown>
refetchQueries? ​
optionalrefetchQueries: (string| {query:DocumentNode;variables?:object; })[] | (result) => (string| {query:DocumentNode;variables?:object; })[]
An array (or a function that returns an array) that specifies which queries you want to refetch after the mutation occurs.
Each array value can be either:
An object containing the
queryto execute, along with anyvariablesA string indicating the operation name of the query to refetch
update()? ​
optionalupdate: (cache,result) =>void
A function used to update the Apollo Client cache after the mutation completes.
Parameters ​
cache ​
ApolloCache
result ​
data? ​
object
Returns ​
void
updateQueries? ​
optionalupdateQueries:Record<string, (prev,options) =>object>
A MutationQueryReducersMap, which is map from query names to mutation query reducers. Briefly, this map defines how to incorporate the results of the mutation into the results of queries that are currently being watched by your application.