Error: Expected undefined to be a GraphQL schema. on version 16.0.1
See original GitHub issuenode: 16.13.0 graphql-js: 16.0.1 I tried to run this example from official documentation :
var { graphql, buildSchema } = require('graphql');
// Construct a schema, using GraphQL schema language
var schema = buildSchema(`
type Query {
hello: String
}
`);
// The root provides a resolver function for each API endpoint
var root = {
hello: () => {
return 'Hello world!';
},
};
// Run the GraphQL query '{ hello }' and print out the response
graphql(schema, '{ hello }', root).then((response) => {
console.log(response);
});
and got this error:
/home/arunz/Downloads/graphql/node_modules/graphql/type/schema.js:35
throw new Error(
^
Error: Expected undefined to be a GraphQL schema.
at assertSchema (/home/arunz/Downloads/graphql/node_modules/graphql/type/schema.js:35:11)
at validateSchema (/home/arunz/Downloads/graphql/node_modules/graphql/type/validate.js:34:28)
at graphqlImpl (/home/arunz/Downloads/graphql/node_modules/graphql/graphql.js:52:64)
at /home/arunz/Downloads/graphql/node_modules/graphql/graphql.js:21:43
at new Promise (<anonymous>)
at graphql (/home/arunz/Downloads/graphql/node_modules/graphql/graphql.js:21:10)
at Object.<anonymous> (/home/arunz/Downloads/graphql/hello.js:18:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
No error with graphql-js version 15.7.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Error: Expected undefined to be a GraphQL schema
I faced this with latest version of graphql and @nestjs/graphql :"9.1.2" version.
Read more >Unhandled Rejection (Error): Expected undefined to be a ...
The front page flashes up and then I get this error: Unhandled Rejection (Error): Expected undefined to be a GraphQL schema. invari...
Read more >Error: expected undefined to be a graphql schema.
if you are getting this error Error: Expected undefined to be a GraphQL schema. it's because You're not passing in a schema to...
Read more >Error: Expected undefined to be a GraphQL schema-Reactjs
I faced this with latest version of graphql and @nestjs/graphql :"9.1.2" version. Downgraded the version to 15.8.0 and it's started working. npm i...
Read more >graphql - npm
GraphQL.js provides two important capabilities: building a type schema and serving queries against that type schema. First, build a GraphQL type ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

When will the documentation be updated 😦
@zorro Please use named arguments, since it’s expected breaking change. Please see #2904 for the details.