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?
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
The suggestion to use managed federation is not a concrete solution. What if you can’t use Managed Federation because of internal company decisions? Are there any other solutions?
So in the newer versions of Apollo Federation (gateway, etc.) there is no way to tell the gateway to reload the schema other than Managed federation via Apollo Studio or restarting the gateway?
Unfortunately it kinda looks like that, please take my answer with a grain of salt, I don’t know much about this myself, last time I tried, I tried, managed federation looked like the only way, obviously there might be some experimental flag which I don’t know about, someone from apollo team might be able to answer this.
If the requirement to do is because of pricing options, I must say there’s no reason to worry about that though, apollo works really well without even paying, we’re paying because I like the schema checks from github.
If the requirement is because your company doesn’t allow usage of apollo studio, then I guess you might have to deploy gateway everytime a subgraph is updated. But that shouldn’t be a big deal though, right? we all do canary deployment, sure it’s annoying, but is that a deal breaker?
BTW, if you just sign up to apollo studio, the team is awesome that you’ll be able to setup a 15 mins call with them and you can just verbally put all your concerns and they’ll address them. I had an amazing experience with @GWashington
You can also try to look at type definitions to see if there’s any experimental flag which let’s you do the polling.
Instead of gateway.load(), has anyone tried either gateway.loadDynamic(false)? Might also be able to change the state before calling load() like this gateway.state = { phase: 'initialized' } (or maybe safer gateway.state.phase = 'initialized' which is the same state that Apollo Gateway sets. Of course, you run the risk of more state properties that might cause issues down the road with the second approach.