-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors from ObservableQuery.currentResult
are not referentially equal
#2278
Comments
@dallonf this should actually already be fixed with the 2.0 👍 |
@jbaxleyiii I'm still seeing this issue in 2.2.7 - either it regressed or was never fixed. Let me try to recreate the sandbox with the latest version. |
Yup, here's a sandbox with the latest version of everything: (Note the dependency on |
Confirmed on
|
@danilobuerger if this is still an error, can you open a new issues instead please? |
Intended outcome:
Using
react-apollo
(although I think the issue is inapollo-client
, see below), I would like to trigger an imperative action (show an error notification) when a load error occurs. The most straightforward path to me is to compareprops.data.error
withnextProps.data.error
, and if they are different, show the notification for the new error.Actual outcome:
The
data.error
prop is actually anew ApolloError
instance every time the component renders. Based on the stack trace, it appears to be created inObservableQuery.currentResult
, which in turn is called byGraphQL.render
.Because these errors are new for every render, the error notification will appear repeatedly. To get my intended behavior, I would have to compare
error.networkError
anderror.graphQLErrors
(which do seem to be referentially stable), which couples my generic error handling to implementation details of Apollo Client.How to reproduce the issue:
Here is a sandbox:
https://codesandbox.io/s/9jon77z484
Note that whenever the
graphql
wrapper is re-rendered (with any new props, to bypass thecomponentShouldUpdate
check), the error instance is new and so logs a new message, even though it is logically the same error.Version
The text was updated successfully, but these errors were encountered: