apollo-client icon indicating copy to clipboard operation
apollo-client copied to clipboard

Makes error handling more consistent

Open MrDoomBringer opened this issue 3 years ago • 1 comments

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

MrDoomBringer avatar Jul 25 '22 19:07 MrDoomBringer

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!

hwillson avatar Jul 29 '22 00:07 hwillson

@MrDoomBringer feel free to ping me when the conflicts are resolved and I'll take a look 👍

alessbell avatar Nov 11 '22 16:11 alessbell

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.

MrDoomBringer avatar Nov 29 '22 18:11 MrDoomBringer