Skip to content
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

fetchPolicy="network-only" still returns data from the cache #81

Open
bradleyayers opened this issue Feb 13, 2019 · 5 comments
Open

fetchPolicy="network-only" still returns data from the cache #81

bradleyayers opened this issue Feb 13, 2019 · 5 comments

Comments

@bradleyayers
Copy link

bradleyayers commented Feb 13, 2019

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.

@trojanowski
Copy link
Owner

Apollo Client 2.5.0 is already released. @bradleyayers could you please confirm if it solved the problem for you?

@wrod7
Copy link

wrod7 commented Mar 11, 2019

still happening on the latest client. 2.5.2, definitely an issue with apollo-client

apollographql/react-apollo#556 (comment)

@ziedHamdi
Copy link

Who found a workaround for this?

@adrianescat
Copy link

I need a solution for this too. fetchPolicy: "network-only" is not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants