You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
First of all, I've used this library extensively for last week and I want to thank for your hard work. It works great!
Secondly, I've used apollo client with react, react native and vue so I'd like to ask about cache update logic OR report a bug if it's a design flow. Here is an example:
Page A
-- Query (messages)
Page B
-- Mutation (addMessage)
--- Use update() callback in Mutation widget. Update "messages" cache and run cache.save()
This scenario works fine 👍 Let's skip to second scenario
Page A
-- Query (messages)
Page B
-- receive an event (e.g. push notification with data)
-- Update "messages" cache and run cache.save()
In this case, I would expect the Query in "Page A" to be updated but it's not. 👎 I've spent almost two days to understand what's wrong.
After digging code, it turns out there is also a local snapshot for every Query widget.
If I change the cache externally, a local snapshot from AsyncSnapshot will not be updated.
I realized snapshot is only updated with Mutation callbacks: update, onError and onCompleted
If I want to update a Query snapshot externally, I manually force cache update with client.queryManager.rebroadcastQueries()
This was my aha moment.
Is this a design choice? I believe, rebroadcastQueries should run after ever cache.write().
Correct?
The text was updated successfully, but these errors were encountered:
Hello,
First of all, I've used this library extensively for last week and I want to thank for your hard work. It works great!
Secondly, I've used apollo client with react, react native and vue so I'd like to ask about cache update logic OR report a bug if it's a design flow. Here is an example:
Page A
-- Query (messages)
Page B
-- Mutation (addMessage)
--- Use
update()
callback in Mutation widget. Update "messages" cache and runcache.save()
This scenario works fine 👍 Let's skip to second scenario
Page A
-- Query (messages)
Page B
-- receive an event (e.g. push notification with data)
-- Update "messages" cache and run
cache.save()
In this case, I would expect the
Query
in "Page A" to be updated but it's not. 👎 I've spent almost two days to understand what's wrong.After digging code, it turns out there is also a local snapshot for every
Query
widget.If I change the cache externally, a local snapshot from AsyncSnapshot will not be updated.
I realized snapshot is only updated with
Mutation
callbacks:update
,onError
andonCompleted
If I want to update a
Query
snapshot externally, I manually force cache update withclient.queryManager.rebroadcastQueries()
This was my aha moment.
Is this a design choice? I believe,
rebroadcastQueries
should run after evercache.write()
.Correct?
The text was updated successfully, but these errors were encountered: