Skip to content

Commit

Permalink
Merge pull request #3644 from apollographql/hwillson/issue-2522
Browse files Browse the repository at this point in the history
Address mutation doc issues
  • Loading branch information
hwillson authored Jul 3, 2018
2 parents 5162b58 + c93dcf7 commit 1d67b43
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/source/api/react-apollo.md
Original file line number Diff line number Diff line change
Expand Up @@ -1090,14 +1090,20 @@ export default graphql(gql`

This option allows you to update your store based on your mutation’s result. By default Apollo Client will update all of the overlapping nodes in your store. Anything that shares the same id as returned by the `dataIdFromObject` you defined will be updated with the new fields from your mutation results. However, sometimes this alone is not sufficient. Sometimes you may want to update your cache in a way that is dependent on the data currently in your cache. For these updates you may use an `options.update` function.

`options.update` takes two arguments. The first is an instance of a [`DataProxy`][] object which has some methods which will allow you to interact with the data in your store. The second is the response from your mutation - either the optimistic response, or the actual response returned by your server.
`options.update` takes two arguments. The first is an instance of a [`DataProxy`][] object which has some methods which will allow you to interact with the data in your store. The second is the response from your mutation - either the optimistic response, or the actual response returned by your server (see the mutation result described in the [mutation render prop](./react-apollo.html#mutation-render-prop) section for more details).

In order to change the data in your store call methods on your [`DataProxy`][] instance like [`writeQuery`][] and [`writeFragment`][]. This will update your cache and reactively re-render any of your GraphQL components which are querying affected data.

To read the data from the store that you are changing, make sure to use methods on your [`DataProxy`][] like [`readQuery`][] and [`readFragment`][].

For more information on updating your cache after a mutation with the `options.update` function make sure to read the [Apollo Client technical documentation on the subject](../advanced/caching.html#updating-the-cache-after-a-mutation).

[`DataProxy`]: ../advanced/caching.html#direct
[`writeQuery`]: ../advanced/caching.html#writequery-and-writefragment
[`writeFragment`]: ../advanced/caching.html#writequery-and-writefragment
[`readQuery`]: ../advanced/caching.html#readquery
[`readFragment`]: ../advanced/caching.html#readfragment

**Example:**

```js
Expand Down

0 comments on commit 1d67b43

Please sign in to comment.