错误:未知类型为“查询”。在assertValidSDL(GRAPHQL)

时间:2020-05-15 17:48:13

标签: reactjs graphql graphql-js

throw new Error(errors.map(function (error) {
    ^
Error: Unknown type "Query".
    at assertValidSDL (C:\Users\Sowmica\Desktop\graphql\udemy\gql\server\node_modules\graphql\validation\validate.js:107:11)
    at Object.buildASTSchema (C:\Users\Sowmica\Desktop\graphql\udemy\gql\server\node_modules\graphql\utilities\buildASTSchema.js:45:34)
    at Object.buildSchemaFromTypeDefinitions (C:\Users\Sowmica\Desktop\graphql\udemy\gql\server\node_modules\graphql-tools\dist\generate\buildSchemaFromTypeDefinitions.js:25:28)
    at Object.makeExecutableSchema (C:\Users\Sowmica\Desktop\graphql\udemy\gql\server\node_modules\graphql-tools\dist\makeExecutableSchema.js:26:29)
    at ApolloServer.initSchema (C:\Users\Sowmica\Desktop\graphql\udemy\gql\server\node_modules\apollo-server-core\dist\ApolloServer.js:273:49)
    at new ApolloServerBase (C:\Users\Sowmica\Desktop\graphql\udemy\gql\server\node_modules\apollo-server-core\dist\ApolloServer.js:196:30)
    at new ApolloServer (C:\Users\Sowmica\Desktop\graphql\udemy\gql\server\node_modules\apollo-server-express\dist\ApolloServer.js:59:9)
    at Object.<anonymous> (C:\Users\Sowmica\Desktop\graphql\udemy\gql\server\server.js:23:22)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
[nodemon] app crashed - waiting for file changes before starting...**

请帮助我解决从错误消息中无法理解的错误。我在git中也提到了类似的问题,但没有帮助。请给我一个可能的解决方案! 这是我的github存储库链接

https://github.com/SowmicaML/graphql

谢谢。

2 个答案:

答案 0 :(得分:1)

您应该将相关的代码示例直接发布到您的问题中,因为将来链接可能会失效。我注意到的一件事是您缺少在typeDefs中关闭make game_with_qtree的功能。 }

中的示例
auth.js

答案 1 :(得分:0)

确保在type / index.ts和resolvers / index.ts中导入正确的typeDef和左轮手枪 有时它会在类型/左轮手枪中导入模型,这对我造成了问题