GraphQL是一个灵活的API标准,前端可以自定义只获取它想要的数据结构,

安装相关依赖

  1. npm i express-graphql
  1. const { graphqlHTTP } = require('express-graphql');
  2. import graphqlSchema from './graphql';
  3. app.use('/graphql', graphqlHTTP({
  4. schema: graphqlSchema,
  5. graphiql: true
  6. }))