Closed
Description
Description
The instructions at the page Getting Started With GraphQL.js didn't work for me.
Even though the page mentions Node v6, I expected that it should work on more recent versions as well.
Steps to Reproduce
Follow the instructions at https://graphql.org/graphql-js/:
npm init
npm install graphql --save
- Create the
server.js file
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);
});
- Run
node server.js
Expected Result
{ data: { hello: 'Hello world!' } }
Actual Result
UnhandledPromiseRejectionWarning: Error: Expected undefined to be a GraphQL schema.
Additional Context
The installed package version was "graphql": "^16.0.1".
The node version I used was v14.17.0.
Metadata
Metadata
Assignees
Labels
No labels