-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Inconsistent cache result's when two or more component calls to useLazyQuery with the same query #7923
Comments
Hi! Thank you for opening this issue, and thank you for providing a runnable code example. Unfortunately, I’m having a bit of trouble wrapping my head around your code. Firstly, you’re writing an Finally, can you rephrase this part:
What do you expect to see on the screen? Do you want the queries to run independently? Do you expect the lists to be concatenated? I might need a little bit of help understanding this part, and am very sorry if I’m missing the point of your example 😓 As always, thanks for reaching out, and I’m happy to go back and forth until we figure this out. I’ll leave your code on my computer for now so I can jump back in and try things out when you get a chance to respond 😊 |
First of all, sorry. I played around with it to check how I can fixed in my proyect. Let me create a fork just with the error to prevent misunderstanding. https://codesandbox.io/s/uselazyqueryissue-forked-1wv4c?file=/src/App.jsx In simple words, the issue is that the cache is not updating. I was create other component and a hook (Wrapper and useApplyWrapper) that only put this on top of the tree and share the exactly same function to each component that case, solve the error. |
Intended outcome:
The cache should be shared between two instances of
useLazyQuery
that use the exact same parameters. If we create an abstraction ofuseLazyQuery
each component that uses it should have the same expected behavior (fetching to graphql or returning cache results).Abstraction sample
Actual outcome:
If you use the abstraction into 2 components and show the store list into another component. You will have mismatched between the results. Every time that call to graphql will work but when you try to load the result from cached 2 times it will return all time the first
How to reproduce the issue:
Steps to reproduce it:
Codesandbox: https://codesandbox.io/s/uselazyqueryissue-forked-1wv4c?file=/src/App.jsx
I create a small store using React.Context and try to save on the store each result. And an effect to watch for data changes because
onComplete
doesn't dispatch on cache resultsVersions
The text was updated successfully, but these errors were encountered: