[2.0] old data after mutation | bug
See original GitHub issueHi, I have next query
query getMini($id: ID!) {
mini(id: $id) {
id
cover(maxWidth: 600, maxHeight: 400)
}
}
and next mutation
mutation ($signature: String!) {
mini: submitMiniCoverS3DirectUpload(signature: $signature) {
id
cover(maxWidth: 600, maxHeight: 400)
}
}
as you can see after success mutation I will get new cover photo. So far so good. Everything is working fine with apolo 1.x. In apollo 2 I will get same cached cover photo after mutation. I checked response from server. There are valid new fields. But apollo is using old cached data.
I am using latest versions of all libraries:
"apollo-cache-inmemory": "^0.2.0-rc.1",
"apollo-client": "^2.0.0-rc.3",
"apollo-link": "^0.8.0",
"apollo-link-http": "^0.8.0",
"apollo-link-batch-http": "^0.4.0",
"apollo-link-retry": "^0.8.0",
"apollo-link-dedup": "^0.6.0",
I think that this is related also to last comment https://github.com/apollographql/apollo-client/issues/2266#issuecomment-335933377.
FYI: fetchPolicy: ‘network-only’ is not working
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:25 (18 by maintainers)
Top Results From Across the Web
Mutations in Apollo Client - Apollo GraphQL Docs
This article demonstrates how to send updates to your GraphQL server with the useMutation hook. You'll also learn how to update the Apollo...
Read more >Apollo Client mutation error and updating components
If the mutation was successful, the component's data is updated using the proxy param, but I can't see an equivalent way of dealing...
Read more >How to update the Apollo Client's cache after a mutation
writeQuery({ query, variables: { published: true }, data }); } catch(error) { console.error(error); }},. That's it. While this use case is ...
Read more >React Query mutating data - Daily Dev Tips
How to manually update React Query cache with useMutation ... can return the old data, and we then merge the old data with...
Read more >Announcing SWR 2.0
Announcing SWR 2.0: new mutation APIs and improvd optimistic UI capabilities, ... request returns us the latest data from the server, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think that this is related to https://github.com/apollographql/react-apollo/issues/1257#issuecomment-338184744 as well.
So, I got 2 queries and 1 mutation:
When I update an existing item (inside a modal that closes after save, so unmounting), I’m getting the new values returned from the mutation and the list immediately updates accordingly (so far everything good). But when I reopen the item/modal, it has the old values. As soon as the list polling interval kicks in, the modal immediately shows the correct values.
fixed by rc7