Saturday 18 March 2017

buildSchema is not a function graphql npm

The official website of graphql refers to this graphql npm to create the helloworld .

var { graphql, buildSchema } = require('graphql');

var schema = buildSchema(`
  type Query {
    hello: String
  }
`);

var root = { hello: () => 'Hello world!' };

graphql(schema, '{ hello }', root).then((response) => {
  console.log(response);
});

When i run this file with node cmd , I got :

var schema = buildSchema(` ^

TypeError: buildSchema is not a function at Object. (

I guess the offcial website of graphql is not up-to-date with this repository , so , i tried to use GraphQLSchema instead of buildSchema

var schema = GraphQLSchema(`
  ...
`)

I go another error:

TypeError: Cannot call a class as a function

Thus , i called new GraphQLSchema(... instead of GraphQLSchema(...

I got another error :

Error: Must provide configuration object.

What is the new version of buildSchema and what is its signature ?



via Abdennour TOUMI

No comments:

Post a Comment