对于我的MongoDB对象,我有一个架构,其中有许多嵌套数据。
但是我在GraphQL中完美实现了查询以获取数据,但是由于无法定义类型,因此无法获取嵌套数据。
fields() {
return {
name: {
type: GraphQLString,
description: 'Name of the person'
},
age: {
type: GraphQLString,
description: 'Age'
},
documents: { // what to do here
type: new GraphQLList(),
description: 'All documents for the person'
}
}
}
Run Code Online (Sandbox Code Playgroud)
原始数据是这样的。
{
"_id" : ObjectId("5ae1da5e4f00b5eee4ab84ee"),
"name" : "Indira Gandhi International Airport",
"age" : 54,
"documents" : [
{
"doc_name" : "personal card",
"doc_url" : "http://",
"status" : true
},
{
"doc_name" : "bank card",
"doc_url" : "http://",
"status" …Run Code Online (Sandbox Code Playgroud)