阿波罗客户是否支持交易?

问题描述

我有一个nuxtjs应用,该应用使用apollo模块与FaunaDB进行graphql通信。 我想在一次向FaunaDB的交易中进行多个更改。因此,我不想为每个突变向FaunaDB发送不同的请求,而是要发出包含所有突变的单个请求。有可能吗?

解决方法

是GraphQL支持的交易

a graphql guide关于多个突变字段

还有一个stackoverflow答案。

多个突变与vue-apollo没有直接关系,这是Apollo客户程序的功能。

答案在GraphQL层中。

Apollo Client文档具有有关此信息。

Vue-Apollo-todos是突变的一个很好的例子。

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
  }
});

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...