简体   繁体   中英

Unable to open graphql on localhost

I'm new to graphql (and to node.js too actually). I need to find mistakes in given app. So I explored files and figured out that mistake must be somewhere in the following code:

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;

When I try to open http://localhost:3000/graphql/ I see error - Cannot GET /graphql/

Where can be a mistake? I checked almost everything and still don't know what I should do to make app work

Can you try http://localhost:3000/graphiql instead of graphql. I think this may solve your issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM