-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
fetchMore
from useLazyQuery
doesn't include cache changes?
#11276
Comments
Hi @mbiggs-gresham 👋🏻 thanks for opening this Issue! Your configuration of |
As a follow-up, please note that fetchMore({ variables: { id: 0, cursor: 100 }}).then(() => {
console.log(data); // don't use the locally scoped `data` argument
}); The promise returned by |
Hi, thanks for the response. That's exactly the problem, the local data given to the |
Thanks for the feedback! We don't recommend using the resolved promise value as the source of truth in your application - all the examples in the docs show the |
That's interesting, I didn't realise that. We were using the promises because we had some quite complex logic that could be triggered by various user interactions. We also have quite a few However, taking your advice, i've refactored our app to do as you say and use the global I think the |
I'm using
useLazyQuery
and manually fetching the data using a promise. I also have myInMemoryCache
configured so that as more data arrives, it merges it and it also replaces some of the child objects such as dates etc with DayJS objects instead.The
data
returned to the initialfetchRows
Promise includes the modified version with the changes made within the cache. Thedata
passed to the Promise of thefetchMore
however only has the last batch of rows and none of the sub objects are replaced. It only seems to give the latest set of data exactly as received via the network.If i console log the
data
from theuseLazyQuery
hook it always includes the correctly modified changes from the cache (original batch plus new batch plus all child objects correctly swapped).ps) I'm not actually calling them sequentially like this, they are being called at the appropriate times via events. I've just listed it like this for simplicity. I'm also use
keyArgs: ['id']
.Why does the
fetchMore
not give the modified cache versions?I'm using apollo-client v3.8.5.
The text was updated successfully, but these errors were encountered: