apollo-client
apollo-client copied to clipboard
Makes error handling more consistent
See this Issue for more information: https://github.com/apollographql/apollo-client/issues/9870
This PR aims to make the networkError and graphQLErrors fields on the result object behave as expected for all react hooks - on any 4/500 error code networkError will be populated, and if there's any GraphQL error from the server, it will be present in that field.
Behavior currently looks good with useQuery, useSubscription, and ApolloLink. I tried to make the implementation as non-intrusive as possible, both for backwards compatability and to hopefully prevent regressions by touching too much code.
TODO: Add test coverage
Checklist:
- [X] If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
- [X] Make sure all of the significant new logic is covered by tests
Super cool @MrDoomBringer (which is an appropriate GH username for working on error PR's 😂). Let us know when you think this is ready for review (holding off for now since it's still in draft). Thanks!
@MrDoomBringer feel free to ping me when the conflicts are resolved and I'll take a look 👍
Hey @alessbell! I think this PR needs a bit more work, so I'll be putting it on the backburner for now. Definitely some good preliminary work in here through that should be useful when it's time to revisit it.