question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Expected undefined to be a GraphQL schema. on version 16.0.1

See original GitHub issue

node: 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:closed
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
myarmolikcommented, Dec 6, 2021

When will the documentation be updated 😦

1reaction
IvanGoncharovcommented, Nov 4, 2021

@zorro Please use named arguments, since it’s expected breaking change. Please see #2904 for the details.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found