Skip to content

Commit

Permalink
Update existing mentions of cache.modify in docs.
Browse files Browse the repository at this point in the history
We will definitely need more documentation about cache.modify after
reverting PR #6289, but in the meantime the existing documentation should
not be blatantly incorrect.
  • Loading branch information
benjamn committed May 28, 2020
1 parent 07f2af9 commit bc0c50c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/source/data/local-state.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ const client = new ApolloClient({
resolvers: {
Mutation: {
toggleTodo: (_root, variables, { cache }) => {
const id = cache.identify({
__typename: 'TodoItem',
id: variables.id,
});
cache.modify(id, {
completed(value) {
return !value;
cache.modify({
id: cache.identify({
__typename: 'TodoItem',
id: variables.id,
}),
modifiers: {
completed: value => !value,
},
});
return null;
Expand Down Expand Up @@ -1095,7 +1095,7 @@ const client = new ApolloClient({
};
```
The `cache.writeQuery` and `cache.writeFragment` methods should cover most of your needs; however, there are some cases where the data you're writing to the cache depends on the data that's already there. In that scenario, you should use `cache.modify(id, modifiers)` to update specific fields within the entity object identified by `id`.
The `cache.writeQuery` and `cache.writeFragment` methods should cover most of your needs; however, there are some cases where the data you're writing to the cache depends on the data that's already there. In that scenario, you can either use a combination of `cache.read{Query,Fragment}` followed by `cache.write{Query,Fragment}`, or use `cache.modify({ id, modifiers })` to update specific fields within the entity object identified by `id`.
### writeQuery and readQuery
Expand Down

0 comments on commit bc0c50c

Please sign in to comment.