Proper way to reload schema without restarting service?

Hi All!

Previously, I was using the apollo gateway load function to reload the schema (I don’t use the managed service), but since this commit and the introduction of phases it no longer works with the error being “Error: ApolloGateway.load called in surprising state loaded”. The function requires that the load functions is in the “initialized” state, which I’m not sure how to get to.

I was wondering if anyone had any suggestions of the correct way to do a manual reload of the schema. The idea is the I would like to expose an endpoint that would fetch the schemas whenever I hit it.

Can you provide a runnable example – at the very least sharing the code you’re using, but preferably either a small Git-clone-able repository or a Codesandbox example (here’s a decent starting app)?

Also, have you changed your underling Apollo Server to use await server.start()? Could you provide all the versions you’re using?

Hi Abernix!

I am using await server.start().
The verisons of depedency’s that I am trying to use are
@apollo/federation”: “^0.25.2”,
@apollo/gateway”: “^0.32.0”,
“apollo-server-express”: “^2.25.2”,

Please see the github repo here for a small runnable example. Using the “start-gateway” and “start-services” scripts. The /refreshSchema post call still has the same issue with this current version mentioned above. The last version that I noticed this working with was apollo gateway 0.22.0

Anyone have any suggestions on what is the recommended solution to reload the schema via some sort of exposed endpoint?

The Apollo-recommended solution is to use Managed federation. It’s free! Have you considered that?

Came here to say ^^. Managed Federation +1

1 Like