@vue/apollo-composable / useMutation / Result
Interface: Result ​
Result returned by useMutation.
1. Mutation ​
mutate() ​
mutate: (
options?) =>Promise<MutateResult>
Call the mutation with optional variables and override options.
Parameters ​
options? ​
Variables and options for this mutation call.
Returns ​
Promise<MutateResult>
Promise resolving to the mutation result.
Example ​
const { mutate } = useMutation(AddTodo)
// Call with variables
const result = await mutate({ variables: { text: 'New todo' } })
// With optimistic response
await mutate({
variables: { text: 'New todo' },
optimisticResponse: {
addTodo: { __typename: 'Todo', id: 'temp', text: 'New todo', completed: false }
}
})2. Operation data ​
error ​
error:
Ref<ErrorLike|undefined>
If the mutation produces one or more errors, this object contains either an array of graphQLErrors or a single networkError. Otherwise, this value is undefined.
result ​
result:
Ref<object|null|undefined>
The data returned from your mutation. Can be undefined if errorPolicy is all or ignore and the server returns a GraphQL response with errors but not data, or a network error is returned.
3. Network info ​
called ​
called:
Ref<boolean>
If true, the mutation's mutate function has been called.
loading ​
loading:
Ref<boolean>
If true, the mutation is currently in flight.
4. Lifecycle ​
reset() ​
reset: () =>
void
Reset the mutation's result to its initial, uncalled state.
Returns ​
void
5. Events ​
onDone ​
onDone:
EventHookOn<MutateResult>
Event triggered when the mutation completes successfully.
onError ​
onError:
EventHookOn<ErrorLike>
Event triggered when the mutation encounters an error.
6. Refs ​
document ​
document:
Ref<DocumentNode>
The GraphQL document being mutated.
options ​
Current options.