React-apollo: Errors cause a re-render with data prop empty and error undefined

Created on 24 Jun 2019  路  4Comments  路  Source: apollographql/react-apollo

Since upgrading from 2.5.6 to 2.5.7 (and 2.5.8), we are seeing an issue where after seeing a GraphQL or network error followed by a re-render, we are getting the error render prop as undefined and the data render prop as {}. If there is a network error, the networkStatus render prop is correctly set to 8, but if it is a GraphQL error, it is set to 7 and we lose the error message.

Intended outcome:

error should stay set to the appropriate ApolloError

Actual outcome:

error is set to undefined

How to reproduce the issue:

I have created a minimal reproduction here: https://tpbowden.dev/react-apollo-error-template/master/

Source code is here: https://github.com/tpbowden/react-apollo-error-template

The query renders with a GraphQL error, then after a 5 second delay a re-render is triggered by setting some state. This causes the bug. I can confirm it only happens in react-apollo versions 2.5.7 and 2.5.8

Version

  System:
    OS: macOS 10.14.5
  Binaries:
    Node: 12.4.0
    Yarn: 1.15.2
    npm: 5.10.0
  Browsers:
    Chrome: 75.0.3770.100
    Firefox: 64.0
    Safari: 12.1.1
  npmPackages:
    apollo: 2.13.1 => 2.13.1
    apollo-link-schema: 1.2.3 => 1.2.3
    apollo-server: 2.6.4 => 2.6.4

[email protected]
[email protected]
bug confirmed has-reproduction

All 4 comments

@jasonpaulos I have added reproduction code in the description

Thanks @tpbowden! I believe the same underlying issue here is present in #3167. I am currently investigating this problem.

3188 has just been merged, which contains a fix for this problem. It will be included in the next beta release of react-apollo 3. Thanks for reporting this issue!

@jasonpaulos thanks for fixing it!

Was this page helpful?
0 / 5 - 0 ratings