让{var}定义-这是什么

时间:2018-07-15 19:45:33

标签: javascript graphql

我想学习GraphQL,并且在文档中有一个启动代码,可在带有express框架的node.js上运行:

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'));

每件事都运行正常,但我不明白这一行:

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

为什么有花括号?为了什么?

0 个答案:

没有答案