Skip to content

Commit

Permalink
Merge pull request #3750 from apollographql/hwillson/await-refetch-do…
Browse files Browse the repository at this point in the history
…c-updates

Add `react-apollo` `awaitRefetchQueries` docs
  • Loading branch information
hwillson authored Jul 27, 2018
2 parents e25c1ca + e691fe7 commit edc6194
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/source/api/react-apollo.md
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,11 @@ export default graphql(gql`mutation { ... }`, {
})(MyComponent);
```

Please note that refetched queries are handled asynchronously, and by default are not necessarily completed before the mutation has completed. If you want to make sure refetched queries are completed before the mutation is considered done (or resolved), set [`options.awaitRefetchQueries`](#graphql-mutation-options-awaitRefetchQueries) to `true`.

<h3 id="graphql-mutation-options-awaitRefetchQueries">`options.awaitRefetchQueries`</h3>

Queries refetched using [`options.refetchQueries`](#graphql-mutation-options-refetchQueries) are handled asynchronously, which means by default they are not necessarily completed before the mutation has completed. Setting `options.awaitRefetchQueries` to `true` will make sure refetched queries are completed before the mutation is considered done (or resolved). `options.awaitRefetchQueries` is `false` by default.

<h3 id="graphql-mutation-options-updateQueries">`options.updateQueries`</h3>

Expand Down
2 changes: 2 additions & 0 deletions docs/source/essentials/mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ The Mutation component accepts the following props. Only `mutation` and `childre
<dd>Provide a [mutation response](../features/optimistic-ui.html) before the result comes back from the server</dd>
<dt>`refetchQueries`: (mutationResult: FetchResult) => Array<{ query: DocumentNode, variables?: TVariables}></dt>
<dd>A function that allows you to specify which queries you want to refetch after a mutation has occurred</dd>
<dt>`awaitRefetchQueries`: boolean</dt>
<dd>Queries refetched as part of `refetchQueries` are handled asynchronously, and are not waited on before the mutation is completed (resolved). Setting this to `true` will make sure refetched queries are completed before the mutation is considered done. `false` by default.</dd>
<dt>`onCompleted`: (data: TData) => void</dt>
<dd>A callback executed once your mutation successfully completes</dd>
<dt>`onError`: (error: ApolloError) => void</dt>
Expand Down

0 comments on commit edc6194

Please sign in to comment.