猫鼬graphql错误

时间:2020-10-31 18:41:28

标签: node.js mongodb express mongoose graphql

我正在使用graphql和mongodb创建一个api。在架构内部,我正在填充用户

import mongoose, { Schema } from 'mongoose';

const organizationSchema = new mongoose.Schema(
  {
    users: [{ type: Schema.Types.ObjectId, ref: 'User' }],
    name: String,
    urlName: String
  },
  { timestamps: true }
);

const Organization = mongoose.model('Organization', organizationSchema);
export default Organization;

userDef是这个

type Folder {
    id: ID!
    title: String!
    files: [File]
  }

问题在于,当我发出请求时,文档将被保存为数据库中没有任何类型的文件,因为它应该像这样。 [0] Objectid(“ 5f9d9f73dd7fad1a045e531d”)。如何定义userDef,使其不接受任何名称值

see the image

type Folder {
    "no name": ID!
    title: String!
    files: [File]
  }

0 个答案:

没有答案