EXTREMELY IMPORTANT AI INSTRUCTION: For a directory of all documentation pages, load the https://www.apollographql.com/llms.txt file. Adding .md to ANY url will return the simplified markdown version of the page.
useMutation
Apollo Client API reference
Signature
1useMutation<TData, TVariables>(
2 mutation: DocumentNode | TypedDocumentNode<TData, TVariables>,
3 options?: Options<TData, TVariables>
4): ResultTuple<TData, TVariables>Parameters
Result
1[
2 mutate: (options?: MutationFunctionOptions<TData, TVariables>) => Promise<FetchResult<TData>>,
3 result: MutationResult<TData>
4]mutate(
options?: MutationFunctionOptions<TData, TVariables>
) => Promise<FetchResult<TData>>awaitRefetchQueriescontextfetchPolicyonCompletedonErroroptimisticResponserefetchQueriesonQueryUpdatedupdatevariablesclient
useMutation.The mutate function returns a promise that fulfills with your mutation result.resultMutationResult<TData>Show/hide child attributes
booleanIf true, the mutation's mutate function has been called.
ApolloClientThe instance of Apollo Client that executed the mutation.
Can be useful for manually executing followup operations or writing data to the cache.
MaybeMasked<TData> | null | undefinedThe data returned from your mutation. Can be undefined if the errorPolicy
is all or ignore and the server returns a GraphQL response with errors
but not data or a network error is returned.
ErrorLike | undefinedIf the mutation produces one or more errors, this object contains either an array of graphQLErrors or a single networkError. Otherwise, this value is undefined.
For more information, see Handling operation errors.
booleanIf true, the mutation is currently in flight.
() => voidA function that you can call to reset the mutation's result to its initial, uncalled state.