when having a network error I would like to show the previous cached data (since we're using polling so there might be moments without network connection)
how can I do it?
@reut-co are you using react-apollo? If so, the component will now keep the data that was previously returned.
As for having a fetch policy that is essentially fetch-from-network-but-use-cache-if-necessary, we don't have that ready quite yet, but it's something we've been thinking about in the context of having much more flexible fetch policies.
@helfer I have a slightly related question about this… I'm using fetchPolicy cache-and-network, but I only want to show an error message to the user if both fail. Meaning ignore network errors as long as there is something in the cache.
By just checking data.error the network request failure will cause an error to pop up even if the cache was able to return data. What is the correct approach here? Ignore data.error if there is still query data available? I'm also always getting "Unhandled (in react-apollo) Error: Network error: undefined" messages – am I doing something wrong? I don't see how I could handle the errors in graphql-wrapped React components.
This issue has been automatically marked as stale becuase it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Apollo Client!
This issue has been automatically closed because it has not had recent activity after being marked as stale. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to Apollo Client!
Most helpful comment
@reut-co are you using react-apollo? If so, the component will now keep the data that was previously returned.
As for having a fetch policy that is essentially fetch-from-network-but-use-cache-if-necessary, we don't have that ready quite yet, but it's something we've been thinking about in the context of having much more flexible fetch policies.