sowmica ML
sowmica ML

Reputation: 17

Error: Unknown type "Query". at assertValidSDL (GRAPHQL)

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...**

Please help me to solve this error I can't understand from the error message. I also referred to similar issues in git but none helped. Please give me a possible solution! This is my github repository link

https://github.com/SowmicaML/graphql

Thank You in advance.

Upvotes: 0

Views: 4400

Answers (2)

Lakshan Hettiarachchi
Lakshan Hettiarachchi

Reputation: 441

Make sure you import correct typeDef and revolvers in types/index.ts and resolvers/index.ts Sometimes it import model in types/revolvers, That cause the issue for me

Upvotes: 0

puelo
puelo

Reputation: 5977

You should post the relevant code samples directly into your question, because links can be dead in the future. One thing i have noticed is that you are missing closing } in your typeDefs. Example from auth.js

const { gql } = require("apollo-server-express");

module.exports = gql`
type Query {
    me: String!
`;

Upvotes: 1

Related Questions