【发布时间】:2018-10-11 12:42:51
【问题描述】:
对于我的 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'
}
}
}
原始数据是这样的。
{
"_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" : true
}
],
"latitude" : "",
"longitude" : "",
"timezone" : "Asia/kolkata"
.......
}
我是 graphQL 的新手,请帮忙。
【问题讨论】:
标签: node.js mongoose graphql graphql-js