@apollo/client 3.9.0-rc.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +158 -170
  2. package/README.md +4 -0
  3. package/apollo-client.cjs +3 -2
  4. package/apollo-client.cjs.map +1 -1
  5. package/apollo-client.min.cjs +1 -1
  6. package/cache/core/types/DataProxy.d.ts +8 -16
  7. package/cache/core/types/DataProxy.js.map +1 -1
  8. package/cache/inmemory/types.d.ts +0 -1
  9. package/cache/inmemory/types.js.map +1 -1
  10. package/cache/inmemory/writeToStore.js.map +1 -1
  11. package/core/ApolloClient.d.ts +6 -1
  12. package/core/ApolloClient.js.map +1 -1
  13. package/core/ObservableQuery.d.ts +22 -0
  14. package/core/ObservableQuery.js +22 -0
  15. package/core/ObservableQuery.js.map +1 -1
  16. package/core/core.cjs +1 -1
  17. package/core/core.cjs.map +1 -1
  18. package/core/core.cjs.native.js +1 -1
  19. package/core/types.d.ts +5 -2
  20. package/core/types.js.map +1 -1
  21. package/core/watchQueryOptions.d.ts +258 -128
  22. package/core/watchQueryOptions.js.map +1 -1
  23. package/dev/dev.cjs +2 -2
  24. package/dev/dev.cjs.map +1 -1
  25. package/dev/dev.cjs.native.js +2 -2
  26. package/invariantErrorCodes.js +1 -1
  27. package/package.json +18 -18
  28. package/react/components/types.d.ts +3 -0
  29. package/react/components/types.js.map +1 -1
  30. package/react/hooks/hooks.cjs.map +1 -1
  31. package/react/hooks/useApolloClient.d.ts +15 -0
  32. package/react/hooks/useApolloClient.js +15 -0
  33. package/react/hooks/useApolloClient.js.map +1 -1
  34. package/react/hooks/useLazyQuery.d.ts +35 -0
  35. package/react/hooks/useLazyQuery.js +35 -0
  36. package/react/hooks/useLazyQuery.js.map +1 -1
  37. package/react/hooks/useLoadableQuery.d.ts +69 -2
  38. package/react/hooks/useLoadableQuery.js.map +1 -1
  39. package/react/hooks/useMutation.d.ts +47 -0
  40. package/react/hooks/useMutation.js +47 -0
  41. package/react/hooks/useMutation.js.map +1 -1
  42. package/react/hooks/useQuery.d.ts +34 -0
  43. package/react/hooks/useQuery.js +34 -0
  44. package/react/hooks/useQuery.js.map +1 -1
  45. package/react/hooks/useQueryRefHandlers.d.ts +5 -4
  46. package/react/hooks/useQueryRefHandlers.js +1 -1
  47. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  48. package/react/hooks/useReactiveVar.d.ts +17 -0
  49. package/react/hooks/useReactiveVar.js +17 -0
  50. package/react/hooks/useReactiveVar.js.map +1 -1
  51. package/react/hooks/useSubscription.d.ts +85 -0
  52. package/react/hooks/useSubscription.js +85 -0
  53. package/react/hooks/useSubscription.js.map +1 -1
  54. package/react/internal/cache/QueryReference.d.ts +39 -0
  55. package/react/internal/cache/QueryReference.js +2 -1
  56. package/react/internal/cache/QueryReference.js.map +1 -1
  57. package/react/internal/internal.cjs +2 -1
  58. package/react/internal/internal.cjs.map +1 -1
  59. package/react/internal/internal.cjs.native.js +2 -1
  60. package/react/query-preloader/createQueryPreloader.d.ts +84 -52
  61. package/react/query-preloader/createQueryPreloader.js +5 -2
  62. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  63. package/react/react.cjs.map +1 -1
  64. package/react/types/types.d.ts +552 -57
  65. package/react/types/types.documentation.d.ts +559 -0
  66. package/react/types/types.documentation.js +2 -0
  67. package/react/types/types.documentation.js.map +1 -0
  68. package/react/types/types.js.map +1 -1
  69. package/utilities/globals/globals.cjs +1 -1
  70. package/utilities/globals/globals.cjs.map +1 -1
  71. package/utilities/globals/globals.cjs.native.js +1 -1
  72. package/utilities/graphql/DocumentTransform.d.ts +12 -0
  73. package/utilities/graphql/DocumentTransform.js.map +1 -1
  74. package/version.js +1 -1
  75. package/.changeset/beige-geese-wink.md +0 -5
  76. package/.changeset/breezy-spiders-tap.md +0 -38
  77. package/.changeset/chatty-comics-yawn.md +0 -8
  78. package/.changeset/clean-items-smash.md +0 -5
  79. package/.changeset/cold-llamas-turn.md +0 -8
  80. package/.changeset/curvy-seas-hope.md +0 -13
  81. package/.changeset/dirty-kids-crash.md +0 -5
  82. package/.changeset/dirty-tigers-matter.md +0 -13
  83. package/.changeset/forty-cups-shop.md +0 -5
  84. package/.changeset/friendly-clouds-laugh.md +0 -7
  85. package/.changeset/hot-ducks-burn.md +0 -5
  86. package/.changeset/late-rabbits-protect.md +0 -7
  87. package/.changeset/mighty-coats-check.md +0 -47
  88. package/.changeset/pink-apricots-yawn.md +0 -5
  89. package/.changeset/polite-avocados-warn.md +0 -5
  90. package/.changeset/pre.json +0 -44
  91. package/.changeset/quick-hats-marry.md +0 -5
  92. package/.changeset/rare-snakes-melt.md +0 -24
  93. package/.changeset/shaggy-ears-scream.md +0 -5
  94. package/.changeset/shaggy-sheep-pull.md +0 -5
  95. package/.changeset/sixty-boxes-rest.md +0 -8
  96. package/.changeset/smooth-plums-shout.md +0 -5
  97. package/.changeset/sour-sheep-walk.md +0 -7
  98. package/.changeset/spicy-drinks-camp.md +0 -5
  99. package/.changeset/strong-terms-perform.md +0 -46
  100. package/.changeset/swift-zoos-collect.md +0 -19
  101. package/.changeset/thick-mice-collect.md +0 -5
  102. package/.changeset/thick-tips-cry.md +0 -9
  103. package/.changeset/thirty-ties-arrive.md +0 -26
  104. package/.changeset/tough-timers-begin.md +0 -8
  105. package/.changeset/unlucky-rats-decide.md +0 -5
  106. package/.changeset/violet-lions-draw.md +0 -5
  107. package/.changeset/wet-forks-rhyme.md +0 -5
  108. package/.changeset/wild-dolphins-jog.md +0 -5
  109. package/.changeset/wise-news-grab.md +0 -7
  110. package/.changeset/yellow-flies-repeat.md +0 -5
@@ -0,0 +1,559 @@
1
+ export interface QueryOptionsDocumentation {
2
+ /**
3
+ * A GraphQL query string parsed into an AST with the gql template literal.
4
+ *
5
+ * @docGroup 1. Operation options
6
+ */
7
+ query: unknown;
8
+ /**
9
+ * An object containing all of the GraphQL variables your query requires to execute.
10
+ *
11
+ * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.
12
+ *
13
+ * @docGroup 1. Operation options
14
+ */
15
+ variables: unknown;
16
+ /**
17
+ * Specifies how the query handles a response that returns both GraphQL errors and partial results.
18
+ *
19
+ * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).
20
+ *
21
+ * The default value is `none`, meaning that the query result includes error details but not partial results.
22
+ *
23
+ * @docGroup 1. Operation options
24
+ */
25
+ errorPolicy: unknown;
26
+ /**
27
+ * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.
28
+ *
29
+ * @docGroup 2. Networking options
30
+ */
31
+ context: unknown;
32
+ /**
33
+ * Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).
34
+ *
35
+ * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).
36
+ *
37
+ * The default value is `cache-first`.
38
+ *
39
+ * @docGroup 3. Caching options
40
+ */
41
+ fetchPolicy: unknown;
42
+ /**
43
+ * Specifies the {@link FetchPolicy} to be used after this query has completed.
44
+ *
45
+ * @docGroup 3. Caching options
46
+ */
47
+ nextFetchPolicy: unknown;
48
+ /**
49
+ * Defaults to the initial value of options.fetchPolicy, but can be explicitly
50
+ * configured to specify the WatchQueryFetchPolicy to revert back to whenever
51
+ * variables change (unless nextFetchPolicy intervenes).
52
+ *
53
+ * @docGroup 3. Caching options
54
+ */
55
+ initialFetchPolicy: unknown;
56
+ /**
57
+ * Specifies the interval (in milliseconds) at which the query polls for updated results.
58
+ *
59
+ * The default value is `0` (no polling).
60
+ *
61
+ * @docGroup 2. Networking options
62
+ */
63
+ pollInterval: unknown;
64
+ /**
65
+ * If `true`, the in-progress query's associated component re-renders whenever the network status changes or a network error occurs.
66
+ *
67
+ * The default value is `false`.
68
+ *
69
+ * @docGroup 2. Networking options
70
+ */
71
+ notifyOnNetworkStatusChange: unknown;
72
+ /**
73
+ * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.
74
+ *
75
+ * The default value is `false`.
76
+ *
77
+ * @docGroup 3. Caching options
78
+ */
79
+ returnPartialData: unknown;
80
+ /**
81
+ * Specifies whether a `NetworkStatus.refetch` operation should merge
82
+ * incoming field data with existing data, or overwrite the existing data.
83
+ * Overwriting is probably preferable, but merging is currently the default
84
+ * behavior, for backwards compatibility with Apollo Client 3.x.
85
+ *
86
+ * @docGroup 3. Caching options
87
+ */
88
+ refetchWritePolicy: unknown;
89
+ /**
90
+ * Watched queries must opt into overwriting existing data on refetch, by passing refetchWritePolicy: "overwrite" in their WatchQueryOptions.
91
+ *
92
+ * The default value is "overwrite".
93
+ *
94
+ * @docGroup 3. Caching options
95
+ */
96
+ refetchWritePolicy_suspense: unknown;
97
+ /**
98
+ * If `true`, causes a query refetch if the query result is detected as partial.
99
+ *
100
+ * The default value is `false`.
101
+ *
102
+ * @deprecated
103
+ * Setting this option is unnecessary in Apollo Client 3, thanks to a more consistent application of fetch policies. It might be removed in a future release.
104
+ */
105
+ partialRefetch: unknown;
106
+ /**
107
+ * Whether to canonize cache results before returning them. Canonization
108
+ * takes some extra time, but it speeds up future deep equality comparisons.
109
+ * Defaults to false.
110
+ *
111
+ * @deprecated
112
+ * Using `canonizeResults` can result in memory leaks so we generally do not
113
+ * recommend using this option anymore.
114
+ * A future version of Apollo Client will contain a similar feature without
115
+ * the risk of memory leaks.
116
+ */
117
+ canonizeResults: unknown;
118
+ /**
119
+ * If true, the query is not executed.
120
+ *
121
+ * The default value is `false`.
122
+ *
123
+ * @docGroup 1. Operation options
124
+ */
125
+ skip: unknown;
126
+ /**
127
+ * If `true`, the query is not executed. The default value is `false`.
128
+ *
129
+ * @deprecated We recommend using `skipToken` in place of the `skip` option as
130
+ * it is more type-safe.
131
+ *
132
+ * This option is deprecated and only supported to ease the migration from useQuery. It will be removed in a future release.
133
+ *
134
+ * @docGroup 1. Operation options
135
+ */
136
+ skip_deprecated: unknown;
137
+ /**
138
+ * A callback function that's called when your query successfully completes with zero errors (or if `errorPolicy` is `ignore` and partial data is returned).
139
+ *
140
+ * This function is passed the query's result `data`.
141
+ *
142
+ * @docGroup 1. Operation options
143
+ */
144
+ onCompleted: unknown;
145
+ /**
146
+ * A callback function that's called when the query encounters one or more errors (unless `errorPolicy` is `ignore`).
147
+ *
148
+ * This function is passed an `ApolloError` object that contains either a `networkError` object or a `graphQLErrors` array, depending on the error(s) that occurred.
149
+ *
150
+ * @docGroup 1. Operation options
151
+ */
152
+ onError: unknown;
153
+ /**
154
+ * The instance of {@link ApolloClient} to use to execute the query.
155
+ *
156
+ * By default, the instance that's passed down via context is used, but you
157
+ * can provide a different instance here.
158
+ *
159
+ * @docGroup 1. Operation options
160
+ */
161
+ client: unknown;
162
+ /**
163
+ * A unique identifier for the query. Each item in the array must be a stable
164
+ * identifier to prevent infinite fetches.
165
+ *
166
+ * This is useful when using the same query and variables combination in more
167
+ * than one component, otherwise the components may clobber each other. This
168
+ * can also be used to force the query to re-evaluate fresh.
169
+ *
170
+ * @docGroup 1. Operation options
171
+ */
172
+ queryKey: unknown;
173
+ /**
174
+ * Pass `false` to skip executing the query during [server-side rendering](https://www.apollographql.com/docs/react/performance/server-side-rendering/).
175
+ *
176
+ * @docGroup 2. Networking options
177
+ */
178
+ ssr: unknown;
179
+ /**
180
+ * A callback function that's called whenever a refetch attempt occurs
181
+ * while polling. If the function returns `true`, the refetch is
182
+ * skipped and not reattempted until the next poll interval.
183
+ *
184
+ * @docGroup 2. Networking options
185
+ */
186
+ skipPollAttempt: unknown;
187
+ }
188
+ export interface QueryResultDocumentation {
189
+ /**
190
+ * The instance of Apollo Client that executed the query.
191
+ * Can be useful for manually executing followup queries or writing data to the cache.
192
+ *
193
+ * @docGroup 2. Network info
194
+ */
195
+ client: unknown;
196
+ /**
197
+ * A reference to the internal `ObservableQuery` used by the hook.
198
+ */
199
+ observable: unknown;
200
+ /**
201
+ * An object containing the result of your GraphQL query after it completes.
202
+ *
203
+ * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
204
+ *
205
+ * @docGroup 1. Operation data
206
+ */
207
+ data: unknown;
208
+ /**
209
+ * An object containing the result from the most recent _previous_ execution of this query.
210
+ *
211
+ * This value is `undefined` if this is the query's first execution.
212
+ *
213
+ * @docGroup 1. Operation data
214
+ */
215
+ previousData: unknown;
216
+ /**
217
+ * If the query produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.
218
+ *
219
+ * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
220
+ *
221
+ * @docGroup 1. Operation data
222
+ */
223
+ error: unknown;
224
+ /**
225
+ * If `true`, the query is still in flight and results have not yet been returned.
226
+ *
227
+ * @docGroup 2. Network info
228
+ */
229
+ loading: unknown;
230
+ /**
231
+ * A number indicating the current network state of the query's associated request. [See possible values.](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/core/networkStatus.ts#L4)
232
+ *
233
+ * Used in conjunction with the [`notifyOnNetworkStatusChange`](#notifyonnetworkstatuschange) option.
234
+ *
235
+ * @docGroup 2. Network info
236
+ */
237
+ networkStatus: unknown;
238
+ /**
239
+ * If `true`, the associated lazy query has been executed.
240
+ *
241
+ * This field is only present on the result object returned by [`useLazyQuery`](/react/data/queries/#executing-queries-manually).
242
+ *
243
+ * @docGroup 2. Network info
244
+ */
245
+ called: unknown;
246
+ /**
247
+ * An object containing the variables that were provided for the query.
248
+ *
249
+ * @docGroup 1. Operation data
250
+ */
251
+ variables: unknown;
252
+ /**
253
+ * A function that enables you to re-execute the query, optionally passing in new `variables`.
254
+ *
255
+ * To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request).
256
+ *
257
+ * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).
258
+ *
259
+ * @docGroup 3. Helper functions
260
+ */
261
+ refetch: unknown;
262
+ /**
263
+ * A function that helps you fetch the next set of results for a [paginated list field](https://www.apollographql.com/docs/react/pagination/core-api/).
264
+ *
265
+ *
266
+ * @docGroup 3. Helper functions
267
+ */
268
+ fetchMore: unknown;
269
+ /**
270
+ * A function that instructs the query to begin re-executing at a specified interval (in milliseconds).
271
+ *
272
+ *
273
+ * @docGroup 3. Helper functions
274
+ */
275
+ startPolling: unknown;
276
+ /**
277
+ * A function that instructs the query to stop polling after a previous call to `startPolling`.
278
+ *
279
+ *
280
+ * @docGroup 3. Helper functions
281
+ */
282
+ stopPolling: unknown;
283
+ /**
284
+ * A function that enables you to execute a [subscription](https://www.apollographql.com/docs/react/data/subscriptions/), usually to subscribe to specific fields that were included in the query.
285
+ *
286
+ * This function returns _another_ function that you can call to terminate the subscription.
287
+ *
288
+ *
289
+ * @docGroup 3. Helper functions
290
+ */
291
+ subscribeToMore: unknown;
292
+ /**
293
+ * A function that enables you to update the query's cached result without executing a followup GraphQL operation.
294
+ *
295
+ * See [using updateQuery and updateFragment](https://www.apollographql.com/docs/react/caching/cache-interaction/#using-updatequery-and-updatefragment) for additional information.
296
+ *
297
+ *
298
+ * @docGroup 3. Helper functions
299
+ */
300
+ updateQuery: unknown;
301
+ }
302
+ export interface MutationOptionsDocumentation {
303
+ /**
304
+ * A GraphQL document, often created with `gql` from the `graphql-tag`
305
+ * package, that contains a single mutation inside of it.
306
+ *
307
+ * @docGroup 1. Operation options
308
+ */
309
+ mutation: unknown;
310
+ /**
311
+ * Provide `no-cache` if the mutation's result should _not_ be written to the Apollo Client cache.
312
+ *
313
+ * The default value is `network-only` (which means the result _is_ written to the cache).
314
+ *
315
+ * Unlike queries, mutations _do not_ support [fetch policies](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy) besides `network-only` and `no-cache`.
316
+ *
317
+ * @docGroup 3. Caching options
318
+ */
319
+ fetchPolicy: unknown;
320
+ /**
321
+ * To avoid retaining sensitive information from mutation root field
322
+ * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`
323
+ * fields from the cache after each mutation finishes. If you need this
324
+ * information to remain in the cache, you can prevent the removal by passing
325
+ * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are
326
+ * also passed to the mutation `update` function, so we recommend obtaining
327
+ * the results that way, rather than using this option, if possible.
328
+ */
329
+ keepRootFields: unknown;
330
+ /**
331
+ * By providing either an object or a callback function that, when invoked after
332
+ * a mutation, allows you to return optimistic data and optionally skip updates
333
+ * via the `IGNORE` sentinel object, Apollo Client caches this temporary
334
+ * (and potentially incorrect) response until the mutation completes, enabling
335
+ * more responsive UI updates.
336
+ *
337
+ * For more information, see [Optimistic mutation results](https://www.apollographql.com/docs/react/performance/optimistic-ui/).
338
+ *
339
+ * @docGroup 3. Caching options
340
+ */
341
+ optimisticResponse: unknown;
342
+ /**
343
+ * A {@link MutationQueryReducersMap}, which is map from query names to
344
+ * mutation query reducers. Briefly, this map defines how to incorporate the
345
+ * results of the mutation into the results of queries that are currently
346
+ * being watched by your application.
347
+ */
348
+ updateQueries: unknown;
349
+ /**
350
+ * An array (or a function that _returns_ an array) that specifies which queries you want to refetch after the mutation occurs.
351
+ *
352
+ * Each array value can be either:
353
+ *
354
+ * - An object containing the `query` to execute, along with any `variables`
355
+ *
356
+ * - A string indicating the operation name of the query to refetch
357
+ *
358
+ * @docGroup 1. Operation options
359
+ */
360
+ refetchQueries: unknown;
361
+ /**
362
+ * If `true`, makes sure all queries included in `refetchQueries` are completed before the mutation is considered complete.
363
+ *
364
+ * The default value is `false` (queries are refetched asynchronously).
365
+ *
366
+ * @docGroup 1. Operation options
367
+ */
368
+ awaitRefetchQueries: unknown;
369
+ /**
370
+ * A function used to update the Apollo Client cache after the mutation completes.
371
+ *
372
+ * For more information, see [Updating the cache after a mutation](https://www.apollographql.com/docs/react/data/mutations#updating-the-cache-after-a-mutation).
373
+ *
374
+ * @docGroup 3. Caching options
375
+ */
376
+ update: unknown;
377
+ /**
378
+ * Optional callback for intercepting queries whose cache data has been updated by the mutation, as well as any queries specified in the `refetchQueries: [...]` list passed to `client.mutate`.
379
+ *
380
+ * Returning a `Promise` from `onQueryUpdated` will cause the final mutation `Promise` to await the returned `Promise`. Returning `false` causes the query to be ignored.
381
+ *
382
+ * @docGroup 1. Operation options
383
+ */
384
+ onQueryUpdated: unknown;
385
+ /**
386
+ * Specifies how the mutation handles a response that returns both GraphQL errors and partial results.
387
+ *
388
+ * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).
389
+ *
390
+ * The default value is `none`, meaning that the mutation result includes error details but _not_ partial results.
391
+ *
392
+ * @docGroup 1. Operation options
393
+ */
394
+ errorPolicy: unknown;
395
+ /**
396
+ * An object containing all of the GraphQL variables your mutation requires to execute.
397
+ *
398
+ * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.
399
+ *
400
+ * @docGroup 1. Operation options
401
+ */
402
+ variables: unknown;
403
+ /**
404
+ * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.
405
+ *
406
+ * @docGroup 2. Networking options
407
+ */
408
+ context: unknown;
409
+ /**
410
+ * The instance of `ApolloClient` to use to execute the mutation.
411
+ *
412
+ * By default, the instance that's passed down via context is used, but you can provide a different instance here.
413
+ *
414
+ * @docGroup 2. Networking options
415
+ */
416
+ client: unknown;
417
+ /**
418
+ * If `true`, the in-progress mutation's associated component re-renders whenever the network status changes or a network error occurs.
419
+ *
420
+ * The default value is `false`.
421
+ *
422
+ * @docGroup 2. Networking options
423
+ */
424
+ notifyOnNetworkStatusChange: unknown;
425
+ /**
426
+ * A callback function that's called when your mutation successfully completes with zero errors (or if `errorPolicy` is `ignore` and partial data is returned).
427
+ *
428
+ * This function is passed the mutation's result `data` and any options passed to the mutation.
429
+ *
430
+ * @docGroup 1. Operation options
431
+ */
432
+ onCompleted: unknown;
433
+ /**
434
+ * A callback function that's called when the mutation encounters one or more errors (unless `errorPolicy` is `ignore`).
435
+ *
436
+ * This function is passed an [`ApolloError`](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/errors/index.ts#L36-L39) object that contains either a `networkError` object or a `graphQLErrors` array, depending on the error(s) that occurred, as well as any options passed the mutation.
437
+ *
438
+ * @docGroup 1. Operation options
439
+ */
440
+ onError: unknown;
441
+ /**
442
+ * If `true`, the mutation's `data` property is not updated with the mutation's result.
443
+ *
444
+ * The default value is `false`.
445
+ *
446
+ * @docGroup 1. Operation options
447
+ */
448
+ ignoreResults: unknown;
449
+ }
450
+ export interface MutationResultDocumentation {
451
+ /**
452
+ * The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.
453
+ */
454
+ data: unknown;
455
+ /**
456
+ * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.
457
+ *
458
+ * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
459
+ */
460
+ error: unknown;
461
+ /**
462
+ * If `true`, the mutation is currently in flight.
463
+ */
464
+ loading: unknown;
465
+ /**
466
+ * If `true`, the mutation's mutate function has been called.
467
+ */
468
+ called: unknown;
469
+ /**
470
+ * The instance of Apollo Client that executed the mutation.
471
+ *
472
+ * Can be useful for manually executing followup operations or writing data to the cache.
473
+ */
474
+ client: unknown;
475
+ /**
476
+ * A function that you can call to reset the mutation's result to its initial, uncalled state.
477
+ */
478
+ reset: unknown;
479
+ }
480
+ export interface SubscriptionOptionsDocumentation {
481
+ /**
482
+ * A GraphQL document, often created with `gql` from the `graphql-tag`
483
+ * package, that contains a single subscription inside of it.
484
+ */
485
+ query: unknown;
486
+ /**
487
+ * An object containing all of the variables your subscription needs to execute
488
+ */
489
+ variables: unknown;
490
+ /**
491
+ * Specifies the {@link ErrorPolicy} to be used for this operation
492
+ */
493
+ errorPolicy: unknown;
494
+ /**
495
+ * How you want your component to interact with the Apollo cache. For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).
496
+ */
497
+ fetchPolicy: unknown;
498
+ /**
499
+ * Determines if your subscription should be unsubscribed and subscribed again when an input to the hook (such as `subscription` or `variables`) changes.
500
+ */
501
+ shouldResubscribe: unknown;
502
+ /**
503
+ * An `ApolloClient` instance. By default `useSubscription` / `Subscription` uses the client passed down via context, but a different client can be passed in.
504
+ */
505
+ client: unknown;
506
+ /**
507
+ * Determines if the current subscription should be skipped. Useful if, for example, variables depend on previous queries and are not ready yet.
508
+ */
509
+ skip: unknown;
510
+ /**
511
+ * Shared context between your component and your network interface (Apollo Link).
512
+ */
513
+ context: unknown;
514
+ /**
515
+ * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component completes the subscription.
516
+ *
517
+ * @since 3.7.0
518
+ */
519
+ onComplete: unknown;
520
+ /**
521
+ * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `data`.
522
+ *
523
+ * @since 3.7.0
524
+ */
525
+ onData: unknown;
526
+ /**
527
+ * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `subscriptionData`.
528
+ *
529
+ * @deprecated Use `onData` instead
530
+ */
531
+ onSubscriptionData: unknown;
532
+ /**
533
+ * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives an error.
534
+ *
535
+ * @since 3.7.0
536
+ */
537
+ onError: unknown;
538
+ /**
539
+ * Allows the registration of a callback function that will be triggered when the `useSubscription` Hook / `Subscription` component completes the subscription.
540
+ *
541
+ * @deprecated Use `onComplete` instead
542
+ */
543
+ onSubscriptionComplete: unknown;
544
+ }
545
+ export interface SubscriptionResultDocumentation {
546
+ /**
547
+ * A boolean that indicates whether any initial data has been returned
548
+ */
549
+ loading: unknown;
550
+ /**
551
+ * An object containing the result of your GraphQL subscription. Defaults to an empty object.
552
+ */
553
+ data: unknown;
554
+ /**
555
+ * A runtime error with `graphQLErrors` and `networkError` properties
556
+ */
557
+ error: unknown;
558
+ }
559
+ //# sourceMappingURL=types.documentation.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.documentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.documentation.js","sourceRoot":"","sources":["../../../src/react/types/types.documentation.ts"],"names":[],"mappings":"","sourcesContent":["export interface QueryOptionsDocumentation {\n /**\n * A GraphQL query string parsed into an AST with the gql template literal.\n *\n * @docGroup 1. Operation options\n */\n query: unknown;\n\n /**\n * An object containing all of the GraphQL variables your query requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * Specifies how the query handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the query result includes error details but not partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).\n *\n * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n *\n * The default value is `cache-first`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * Specifies the {@link FetchPolicy} to be used after this query has completed.\n *\n * @docGroup 3. Caching options\n */\n nextFetchPolicy: unknown;\n\n /**\n * Defaults to the initial value of options.fetchPolicy, but can be explicitly\n * configured to specify the WatchQueryFetchPolicy to revert back to whenever\n * variables change (unless nextFetchPolicy intervenes).\n *\n * @docGroup 3. Caching options\n */\n initialFetchPolicy: unknown;\n\n /**\n * Specifies the interval (in milliseconds) at which the query polls for updated results.\n *\n * The default value is `0` (no polling).\n *\n * @docGroup 2. Networking options\n */\n pollInterval: unknown;\n\n /**\n * If `true`, the in-progress query's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `false`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n\n /**\n * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.\n *\n * The default value is `false`.\n *\n * @docGroup 3. Caching options\n */\n returnPartialData: unknown;\n\n /**\n * Specifies whether a `NetworkStatus.refetch` operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy: unknown;\n\n /**\n * Watched queries must opt into overwriting existing data on refetch, by passing refetchWritePolicy: \"overwrite\" in their WatchQueryOptions.\n *\n * The default value is \"overwrite\".\n *\n * @docGroup 3. Caching options\n */\n refetchWritePolicy_suspense: unknown;\n\n /**\n * If `true`, causes a query refetch if the query result is detected as partial.\n *\n * The default value is `false`.\n *\n * @deprecated\n * Setting this option is unnecessary in Apollo Client 3, thanks to a more consistent application of fetch policies. It might be removed in a future release.\n */\n partialRefetch: unknown;\n\n /**\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n *\n * @deprecated\n * Using `canonizeResults` can result in memory leaks so we generally do not\n * recommend using this option anymore.\n * A future version of Apollo Client will contain a similar feature without\n * the risk of memory leaks.\n */\n canonizeResults: unknown;\n\n /**\n * If true, the query is not executed.\n *\n * The default value is `false`.\n *\n * @docGroup 1. Operation options\n */\n skip: unknown;\n\n /**\n * If `true`, the query is not executed. The default value is `false`.\n *\n * @deprecated We recommend using `skipToken` in place of the `skip` option as\n * it is more type-safe.\n *\n * This option is deprecated and only supported to ease the migration from useQuery. It will be removed in a future release.\n *\n * @docGroup 1. Operation options\n */\n skip_deprecated: unknown;\n\n /**\n * A callback function that's called when your query successfully completes with zero errors (or if `errorPolicy` is `ignore` and partial data is returned).\n *\n * This function is passed the query's result `data`.\n *\n * @docGroup 1. Operation options\n */\n onCompleted: unknown;\n /**\n * A callback function that's called when the query encounters one or more errors (unless `errorPolicy` is `ignore`).\n *\n * This function is passed an `ApolloError` object that contains either a `networkError` object or a `graphQLErrors` array, depending on the error(s) that occurred.\n *\n * @docGroup 1. Operation options\n */\n onError: unknown;\n\n /**\n * The instance of {@link ApolloClient} to use to execute the query.\n *\n * By default, the instance that's passed down via context is used, but you\n * can provide a different instance here.\n *\n * @docGroup 1. Operation options\n */\n client: unknown;\n\n /**\n * A unique identifier for the query. Each item in the array must be a stable\n * identifier to prevent infinite fetches.\n *\n * This is useful when using the same query and variables combination in more\n * than one component, otherwise the components may clobber each other. This\n * can also be used to force the query to re-evaluate fresh.\n *\n * @docGroup 1. Operation options\n */\n queryKey: unknown;\n\n /**\n * Pass `false` to skip executing the query during [server-side rendering](https://www.apollographql.com/docs/react/performance/server-side-rendering/).\n *\n * @docGroup 2. Networking options\n */\n ssr: unknown;\n\n /**\n * A callback function that's called whenever a refetch attempt occurs\n * while polling. If the function returns `true`, the refetch is\n * skipped and not reattempted until the next poll interval.\n *\n * @docGroup 2. Networking options\n */\n skipPollAttempt: unknown;\n}\n\nexport interface QueryResultDocumentation {\n /**\n * The instance of Apollo Client that executed the query.\n * Can be useful for manually executing followup queries or writing data to the cache.\n *\n * @docGroup 2. Network info\n */\n client: unknown;\n /**\n * A reference to the internal `ObservableQuery` used by the hook.\n */\n observable: unknown;\n /**\n * An object containing the result of your GraphQL query after it completes.\n *\n * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).\n *\n * @docGroup 1. Operation data\n */\n data: unknown;\n /**\n * An object containing the result from the most recent _previous_ execution of this query.\n *\n * This value is `undefined` if this is the query's first execution.\n *\n * @docGroup 1. Operation data\n */\n previousData: unknown;\n /**\n * If the query produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n *\n * @docGroup 1. Operation data\n */\n error: unknown;\n /**\n * If `true`, the query is still in flight and results have not yet been returned.\n *\n * @docGroup 2. Network info\n */\n loading: unknown;\n /**\n * A number indicating the current network state of the query's associated request. [See possible values.](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/core/networkStatus.ts#L4)\n *\n * Used in conjunction with the [`notifyOnNetworkStatusChange`](#notifyonnetworkstatuschange) option.\n *\n * @docGroup 2. Network info\n */\n networkStatus: unknown;\n /**\n * If `true`, the associated lazy query has been executed.\n *\n * This field is only present on the result object returned by [`useLazyQuery`](/react/data/queries/#executing-queries-manually).\n *\n * @docGroup 2. Network info\n */\n called: unknown;\n /**\n * An object containing the variables that were provided for the query.\n *\n * @docGroup 1. Operation data\n */\n variables: unknown;\n\n /**\n * A function that enables you to re-execute the query, optionally passing in new `variables`.\n *\n * To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request).\n *\n * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).\n *\n * @docGroup 3. Helper functions\n */\n refetch: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n fetchMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#startPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n startPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#stopPolling:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n stopPolling: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n subscribeToMore: unknown;\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#updateQuery:member(1)}\n *\n * @docGroup 3. Helper functions\n */\n updateQuery: unknown;\n}\n\nexport interface MutationOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n *\n * @docGroup 1. Operation options\n */\n mutation: unknown;\n\n /**\n * Provide `no-cache` if the mutation's result should _not_ be written to the Apollo Client cache.\n *\n * The default value is `network-only` (which means the result _is_ written to the cache).\n *\n * Unlike queries, mutations _do not_ support [fetch policies](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy) besides `network-only` and `no-cache`.\n *\n * @docGroup 3. Caching options\n */\n fetchPolicy: unknown;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields: unknown;\n\n /**\n * By providing either an object or a callback function that, when invoked after\n * a mutation, allows you to return optimistic data and optionally skip updates\n * via the `IGNORE` sentinel object, Apollo Client caches this temporary\n * (and potentially incorrect) response until the mutation completes, enabling\n * more responsive UI updates.\n *\n * For more information, see [Optimistic mutation results](https://www.apollographql.com/docs/react/performance/optimistic-ui/).\n *\n * @docGroup 3. Caching options\n */\n optimisticResponse: unknown;\n\n /**\n * A {@link MutationQueryReducersMap}, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries: unknown;\n\n /**\n * An array (or a function that _returns_ an array) that specifies which queries you want to refetch after the mutation occurs.\n *\n * Each array value can be either:\n *\n * - An object containing the `query` to execute, along with any `variables`\n *\n * - A string indicating the operation name of the query to refetch\n *\n * @docGroup 1. Operation options\n */\n refetchQueries: unknown;\n\n /**\n * If `true`, makes sure all queries included in `refetchQueries` are completed before the mutation is considered complete.\n *\n * The default value is `false` (queries are refetched asynchronously).\n *\n * @docGroup 1. Operation options\n */\n awaitRefetchQueries: unknown;\n\n /**\n * A function used to update the Apollo Client cache after the mutation completes.\n *\n * For more information, see [Updating the cache after a mutation](https://www.apollographql.com/docs/react/data/mutations#updating-the-cache-after-a-mutation).\n *\n * @docGroup 3. Caching options\n */\n update: unknown;\n\n /**\n * Optional callback for intercepting queries whose cache data has been updated by the mutation, as well as any queries specified in the `refetchQueries: [...]` list passed to `client.mutate`.\n *\n * Returning a `Promise` from `onQueryUpdated` will cause the final mutation `Promise` to await the returned `Promise`. Returning `false` causes the query to be ignored.\n *\n * @docGroup 1. Operation options\n */\n onQueryUpdated: unknown;\n\n /**\n * Specifies how the mutation handles a response that returns both GraphQL errors and partial results.\n *\n * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).\n *\n * The default value is `none`, meaning that the mutation result includes error details but _not_ partial results.\n *\n * @docGroup 1. Operation options\n */\n errorPolicy: unknown;\n\n /**\n * An object containing all of the GraphQL variables your mutation requires to execute.\n *\n * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.\n *\n * @docGroup 1. Operation options\n */\n variables: unknown;\n\n /**\n * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.\n *\n * @docGroup 2. Networking options\n */\n context: unknown;\n\n /**\n * The instance of `ApolloClient` to use to execute the mutation.\n *\n * By default, the instance that's passed down via context is used, but you can provide a different instance here.\n *\n * @docGroup 2. Networking options\n */\n client: unknown;\n /**\n * If `true`, the in-progress mutation's associated component re-renders whenever the network status changes or a network error occurs.\n *\n * The default value is `false`.\n *\n * @docGroup 2. Networking options\n */\n notifyOnNetworkStatusChange: unknown;\n /**\n * A callback function that's called when your mutation successfully completes with zero errors (or if `errorPolicy` is `ignore` and partial data is returned).\n *\n * This function is passed the mutation's result `data` and any options passed to the mutation.\n *\n * @docGroup 1. Operation options\n */\n onCompleted: unknown;\n /**\n * A callback function that's called when the mutation encounters one or more errors (unless `errorPolicy` is `ignore`).\n *\n * This function is passed an [`ApolloError`](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/errors/index.ts#L36-L39) object that contains either a `networkError` object or a `graphQLErrors` array, depending on the error(s) that occurred, as well as any options passed the mutation.\n *\n * @docGroup 1. Operation options\n */\n onError: unknown;\n /**\n * If `true`, the mutation's `data` property is not updated with the mutation's result.\n *\n * The default value is `false`.\n *\n * @docGroup 1. Operation options\n */\n ignoreResults: unknown;\n}\n\nexport interface MutationResultDocumentation {\n /**\n * The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.\n */\n data: unknown;\n /**\n * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.\n *\n * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).\n */\n error: unknown;\n /**\n * If `true`, the mutation is currently in flight.\n */\n loading: unknown;\n /**\n * If `true`, the mutation's mutate function has been called.\n */\n called: unknown;\n /**\n * The instance of Apollo Client that executed the mutation.\n *\n * Can be useful for manually executing followup operations or writing data to the cache.\n */\n client: unknown;\n /**\n * A function that you can call to reset the mutation's result to its initial, uncalled state.\n */\n reset: unknown;\n}\n\nexport interface SubscriptionOptionsDocumentation {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: unknown;\n /**\n * An object containing all of the variables your subscription needs to execute\n */\n variables: unknown;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy: unknown;\n\n /**\n * How you want your component to interact with the Apollo cache. For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).\n */\n fetchPolicy: unknown;\n\n /**\n * Determines if your subscription should be unsubscribed and subscribed again when an input to the hook (such as `subscription` or `variables`) changes.\n */\n shouldResubscribe: unknown;\n\n /**\n * An `ApolloClient` instance. By default `useSubscription` / `Subscription` uses the client passed down via context, but a different client can be passed in.\n */\n client: unknown;\n\n /**\n * Determines if the current subscription should be skipped. Useful if, for example, variables depend on previous queries and are not ready yet.\n */\n skip: unknown;\n\n /**\n * Shared context between your component and your network interface (Apollo Link).\n */\n context: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component completes the subscription.\n *\n * @since 3.7.0\n */\n onComplete: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `data`.\n *\n * @since 3.7.0\n */\n onData: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `subscriptionData`.\n *\n * @deprecated Use `onData` instead\n */\n onSubscriptionData: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives an error.\n *\n * @since 3.7.0\n */\n onError: unknown;\n\n /**\n * Allows the registration of a callback function that will be triggered when the `useSubscription` Hook / `Subscription` component completes the subscription.\n *\n * @deprecated Use `onComplete` instead\n */\n onSubscriptionComplete: unknown;\n}\n\nexport interface SubscriptionResultDocumentation {\n /**\n * A boolean that indicates whether any initial data has been returned\n */\n loading: unknown;\n /**\n * An object containing the result of your GraphQL subscription. Defaults to an empty object.\n */\n data: unknown;\n /**\n * A runtime error with `graphQLErrors` and `networkError` properties\n */\n error: unknown;\n}\n"]}