graphql/express-graphql

Why isn't the callback of app.listen() called when using express-graphql middleware?

KerimG opened this issue · 4 comments

I have a very simple graphql setup that looks something like this:

const express = require("express");
const app = express();

//...

app.use(
  '/graphql',
  graphqlHTTP({
    schema: makeExecutableSchema({
      typeDefs,
      resolvers,
    }),
    graphiql: true,
  })
);

app.listen(8165, () => {
  'Running a GraphQL API server at :8165/graphql';
});

but for some reason the callback isn't being called. I figure this has something to do with the middleware.

Try
app.listen(8165, () => {
'Running a GraphQL API server at :8165/graphql';
});

@harsh3977 thanks for the info. That's the first thing I tired, since it's the default express way, but it looks like express-graphql seems to somehow supress it

Sorry My bad. Try async before the function
app.listen(8165,async () => {
'Running a GraphQL API server at :8165/graphql';
});

@harsh3977

Thanks a ton. That seems to have worked. I don't know why the callback has to be async but that seems to have fixed it.