Add option to throw error on willStart #5036
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is maybe more of a question than a suggestion.
At work we are experiencing problems with ApolloGateway- it does not crash if it is unable to connect to services on startup. I debugged it and seems that gateway is handling the error correctly- it throws it, however it's being catched in ApolloServerCore.
We solved this, and other problems by extending ApolloGateway class in our code.
Not so long ago we started using new technological stack, using Nest- and we experienced the issue even more than before. Since we now have less control of the code (if we do not want to fork graphql gateway module ofc.) it's way harder to inject own monkey patches. This behavior makes using gateway harder- we need to either catch the error earlier (for example in AuthenticatedDataSource, where we have no information about gateway/server state), or later (for example using healthchecks).
Because of it we would like to know a best way to catch these errors (or just to allow us to throw errors created during initialization).
Desired behavior seems like this:
Case 1- one or more of the services are unavailable on startup
Gateway crashes
Case 2- one of more of the services crashes after schema is already composed
Gateway handles requests which aren't related to this services
Edit: if there is other way of fixing this issue by making PR to your code I will be happy to create it if it requires reasonable amount of hours to be done.