Node.js Graphql始终返回null

Node.js Graphql始终返回null,node.js,mongoose,graphql,Node.js,Mongoose,Graphql,我试图使用graphql和mongoose从mongodb集合获取数据,但graphql总是解析为null。这是我正在尝试的查询: getUser(电子邮件:john@gmail.com"){ 名称 } 我认为这是一个类型问题,mongodb的id是一个字符串,graphql的id是GraphQLID,我不想重新启动。为什么要为mongo模式指定和id?是否要在每次更新时手动设置id?否则,您可以删除此字段,因为mongo会自动设置idI。我已经尝试删除id字段,但仍然存在相同的问题。我认为这是

我试图使用graphql和mongoose从mongodb集合获取数据,但graphql总是解析为null。这是我正在尝试的查询:

getUser(电子邮件:john@gmail.com"){ 名称 }


我认为这是一个类型问题,mongodb的id是一个字符串,graphql的id是GraphQLID,我不想重新启动。为什么要为mongo模式指定和id?是否要在每次更新时手动设置id?否则,您可以删除此字段,因为mongo会自动设置idI。我已经尝试删除id字段,但仍然存在相同的问题。我认为这是类型问题,mongodb的id是字符串,graphql的id是GraphQLID,我不知道为什么要为mongo模式指定和id,每次更新都要手动设置id吗?否则,您可以删除此字段,因为mongo会自动设置idI。您已经尝试删除id字段,但仍然存在相同的问题
const userModel = new Mongoose.model("db.users", {
    _id: String,
    email: String,
    name: String
});

const userType = new GraphQLObjectType({
    name: "user",
    fields : {
        _id: {type: GraphQLID},
        email: {type: GraphQLString},
        name: {type: GraphQLString}

    }
});


// Construct a schema
const schema = new GraphQLSchema({

    query: new GraphQLObjectType({
        name:"query",
        fields: {
            getUser: {
                type: userType,
                args: {
                    email: {
                        type: GraphQLString,
                    }
                },
                resolve: async(root, args, context, info) => {
                    return await(userModel.findOne(args).exec());

                }               
            }
        }
    })
});