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

skip is not working correctly with nextFetchPolicy #8895

Open
smitpatel1010 opened this issue Oct 5, 2021 · 4 comments
Open

skip is not working correctly with nextFetchPolicy #8895

smitpatel1010 opened this issue Oct 5, 2021 · 4 comments

Comments

@smitpatel1010
Copy link

const { loading, data } = useQuery(QUERY, {
  skip: conditionallySkipped,
  fetchPolicy: 'cache-and-network',
  nextFetchPolicy: 'cache-first'
});

Intended outcome:
If the skip is false in useQuery then a new call should go and the cache should update with a new response.

Actual outcome:
If the skip is false in useQuery then a new call is going correct but the cache is not updating with the latest response came.

How to reproduce the issue:
https://codesandbox.io/s/serene-grass-qwy7b?file=/src/index.js
Open this codesandbox and follow below steps.

  1. toggle skip to true
  2. add new todo
  3. toggle skip to false

then check new call is going and received new data but the cache is not updating the value with the latest response.

@brainkim
Copy link
Contributor

brainkim commented Oct 5, 2021

I’m currently on my phone in bed (it’s 3AM), but I bet you if you remove the nextFetchPolicy: 'cache-first' line, everything works as expected? Just a hunch. I will look into it more fully in the morning. Thanks for the reproduction!

@smitpatel1010
Copy link
Author

smitpatel1010 commented Oct 5, 2021

Yes, If we remove nextFetchPolicy: 'cache-first' line then it works fine. but I want pagination with cache-and-network and because of this issue I had to add this line. and Thanks for quick reply

@brainkim brainkim changed the title Cache not updating when skip value changed from false to true. skip is not working correctly with nextFetchPolicy Oct 5, 2021
@brainkim
Copy link
Contributor

brainkim commented Oct 5, 2021

@smitpatel1010 Thanks for the confirmation! I updated the title to reflect this detail; I hope you don’t mind. I’m not too sure about how nextFetchPolicy should work with the skip option, so I might need to do some rereading of the docs for that option to see what’s up. I’ll also try to follow up on the issue you linked as it seems to be causing people a lot of frustration.

@smitpatel1010
Copy link
Author

Thanks @brainkim. I will also check if I can find any workaround or any relevant info in docs

@hwillson hwillson added the 🔍 investigate Investigate further label May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants