-
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
Update the cache of Apollo client 3 when polling not working #7115
Comments
I have almost the exact same issue. In my case, the optimistic update is of an existing record in the cache. The optimistic update succeeds, verified in the UI. When the refetch (on a polling interval) comes back, I can see in the network tab that the data is different than the cached (displayed) data. Yet there is no update of the cache. I've attempted each of the |
I ran into this same issue today. Polling is being called as verified in the Network tab - but the UI will not refresh. *Edit: I polling works fine and UI updates are also working as expected. I realized the issue was using React Table component which memoized the state to decrease renders. This prevented the UI from updating as it should so for future viewers, if your network tab is updating its likely a component issue. |
I run into the same issue. |
Intended outcome:
I am playing with the cache of
@apollo/client
v3. codesandboxI am adding a user to a cached list of users using
client.writeQuery
, and the query has apollInterval
to refetch every few seconds.I am able to add the user to the list, it does refresh the UI, and I can see the pollInterval working in the
network
tab of Chrome.THE PROBLEM
I would expect the list of users to return to its initial state when the polling kicks in, and overwrite the user I added manually to the cache, but it does not.
Apollo config
UserList
useUserList
How to reproduce the issue:
codesandbox
Just click on the button. It will add a user. The polling works but it won't overwrite the cache to remove the newly added user.
Versions
System:
OS: Windows 10 10.0.18363
Binaries:
Node: 12.18.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.21.1 - D:\code\schedio\web\node_modules.bin\yarn.CMD
npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.18362.449.0)
npmPackages:
@apollo/client: ^3.2.2 => 3.2.2
The text was updated successfully, but these errors were encountered: