ApolloServerExpressv4GraphQLthis.findOneByIdisnotafunction
创始人
2024-09-09 13:00:59
0

出现这个错误通常是因为没有在Model中定义需要查询的字段。解决方法是定义需要查询的字段,例如在mongoose中,可以使用findById而不是findOneById。以下是一个示例代码:

const { ApolloServer } = require('apollo-server-express');
const mongoose = require('mongoose');

// 定义schema
const typeDefs = `
  type User {
    id: ID!
    name: String!
    email: String!
  }
  type Query {
    user(id: ID!): User
  }
`;

// 定义resolvers
const resolvers = {
  Query: {
    user: async (parent, args) => {
      const { id } = args;
      const User = mongoose.model('User');
      const user = await User.findById(id);
      return user;
    }
  }
};

// 创建服务器
const server = new ApolloServer({ typeDefs, resolvers });

相关内容

热门资讯

透视真的(wpk发牌)外挂透明... 1、透视真的(wpk发牌)外挂透明挂辅助软件(辅助挂)透视辅助(有挂透明挂)-哔哩哔哩(UU pok...
今日头条(微扑克软件)外挂透明... WePoker透视辅助版本稳定性对比与推荐‌:今日头条(微扑克软件)外挂透明挂辅助APP(辅助挂)发...
一分钟揭秘(wepokeai代... 一分钟揭秘(wepokeai代打)外挂透明挂辅助工具(辅助挂)的确真的有挂(2024已更新)(哔哩哔...
1分钟了解!wepoke规律(... 自定义wepoke规律系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器,不管...
科技分享(Wepoke技术)外... 科技分享(Wepoke技术)外挂透明挂辅助机制(透视)透视辅助(有挂总结)-哔哩哔哩;Wepoke技...
玩家必知教程(wepoke辅助... 玩家必知教程(wepoke辅助)外挂透明挂辅助软件(辅助挂)发牌机制(新版有挂)-哔哩哔哩是一款可以...
记者发布(WPKplus)外挂... WPKplus赢率提升策略‌;记者发布(WPKplus)外挂透明挂辅助机制(辅助挂)其实真的有挂(2...
大神推荐!拱趴大菠萝免费(we... 大神推荐!拱趴大菠萝免费(wepOKE)外挂透明挂辅助插件(辅助挂)细节揭秘(有挂解惑)-哔哩哔哩关...
一分钟揭秘(Wepoke技巧)... 1、一分钟揭秘(Wepoke技巧)外挂透明挂辅助脚本(辅助挂)辅助透视(有挂透视)-哔哩哔哩;该软件...
科普(扑克时间后台数据)外挂透... 科普(扑克时间后台数据)外挂透明挂辅助神器(透视)透视辅助(有挂透明挂)-哔哩哔哩;扑克时间后台数据...