Apollo-client: Update misleading `cache.writeData` docs

Created on 1 Feb 2019  路  4Comments  路  Source: apollographql/apollo-client

See https://github.com/apollographql/apollo-client/issues/2415#issuecomment-459732038 for the full discussion.

TL;DR - we need to clarify the differences between client.writeQuery and cache.writeQuery somewhere in the docs, so people are aware of the fact that client.writeQuery leads to watched queries being re-broadcast, whereas cache.writeQuery does not (well, does not always - it does under certain circumstances like when using client.mutate's update option, but not when just calling cache.writeQuery by itself).

馃摑 documentation 馃檹 help-wanted

Most helpful comment

is cache.readQuery and client.readQuery the same or is there any difference like there is with writing ?

Also in the new docs it says, This behavior is sometimes useful in scenarios where you want to perform multiple cache writes without immediately updating the view layer
so if I want to make multiple updates and then update the view layer, what would be the best way to do that?

All 4 comments

3909 seems pretty much related and this issue should be prioritized IMHO.

I can take this up. We have used cache.readQuery and cache.writeQuery for our project at different places. This was used keeping in mind that we didn't want a re-render or a network call. I need to think of a small/relatable example and send a PR.
Should I go ahead with it @hwillson ? Anything else, I should be wary of?

@tanaypratap Yes please, that would be awesome! As long as the doc changes cover the differences between client/cache writeQuery, then we should be good to go. Thanks!

is cache.readQuery and client.readQuery the same or is there any difference like there is with writing ?

Also in the new docs it says, This behavior is sometimes useful in scenarios where you want to perform multiple cache writes without immediately updating the view layer
so if I want to make multiple updates and then update the view layer, what would be the best way to do that?

Was this page helpful?
0 / 5 - 0 ratings