Error: Expected undefined to be a GraphQL schema
Solution 1:
Feb, 2022 Update:
I downgraded graphql to 15.x then the problem was solved:
npm install [email protected]
If you don't mind the specific version:
npm install graphql@15
If you use "yarn":
yarn add [email protected]
If you don't mind the specific version:
yarn add graphql@15
Solution 2:
You're not passing in a schema to your configuration for the /graphql
endpoint. Property names are case-sensitive in javascript. Change this:
app.use('/graphql',bodyParser.json(), graphqlExpress({
Schema,
context:{
Story,
User
}
}))
to this:
app.use('/graphql',bodyParser.json(), graphqlExpress({
schema: Schema,
context:{
Story,
User
}
}))
or make your variable lowercase and then do:
app.use('/graphql',bodyParser.json(), graphqlExpress({
schema,
context:{
Story,
User
}
}))