I have a nuxtjs app that uses apollo module for graphql communication with FaunaDB. I want to make multiple mutations in one transaction to FaunaDB. So I don't want to send a different request for every single mutation to FaunaDB, I want to make a single request that contains all the mutations. Is it possible?
Asked
Active
Viewed 1,249 times
1 Answers
0
Yes transactions are supported by GraphQL
There is a graphql guide about Multiple fields in mutations .
And a stackoverflow answer.
multiple mutations is not directly related with vue-apollo, it's a feature of Apollo client.
Answer is in GraphQL layer.
Apollo Client documantation has information about it.
Vue-Apollo-todos is a good example for mutations.
And there is a example in apollographql issues
graphql(gql`
query UserQuery ($userId: ID!) {
user(id: $userId) {
# ... selection set
}
}
query PostQuery($postId: ID!) {
post(id: $postId) {
# ... selection set
}
}
mutation CreateUser ($createUserInput: CreateUserInput!) {
createUser(data: $createUserInput) {
# ... selection set
}
}
mutation CreatePost ($createPostInput: CreatePostInput!) {
createPost(data: $createPostInput) {
# ... selection set
}
}
`, {
props: ({ data: { loading, user, post }, createUser, createPost }) => {
// ... do stuff with multiple operations
}
});

Cem Kaan
- 2,086
- 1
- 24
- 55