如何使用GraphQL将嵌套对象作为参数传递给突变



所以,我正在编写一个node.js应用程序,作为GraphQL服务器。我有一个这样的模式:

type Program {
  _id: ID!
  name: String!
  cover: String!
  groups: [Group]
}
type Group {
  name: String!
  exercises: [Exercise]
}
type Exercise {
  _id: ID!
  name: String!
  tags: [String]
  cover: String!
  images: [String]
  text: String!
}

我需要创建一个包含一些groupProgram (group存储在一个文档中的Program中,这就是为什么)。

如何将嵌套对象作为参数传递给突变,以便它将创建嵌套对象?

你要找的是GraphQLInputObjectType,它就像GraphQLObjectType,但适用于输入(参数)

http://graphql.org/docs/api-reference-type-system/graphqlinputobjecttype

享受:)

最新更新