【问题标题】:How to create a nested mutation with an empty child in GraphQL如何在 GraphQL 中使用空子创建嵌套突变
【发布时间】:2017-04-25 00:24:53
【问题描述】:

如何在作者没有必填字段的情况下创建帖子和作者?

类似:

mutation {
  createPost(
    text: "This is a post!"
    author: {
      // ???
    }
  ) {
    id
    author {
      id
    }
  }
}

【问题讨论】:

    标签: graphql


    【解决方案1】:

    你可以转nested mutation

    mutation {
      createUser(posts: [{
        text: "This is a post!"
      }]) {
        id
      }
    }
    

    我假设它是一个一对多关系,并且字段被称为posts

    【讨论】:

      猜你喜欢
      • 2018-09-19
      • 2019-07-31
      • 2016-09-08
      • 2019-08-24
      • 2020-04-24
      • 2018-08-24
      • 2021-04-09
      • 2018-01-02
      • 2021-04-24
      相关资源
      最近更新 更多