代码之家  ›  专栏  ›  技术社区  ›  Avraam Mavridis

Graphql:必须提供查询字符串

  •  3
  • Avraam Mavridis  · 技术社区  · 7 年前

    我有一个简单的express graphql服务器:

    const schema = require('./schema');
    const express = require('express');
    const graphqlHTTP = require('express-graphql');
    const cors = require('cors')
    const bodyParser = require('body-parser');
    
    
    const app = express();
    app.use(cors());
    app.use(bodyParser.urlencoded({ extended: true }));
    app.use(bodyParser.json());
    
    app.use('/graphql', graphqlHTTP(req => {
      return ({
      schema,
      pretty: true,
      })
    }));
    
    const server = app.listen(9000, err => {
      if (err) { return err; }
      console.log(`GraphQL server running on http://localhost:${9000}/graphql`);
    });
    

    enter image description here

    有什么帮助吗?

    (请不要将其作为副本关闭,因为其他帖子没有提供足够的信息,说明用户是如何解决的)

    1 回复  |  直到 7 年前
        1
  •  2
  •   Daniel Rearden    7 年前

    您需要指定 application/json text/plain