到目前为止,我见过的所有教程都有非常简单的文档结构,正在转换为GraphQL Schema。我想知道如何将我的mongoose模式转换为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',
},
},
],
},
非常感谢。
答案 0 :(得分:1)
与Mongoose模式中的逻辑非常相似
let exampleType = new GraphQLObjectType({
name: ‘exampleType',
description: ‘example’,
fields: {
_id: {type: GraphQLString},
bookAny: {type: GraphQLBoolean},
bookTopMgt: {type: GraphQLBoolean},
bookPerDepartment: {type: GraphQLBoolean}
...
}
});