Skip to content
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

Clarify that the result of readQuery should not be modified #4815

Merged
merged 2 commits into from
May 20, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/advanced/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ const { todo } = client.readQuery({
});
```

Note that you should not modify the return value of `readQuery` because the same object may be reused between components. If you want to update the data in the cache, create a new replacement object and pass it to `writeQuery`.

<h3 id="readfragment">readFragment</h3>

This method allows you great flexibility around the data in your cache. Whereas `readQuery` only allowed you to read data from your root query type, `readFragment` allows you to read data from _any node you have queried_. This is incredibly powerful. You use this method as follows:
Expand Down