【问题标题】:Unable to open graphql on localhost无法在本地主机上打开 graphql
【发布时间】:2018-01-09 11:40:51
【问题描述】:

我是 graphql 的新手(实际上也是 node.js 的新手)。我需要在给定的应用程序中找到错误。所以我浏览了文件,发现错误一定在以下代码的某个地方:

const express = require('express');
const graphqlHTTP = require('express-graphql');

const { makeExecutableSchema } = require('graphql-tools');

const typeDefs = require('./typeDefs');
const resolvers = require('./resolvers');

const router = express.Router();

const schema = makeExecutableSchema({
   typeDefs,
  resolvers: resolvers()
});

router.use('/graphql', graphqlHTTP({
  schema: schema,
  graphiql: true,
 }));

module.exports = router;

当我尝试打开 http://localhost:3000/graphql/ 时,我看到错误 - 无法获取 /graphql/

哪里可能出错?我几乎检查了所有内容,但仍然不知道我应该怎么做才能让应用正常运行

【问题讨论】:

    标签: javascript node.js graphql


    【解决方案1】:

    你能试试 http://localhost:3000/graphiql 而不是 graphql。我认为这可能会解决您的问题

    【讨论】:

    • 我看到了同样的错误
    • 好的..问题解决了吗?
    • 不,我还在努力寻找解决方案
    猜你喜欢
    • 1970-01-01
    • 2019-07-19
    • 2017-01-10
    • 2015-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-03
    • 1970-01-01
    相关资源
    最近更新 更多