Reputation: 4650
So, I am writing a node.js app that acts as GraphQL server. I have a schema like that:
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!
}
And I need to create a Program
that includes some group
s (group
is stored inside a Program
in one document, that's why).
How can I pass a nested object as an argument to mutation so it will create a nested object?
Upvotes: 0
Views: 1517
Reputation: 706
What you are looking for is called GraphQLInputObjectType, which is just like GraphQLObjectType, but works for input (arguments)
http://graphql.org/docs/api-reference-type-system/#graphqlinputobjecttype
Enjoy :)
Upvotes: 3