1

I'm want to learn GraphQL and in the documentation there is a start up code to run on node.js with express framework:

var express = require('express');
var graphqlHTTP = require('express-graphql');
var { buildSchema } = require('graphql');

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

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

var app = express();
app.use('/graphql', graphqlHTTP({
  schema: schema,
  rootValue: root,
  graphiql: true,
}));
app.listen(4000, () => console.log('Now browse to localhost:4000/graphql'));

Every thing is running properly but I dont understand this line:

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

Why there are curly braces? For what?

Jacek Majer
  • 345
  • 1
  • 3
  • 14

0 Answers0