代码之家  ›  专栏  ›  技术社区  ›  Woppi

如何在创建graphql模式时处理嵌入文档?

  •  0
  • Woppi  · 技术社区  · 8 年前

    到目前为止,我看到的所有教程都有非常简单的文档结构,正在转换为GraphQL模式。我想知道如何将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', }, }, ], },

    谢谢。

    1 回复  |  直到 8 年前
        1
  •  1
  •   Katie Mary    8 年前

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

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

    推荐文章