Is it correct to use cache.writeQuery and cache.readQuery? I found that this currently doesn't work for me (state doesn't get updated) and the documentation of Apollo notes:
The cache you created with new InMemoryCache(...) class is not meant to be used directly, but passed to the ApolloClient constructor. The client then accesses the cache using methods like readQuery and writeQuery. The difference between cache.writeQuery and client.writeQuery is that the client version also performs a broadcast after writing to the cache. This broadcast ensures your data is refreshed in the view layer after the client.writeQuery operation. If you only use cache.writeQuery, the changes may not be immediately reflected in the view layer. This behavior is sometimes useful in scenarios where you want to perform multiple cache writes without immediately updating the view layer.
I rather meant in the mutations inside the resolver. With client.writeQuery you can make sure, the data reactivity is triggered for sure while cache.writeQuery will possible not fire a data refresh in your UI if you change nested items. At least that's what I currently can reproduce.
I cannot reproduce this behavior and very own Apollo tutorials are also relying on cache.writeData and cache.writeQuery apollographql.com/docs/react/essen...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Is it correct to use
cache.writeQuery
andcache.readQuery
? I found that this currently doesn't work for me (state doesn't get updated) and the documentation of Apollo notes:apollographql.com/docs/react/advan...
I fixed it in the article: we use writeData, not writeQuery ;)
I rather meant in the mutations inside the resolver. With client.writeQuery you can make sure, the data reactivity is triggered for sure while cache.writeQuery will possible not fire a data refresh in your UI if you change nested items. At least that's what I currently can reproduce.
I cannot reproduce this behavior and very own Apollo tutorials are also relying on
cache.writeData
andcache.writeQuery
apollographql.com/docs/react/essen...