Apollo server: call start() after stop() server not start

Hello all,
I’m developing an app using Apollo server express.
I can’t understand why if I call server.stop() and then server.start() the server throw Error because the state is stopped.

Any idea about how to stop the server and then restart?

Make a new ApolloServer object.

Thank you for the reply.
I tried also that, but seems that the new instance of ApolloServer is not more reachable on the same path of express server, after using applyMiddleware function.

Could it be possible or I doing something wrong?

You shouldn’t stop your server until you’ve fully drained all HTTP servers that are sending requests to it anyway, or those requests will fail. Why do you want to stop and start your server?

My target is to stop the ApolloServer graphql endpoint, so that it doesn’t accept income requests. Then rebuild a new instance of ApolloServer with a new schema and make it available on the same path.

I tried also to reload a schema, but with no success.

The gateway option can be used to dynamically update the schema of an ApolloServer.

Thank you for point me in the right way. I will try the gateway option and let you know if all is ok