如何在制作 graphql 模式时处理嵌入式文档?

How to handle embedded documents in making a graphql schema?

到目前为止,我看到的所有教程都具有非常简单的文档结构,这些文档结构正在转换为 GraphQL 模式。我想知道如何将我的猫鼬模式转换为 GraphQL。

_id: mongoose.Schema.Types.ObjectId, booking: { bookAny: { type: Boolean, default: true, }, bookTopMgt: { type: Boolean, default: false, }, bookPerDepartment: { type: Boolean, default: false, }, perDepartmentBooking: [ { departmentId: { type: mongoose.Schema.Types.ObjectId, ref: 'Department', }, }, ], },

非常感谢。

与 Mongoose 模式中的逻辑几乎相同

let exampleType = new GraphQLObjectType({ name: ‘exampleType', description: ‘example’, fields: { _id: {type: GraphQLString}, bookAny: {type: GraphQLBoolean}, bookTopMgt: {type: GraphQLBoolean}, bookPerDepartment: {type: GraphQLBoolean} ... } });