Intended outcome:
const withGraphQlQuery = graphql(someQuery, {
options: () => ({
notifyOnNetworkStatusChange: true,
}),
props: ({data}) => {
console.log('data', data);
return data;
}
});
In the above example I have some code in my actual presentational component that does error handling and displays a button that will call data.refetch() when pressed. When a network error occurs and then you tap said button, I would expect refetch to be called and for data to be logged with a networkStatus of 4 (when it's refetching), and then a second time once the response comes back with a networkStatus of 7 (when it gets a response and is ready).
Actual outcome:
When I actually tried this out, I did not receive the first console log statement I expected. Instead I only got notified of the networkStatus of 7 response.

One interesting thing to note is that when the network request is successful and I try to refetch, it will log out the responses I was expecting in the error scenario.

Another interesting note is that I'm able to get the expected console log statements with the networkStatus of 4 while refetching if there is a network error, I have notifyOnNetworkStatusChange set to true AND I have an errorPolicy of all. However, setting this errorPolicy has other side effects and I don't think it should be necessary to set an errorPolicy and notifyOnNetworkStatusChange option just to get notified of network status changes....
How to reproduce the issue:
If I get time I will add the reproduction using the error template, but you should be able to reproduce by using any HOC query with a similar format as mine listed above, and then forcing a network error and trying to refetching. When you attempt a refetch after an error response then you never get notified of the networkStatus changing to 4.
Version
I created this reproduction that proves the issue still exists: https://codesandbox.io/s/react-apollo-issue-2926-o1ryu
This is an issue with apollo-client, and I am working on creating a fix to be included in its next version.
Most helpful comment
I created this reproduction that proves the issue still exists: https://codesandbox.io/s/react-apollo-issue-2926-o1ryu
This is an issue with apollo-client, and I am working on creating a fix to be included in its next version.