I want to listen for file changes and automatically restart the service when changes occur. But I did not find a way to close the server.
Hej @PanJiaChen 馃檶馃徎I remember a discussion on this a while ago... https://github.com/prismagraphql/graphql-yoga/issues/100
Essentially...
const server = new GraphQLServer({ typeDefs, resolvers })
const httpServer = server.start()
httpServer.close()
I have read this issue before, but I found that it does not work.
There are a few problems with the start method usage as shown above:
start method is said to return Promise<void>.start method in the code gives the return type as Promise<HttpServer | HttpsServer>.So, an undocumented, but workable way to obtain the HTTP server object would be:
const server = new GraphQLServer({ typeDefs, resolvers })
server.start()
.then(httpServer => {
// Do stuff
httpServer.close()
});
Due to inactivity of this issue we have marked it stale. It will be closed if no further activity occurs.
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:
Most helpful comment
There are a few problems with the
startmethod usage as shown above:startmethod is said to returnPromise<void>.startmethod in the code gives the return type asPromise<HttpServer | HttpsServer>.So, an undocumented, but workable way to obtain the HTTP server object would be: