You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** canonical reference of the DocBlock to include. */
59
59
canonicalReference: string;
60
+
/** can be used to override the heading, which would usually just be the name of the function. This is useful if the interface name only makes sense in the context of a class, such as `client.refetchResult` or `ApolloClient.refetchResult` instead of `refetchResult`, which would be too generic */
61
+
displayName?: string;
60
62
/** describes the nesting depth of the main heading for the markdown generated by this codeblock */
61
63
headingLevel: number;
62
64
/** can be set to `false` to hide the result and parameters sections in the generated Docs page - this is useful if the parameters are not well documented */
Copy file name to clipboardExpand all lines: docs/source/data/refetching.mdx
+16-58Lines changed: 16 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
title: Refetching queries in Apollo Client
3
3
---
4
4
5
+
{/**@import {MDXProvidedComponents} from '../../shared/MdxProvidedComponents.js' */}
5
6
6
7
Apollo Client allows you to make local modifications to your GraphQL data by [updating the cache](./mutations/#updating-the-cache-directly), but sometimes it's more straightforward to update your client-side GraphQL data by refetching queries from the server.
7
8
@@ -13,73 +14,30 @@ Refetching is especially common after a mutation, so [mutate functions](./mutati
13
14
14
15
To selectively refetch queries _outside_ of a mutation, you instead use the `refetchQueries` method of `ApolloClient`, which is documented here.
The `client.refetchQueries` method collects the `TResult` results returned by `onQueryUpdated`, defaulting to `TResult = Promise<ApolloQueryResult<any>>` if `onQueryUpdated` is not provided. It combines those results into a single `Promise<TResolved[]>` using `Promise.all(results)`.
30
24
31
-
> Thanks to the `Promise`-unwrapping behavior of `Promise.all`, this `TResolved` type is often the same type as `TResult`, except when `TResult` is a `PromiseLike<TResolved>` or a `boolean`.
25
+
<Note>
26
+
Thanks to the `Promise`-unwrapping behavior of `Promise.all`, this `TResolved` type is often the same type as `TResult`, except when `TResult` is a `PromiseLike<TResolved>` or a `boolean`.
27
+
</Note>
32
28
33
29
The returned `Promise` object has two other useful properties:
34
30
35
-
<tableclass="field-table api-ref">
36
-
<thead>
37
-
<tr>
38
-
<th>Name /<br/>Type</th>
39
-
<th>Description</th>
40
-
</tr>
41
-
</thead>
42
-
<tbody>
43
-
44
-
<tr>
45
-
<td>
46
-
47
-
###### `queries`
48
-
49
-
`ObservableQuery[]`
50
-
</td>
51
-
52
-
<td>
53
-
54
-
An array of `ObservableQuery` objects that were refetched.
55
-
56
-
</td>
57
-
</tr>
58
-
59
-
<tr>
60
-
<td>
61
-
62
-
###### `results`
63
-
64
-
`TResult[]`
65
-
</td>
66
-
67
-
<td>
68
-
69
-
An array of results that were either returned by `onQueryUpdated`, or provided by default in the absence of `onQueryUpdated`, including pending promises.
70
-
71
-
If `onQueryUpdated` returns `false` for a given query, no result is provided for that query.
72
-
73
-
If `onQueryUpdated` returns `true`, the resulting `Promise<ApolloQueryResult<any>>` is included in the `results` array instead of `true`.
These two arrays parallel each other: they have the same length, and `results[i]` is the result produced by `onQueryUpdated` when called with the `ObservableQuery` found at `queries[i]`, for any index `i`.
* An array of ObservableQuery objects corresponding 1:1 to TResult values
288
+
* in the results arrays (both the `result` property and the resolved value).
289
+
*/
290
+
queries: ObservableQuery<any>[];
291
+
/**
292
+
* An array of results that were either returned by `onQueryUpdated`, or provided by default in the absence of `onQueryUpdated`, including pending promises.
293
+
*
294
+
* If `onQueryUpdated` returns `false` for a given query, no result is provided for that query.
295
+
*
296
+
* If `onQueryUpdated` returns `true`, the resulting `Promise<ApolloQueryResult<any>>` is included in the `results` array instead of `true`.
0 commit comments