9419ffd03d
* spelling correction * spelling correction * spelling correction * spelling correction * spelling correction * spelling correction * spelling correction * spelling correction * spelling correction
1.7 KiB
1.7 KiB
ApolloMutation component
Example:
<ApolloMutation
:mutation="gql => gql`
mutation DoStuff ($name: String!) {
someWork (name: $name) {
success
timeSpent
}
}
`"
:variables="{
name
}"
@done="onDone"
>
<template v-slot="{ mutate, loading, error }">
<button :disabled="loading" @click="mutate()">Click me</button>
<p v-if="error">An error occurred: {{ error }}</p>
</template>
</ApolloMutation>
Props
mutation: GraphQL query (transformed bygraphql-tag) or a function that receives thegqltag as argument and should return the transformed queryvariables: Object of GraphQL variablesoptimisticResponse: See optimistic UIupdate: See updating cache after mutationrefetchQueries: See refetching queries after mutationclientId: id of the Apollo Client used by the query (defined in ApolloProviderclientsoption)tag: String HTML tag name (default:div); ifundefined, the component will be renderless (the content won't be wrapped in a tag)
Scoped slot props
mutate(options = undefined): Function to call the mutation. You can override the mutation options (for example:mutate({ variables: { foo: 'bar } }))loading: Boolean indicating that the request is in flighterror: Eventual error for the last mutation callgqlError: first GraphQL error if any
Events
done(resultObject)error(errorObject)loading(boolean)