I follow the tutorial from GraphQl https://graphql.org/graphql-js/
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);
});
When I run it, I expect to get
{ data: { hello: 'Hello world!' } }
However, instead I get
{ data: [Object: null prototype] { hello: 'Hello world!' } }
Why is that?