fetchPolicy="network-only" still returns data from the cache
It seems like even when I'm using network-only that data from the cache is being returned immediately. I would have expected that the rendering phases would be:
{ data: {}, loading: true } // render 1
{ data: { foo: {…} }, loading: false } // render 2
// done
Instead what happens is that if data from the cache exists, at render 1 data will actually be populated with the cache data.
The React Apollo docs make it clear this should never happen:
network-only: This fetch policy will never return you initial data from the cache. Instead it will always make a request using your network interface to the server. This fetch policy optimizes for data consistency with the server, but at the cost of an instant response to the user when one is available.
For now I'm using a wrapper that returns {} when loading=true and fetchPolicy=no-cache or fetchPolicy=network-only.
@bradleyayers it seems it's an issue with apollo-client which is already fixed in master:
- https://github.com/apollographql/apollo-client/pull/4352
- https://github.com/apollographql/react-apollo/issues/556
Apollo Client 2.5.0 is already released. @bradleyayers could you please confirm if it solved the problem for you?
still happening on the latest client. 2.5.2, definitely an issue with apollo-client
https://github.com/apollographql/react-apollo/issues/556#issuecomment-468886874
Who found a workaround for this?
I need a solution for this too. fetchPolicy: "network-only" is not working.