Graphql-yoga: Production Server Endpoint Hangs on Request

Created on 4 Mar 2019  路  4Comments  路  Source: dotansimha/graphql-yoga

Hey everyone,
I've been working on deploying my GraphQL-Yoga server these last few days and I'm having an issue that I'm not able to diagnose, so any insight you all can provide would be greatly appreciated.

Problem: After I deploy my GraphQL server to a DigitalOcean node via Docker then when I make a request to the API server the request hangs indefinitely till it times out. The network logs in the browser show that the first fetch request for OPTIONS is successful but the 2nd fetch stays pending.

I've gone ahead and isolated the server on its own node and separated it's deploy from my web container to rule out any networking issues.

Also, please note that the server is functional when running it on my own localhost via npm start or using Docker locally.

statustale

Most helpful comment

Go ahead and close out; I ended up switching to Apollo Server.
The issue ended up being was that GraphQL Yoga is bound to localhost and I was unable to get the endpoint to bind to 0.0.0.0. A host option needs to be added to bind to a different host.

All 4 comments

Go ahead and close out; I ended up switching to Apollo Server.
The issue ended up being was that GraphQL Yoga is bound to localhost and I was unable to get the endpoint to bind to 0.0.0.0. A host option needs to be added to bind to a different host.

Due to inactivity of this issue we have marked it stale. It will be closed if no further activity occurs.

Hey :wave:, It seems like this issue has been inactive for some time. In need for maintaining clear overview of the issues concerning the latest version of graphql-yoga we'll close it.
Feel free to reopen it at any time if you believe we should futher discuss its content. :slightly_smiling_face:

GraphQLServer.start() just returns Promise of express.listen()
https://github.com/prisma-labs/graphql-yoga/blob/88b08ddde53641c6856ed240ea42da01fb7eea20/src/index.ts#L373-L399

So you can use GraphQLServer.createHttpServer() and listen() with it
(Be careful: This behavior can be changed in the future).
~~~js
const server = new GraphQLServer({ typeDefs, resolvers });
const options = {
port: 3000,
};

server.createHttpServer(options)
.listen(options.port, '0.0.0.0', () => {
console.log(Server started, listening on port ${options.port});
});
~~~

Was this page helpful?
0 / 5 - 0 ratings