@apollo/client 4.2.0-alpha.5 → 4.2.0-alpha.7

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 (48) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/__cjs/core/ApolloClient.cjs.map +1 -1
  3. package/__cjs/core/ApolloClient.d.cts +29 -2
  4. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  5. package/__cjs/react/hooks/useBackgroundQuery.d.cts +1019 -19
  6. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  7. package/__cjs/react/hooks/useLazyQuery.d.cts +115 -7
  8. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  9. package/__cjs/react/hooks/useLoadableQuery.d.cts +195 -8
  10. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  11. package/__cjs/react/hooks/useMutation.d.cts +20 -9
  12. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  13. package/__cjs/react/hooks/useQuery.d.cts +280 -11
  14. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  15. package/__cjs/react/hooks/useSuspenseQuery.d.cts +405 -13
  16. package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
  17. package/__cjs/react/query-preloader/createQueryPreloader.d.cts +395 -123
  18. package/__cjs/version.cjs +1 -1
  19. package/core/ApolloClient.d.ts +29 -2
  20. package/core/ApolloClient.js.map +1 -1
  21. package/package.json +1 -1
  22. package/react/hooks/useBackgroundQuery.d.ts +1019 -19
  23. package/react/hooks/useBackgroundQuery.js.map +1 -1
  24. package/react/hooks/useLazyQuery.d.ts +115 -7
  25. package/react/hooks/useLazyQuery.js.map +1 -1
  26. package/react/hooks/useLoadableQuery.d.ts +195 -8
  27. package/react/hooks/useLoadableQuery.js.map +1 -1
  28. package/react/hooks/useMutation.d.ts +20 -9
  29. package/react/hooks/useMutation.js.map +1 -1
  30. package/react/hooks/useQuery.d.ts +280 -11
  31. package/react/hooks/useQuery.js.map +1 -1
  32. package/react/hooks/useSuspenseQuery.d.ts +405 -13
  33. package/react/hooks/useSuspenseQuery.js.map +1 -1
  34. package/react/hooks-compiled/useBackgroundQuery.d.ts +1019 -19
  35. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  36. package/react/hooks-compiled/useLazyQuery.d.ts +115 -7
  37. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  38. package/react/hooks-compiled/useLoadableQuery.d.ts +195 -8
  39. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  40. package/react/hooks-compiled/useMutation.d.ts +20 -9
  41. package/react/hooks-compiled/useMutation.js.map +1 -1
  42. package/react/hooks-compiled/useQuery.d.ts +280 -11
  43. package/react/hooks-compiled/useQuery.js.map +1 -1
  44. package/react/hooks-compiled/useSuspenseQuery.d.ts +405 -13
  45. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  46. package/react/query-preloader/createQueryPreloader.d.ts +395 -123
  47. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  48. package/version.js +1 -1
@@ -1,6 +1,6 @@
1
1
  import type { ApolloClient, DefaultContext, DocumentNode, ErrorPolicy, OperationVariables, RefetchOn, RefetchWritePolicy, TypedDocumentNode, WatchQueryFetchPolicy } from "@apollo/client";
2
2
  import type { PreloadedQueryRef } from "@apollo/client/react";
3
- import type { NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
3
+ import type { NoInfer, OptionWithFallback, SignatureStyle, VariablesOption } from "@apollo/client/utilities/internal";
4
4
  export type PreloadQueryFetchPolicy = Extract<WatchQueryFetchPolicy, "cache-first" | "network-only" | "no-cache" | "cache-and-network">;
5
5
  export type PreloadQueryOptions<TVariables extends OperationVariables = OperationVariables> = {
6
6
  /**
@@ -93,128 +93,7 @@ export type PreloadQueryOptions<TVariables extends OperationVariables = Operatio
93
93
  * }
94
94
  * ```
95
95
  */
96
- export interface PreloadQueryFunction {
97
- /**
98
- * A function that will begin loading a query when called. It's result can be
99
- * read by `useReadQuery` which will suspend until the query is loaded.
100
- * This is useful when you want to start loading a query as early as possible
101
- * outside of a React component.
102
- *
103
- * @example
104
- *
105
- * ```js
106
- * const preloadQuery = createQueryPreloader(client);
107
- * const queryRef = preloadQuery(query, { variables, ...otherOptions });
108
- *
109
- * function App() {
110
- * return (
111
- * <Suspense fallback={<div>Loading</div>}>
112
- * <MyQuery />
113
- * </Suspense>
114
- * );
115
- * }
116
- *
117
- * function MyQuery() {
118
- * const { data } = useReadQuery(queryRef);
119
- *
120
- * // do something with `data`
121
- * }
122
- * ```
123
- */
124
- <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: PreloadQueryOptions<NoInfer<TVariables>> & {
125
- returnPartialData: true;
126
- errorPolicy: "ignore" | "all";
127
- }): PreloadedQueryRef<TData, TVariables, "complete" | "streaming" | "partial" | "empty">;
128
- /**
129
- * A function that will begin loading a query when called. It's result can be
130
- * read by `useReadQuery` which will suspend until the query is loaded.
131
- * This is useful when you want to start loading a query as early as possible
132
- * outside of a React component.
133
- *
134
- * @example
135
- *
136
- * ```js
137
- * const preloadQuery = createQueryPreloader(client);
138
- * const queryRef = preloadQuery(query, { variables, ...otherOptions });
139
- *
140
- * function App() {
141
- * return (
142
- * <Suspense fallback={<div>Loading</div>}>
143
- * <MyQuery />
144
- * </Suspense>
145
- * );
146
- * }
147
- *
148
- * function MyQuery() {
149
- * const { data } = useReadQuery(queryRef);
150
- *
151
- * // do something with `data`
152
- * }
153
- * ```
154
- */
155
- <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: PreloadQueryOptions<NoInfer<TVariables>> & {
156
- errorPolicy: "ignore" | "all";
157
- }): PreloadedQueryRef<TData, TVariables, "complete" | "streaming" | "empty">;
158
- /**
159
- * A function that will begin loading a query when called. It's result can be
160
- * read by `useReadQuery` which will suspend until the query is loaded.
161
- * This is useful when you want to start loading a query as early as possible
162
- * outside of a React component.
163
- *
164
- * @example
165
- *
166
- * ```js
167
- * const preloadQuery = createQueryPreloader(client);
168
- * const queryRef = preloadQuery(query, { variables, ...otherOptions });
169
- *
170
- * function App() {
171
- * return (
172
- * <Suspense fallback={<div>Loading</div>}>
173
- * <MyQuery />
174
- * </Suspense>
175
- * );
176
- * }
177
- *
178
- * function MyQuery() {
179
- * const { data } = useReadQuery(queryRef);
180
- *
181
- * // do something with `data`
182
- * }
183
- * ```
184
- */
185
- <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: PreloadQueryOptions<NoInfer<TVariables>> & {
186
- returnPartialData: true;
187
- }): PreloadedQueryRef<TData, TVariables, "complete" | "streaming" | "partial">;
188
- /**
189
- * A function that will begin loading a query when called. It's result can be
190
- * read by `useReadQuery` which will suspend until the query is loaded.
191
- * This is useful when you want to start loading a query as early as possible
192
- * outside of a React component.
193
- *
194
- * @example
195
- *
196
- * ```js
197
- * const preloadQuery = createQueryPreloader(client);
198
- * const queryRef = preloadQuery(query, { variables, ...otherOptions });
199
- *
200
- * function App() {
201
- * return (
202
- * <Suspense fallback={<div>Loading</div>}>
203
- * <MyQuery />
204
- * </Suspense>
205
- * );
206
- * }
207
- *
208
- * function MyQuery() {
209
- * const { data } = useReadQuery(queryRef);
210
- *
211
- * // do something with `data`
212
- * }
213
- * ```
214
- */
215
- <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
216
- options?: PreloadQueryOptions<NoInfer<TVariables>>
217
- ] : [options: PreloadQueryOptions<NoInfer<TVariables>>]): PreloadedQueryRef<TData, TVariables, "complete" | "streaming">;
96
+ export interface PreloadQueryFunction extends PreloadQueryFunction.Signatures.Evaluated {
218
97
  /**
219
98
  * A function that returns a promise that resolves when the query has finished
220
99
  * loading. The promise resolves with the `QueryReference` itself.
@@ -253,6 +132,399 @@ export interface PreloadQueryFunction {
253
132
  */
254
133
  toPromise<TQueryRef extends PreloadedQueryRef<any, any, any>>(queryRef: TQueryRef): Promise<TQueryRef>;
255
134
  }
135
+ export declare namespace PreloadQueryFunction {
136
+ interface DefaultOptions extends ApolloClient.DefaultOptions.WatchQuery.Calculated {
137
+ }
138
+ namespace DocumentationTypes {
139
+ /**
140
+ * @deprecated Avoid manually specifying generics on `preloadQuery`.
141
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
142
+ *
143
+ *
144
+ * A function that will begin loading a query when called. It's result can be
145
+ * read by `useReadQuery` which will suspend until the query is loaded.
146
+ * This is useful when you want to start loading a query as early as possible
147
+ * outside of a React component.
148
+ *
149
+ * @example
150
+ *
151
+ * ```js
152
+ * const preloadQuery = createQueryPreloader(client);
153
+ * const queryRef = preloadQuery(query, { variables, ...otherOptions });
154
+ *
155
+ * function App() {
156
+ * return (
157
+ * <Suspense fallback={<div>Loading</div>}>
158
+ * <MyQuery />
159
+ * </Suspense>
160
+ * );
161
+ * }
162
+ *
163
+ * function MyQuery() {
164
+ * const { data } = useReadQuery(queryRef);
165
+ *
166
+ * // do something with `data`
167
+ * }
168
+ * ```
169
+ */
170
+ interface PreloadQueryFunction_Deprecated extends PreloadQueryFunction {
171
+ }
172
+ }
173
+ type ResultForOptions<TData, TVariables extends OperationVariables, TOptions extends Record<string, never> | PreloadQueryOptions<TVariables>> = TOptions extends any ? PreloadedQueryRef<TData, TVariables, ResultForOptions.States<TOptions, DefaultOptions>> : never;
174
+ namespace ResultForOptions {
175
+ type States<TOptions, TDefaultOptions extends DefaultOptions = DefaultOptions> = "complete" | "streaming" | (OptionWithFallback<TOptions, TDefaultOptions, "errorPolicy"> extends ("none") ? never : "empty") | (OptionWithFallback<TOptions, TDefaultOptions, "returnPartialData"> extends false ? never : "partial");
176
+ }
177
+ namespace Signatures {
178
+ interface Classic {
179
+ /**
180
+ * A function that will begin loading a query when called. It's result can be
181
+ * read by `useReadQuery` which will suspend until the query is loaded.
182
+ * This is useful when you want to start loading a query as early as possible
183
+ * outside of a React component.
184
+ *
185
+ * @example
186
+ *
187
+ * ```js
188
+ * const preloadQuery = createQueryPreloader(client);
189
+ * const queryRef = preloadQuery(query, { variables, ...otherOptions });
190
+ *
191
+ * function App() {
192
+ * return (
193
+ * <Suspense fallback={<div>Loading</div>}>
194
+ * <MyQuery />
195
+ * </Suspense>
196
+ * );
197
+ * }
198
+ *
199
+ * function MyQuery() {
200
+ * const { data } = useReadQuery(queryRef);
201
+ *
202
+ * // do something with `data`
203
+ * }
204
+ * ```
205
+ */
206
+ <TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: PreloadQueryOptions<NoInfer<TVariables>> & {
207
+ returnPartialData: true;
208
+ errorPolicy: "ignore" | "all";
209
+ }): PreloadedQueryRef<TData, TVariables, "complete" | "streaming" | "partial" | "empty">;
210
+ /**
211
+ * A function that will begin loading a query when called. It's result can be
212
+ * read by `useReadQuery` which will suspend until the query is loaded.
213
+ * This is useful when you want to start loading a query as early as possible
214
+ * outside of a React component.
215
+ *
216
+ * @example
217
+ *
218
+ * ```js
219
+ * const preloadQuery = createQueryPreloader(client);
220
+ * const queryRef = preloadQuery(query, { variables, ...otherOptions });
221
+ *
222
+ * function App() {
223
+ * return (
224
+ * <Suspense fallback={<div>Loading</div>}>
225
+ * <MyQuery />
226
+ * </Suspense>
227
+ * );
228
+ * }
229
+ *
230
+ * function MyQuery() {
231
+ * const { data } = useReadQuery(queryRef);
232
+ *
233
+ * // do something with `data`
234
+ * }
235
+ * ```
236
+ */
237
+ <TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: PreloadQueryOptions<NoInfer<TVariables>> & {
238
+ errorPolicy: "ignore" | "all";
239
+ }): PreloadedQueryRef<TData, TVariables, "complete" | "streaming" | "empty">;
240
+ /**
241
+ * A function that will begin loading a query when called. It's result can be
242
+ * read by `useReadQuery` which will suspend until the query is loaded.
243
+ * This is useful when you want to start loading a query as early as possible
244
+ * outside of a React component.
245
+ *
246
+ * @example
247
+ *
248
+ * ```js
249
+ * const preloadQuery = createQueryPreloader(client);
250
+ * const queryRef = preloadQuery(query, { variables, ...otherOptions });
251
+ *
252
+ * function App() {
253
+ * return (
254
+ * <Suspense fallback={<div>Loading</div>}>
255
+ * <MyQuery />
256
+ * </Suspense>
257
+ * );
258
+ * }
259
+ *
260
+ * function MyQuery() {
261
+ * const { data } = useReadQuery(queryRef);
262
+ *
263
+ * // do something with `data`
264
+ * }
265
+ * ```
266
+ */
267
+ <TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: PreloadQueryOptions<NoInfer<TVariables>> & {
268
+ returnPartialData: true;
269
+ }): PreloadedQueryRef<TData, TVariables, "complete" | "streaming" | "partial">;
270
+ /**
271
+ * A function that will begin loading a query when called. It's result can be
272
+ * read by `useReadQuery` which will suspend until the query is loaded.
273
+ * This is useful when you want to start loading a query as early as possible
274
+ * outside of a React component.
275
+ *
276
+ * @example
277
+ *
278
+ * ```js
279
+ * const preloadQuery = createQueryPreloader(client);
280
+ * const queryRef = preloadQuery(query, { variables, ...otherOptions });
281
+ *
282
+ * function App() {
283
+ * return (
284
+ * <Suspense fallback={<div>Loading</div>}>
285
+ * <MyQuery />
286
+ * </Suspense>
287
+ * );
288
+ * }
289
+ *
290
+ * function MyQuery() {
291
+ * const { data } = useReadQuery(queryRef);
292
+ *
293
+ * // do something with `data`
294
+ * }
295
+ * ```
296
+ */
297
+ <TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
298
+ options?: PreloadQueryOptions<NoInfer<TVariables>>
299
+ ] : [options: PreloadQueryOptions<NoInfer<TVariables>>]): PreloadedQueryRef<TData, TVariables, "complete" | "streaming">;
300
+ /**
301
+ * @deprecated Avoid manually specifying generics on `preloadQuery`.
302
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
303
+ *
304
+ *
305
+ * A function that will begin loading a query when called. It's result can be
306
+ * read by `useReadQuery` which will suspend until the query is loaded.
307
+ * This is useful when you want to start loading a query as early as possible
308
+ * outside of a React component.
309
+ *
310
+ * @example
311
+ *
312
+ * ```js
313
+ * const preloadQuery = createQueryPreloader(client);
314
+ * const queryRef = preloadQuery(query, { variables, ...otherOptions });
315
+ *
316
+ * function App() {
317
+ * return (
318
+ * <Suspense fallback={<div>Loading</div>}>
319
+ * <MyQuery />
320
+ * </Suspense>
321
+ * );
322
+ * }
323
+ *
324
+ * function MyQuery() {
325
+ * const { data } = useReadQuery(queryRef);
326
+ *
327
+ * // do something with `data`
328
+ * }
329
+ * ```
330
+ */
331
+ <TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: PreloadQueryOptions<NoInfer<TVariables>> & {
332
+ returnPartialData: true;
333
+ errorPolicy: "ignore" | "all";
334
+ }): PreloadedQueryRef<TData, TVariables, "complete" | "streaming" | "partial" | "empty">;
335
+ /**
336
+ * @deprecated Avoid manually specifying generics on `preloadQuery`.
337
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
338
+ *
339
+ *
340
+ * A function that will begin loading a query when called. It's result can be
341
+ * read by `useReadQuery` which will suspend until the query is loaded.
342
+ * This is useful when you want to start loading a query as early as possible
343
+ * outside of a React component.
344
+ *
345
+ * @example
346
+ *
347
+ * ```js
348
+ * const preloadQuery = createQueryPreloader(client);
349
+ * const queryRef = preloadQuery(query, { variables, ...otherOptions });
350
+ *
351
+ * function App() {
352
+ * return (
353
+ * <Suspense fallback={<div>Loading</div>}>
354
+ * <MyQuery />
355
+ * </Suspense>
356
+ * );
357
+ * }
358
+ *
359
+ * function MyQuery() {
360
+ * const { data } = useReadQuery(queryRef);
361
+ *
362
+ * // do something with `data`
363
+ * }
364
+ * ```
365
+ */
366
+ <TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: PreloadQueryOptions<NoInfer<TVariables>> & {
367
+ errorPolicy: "ignore" | "all";
368
+ }): PreloadedQueryRef<TData, TVariables, "complete" | "streaming" | "empty">;
369
+ /**
370
+ * @deprecated Avoid manually specifying generics on `preloadQuery`.
371
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
372
+ *
373
+ *
374
+ * A function that will begin loading a query when called. It's result can be
375
+ * read by `useReadQuery` which will suspend until the query is loaded.
376
+ * This is useful when you want to start loading a query as early as possible
377
+ * outside of a React component.
378
+ *
379
+ * @example
380
+ *
381
+ * ```js
382
+ * const preloadQuery = createQueryPreloader(client);
383
+ * const queryRef = preloadQuery(query, { variables, ...otherOptions });
384
+ *
385
+ * function App() {
386
+ * return (
387
+ * <Suspense fallback={<div>Loading</div>}>
388
+ * <MyQuery />
389
+ * </Suspense>
390
+ * );
391
+ * }
392
+ *
393
+ * function MyQuery() {
394
+ * const { data } = useReadQuery(queryRef);
395
+ *
396
+ * // do something with `data`
397
+ * }
398
+ * ```
399
+ */
400
+ <TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: PreloadQueryOptions<NoInfer<TVariables>> & {
401
+ returnPartialData: true;
402
+ }): PreloadedQueryRef<TData, TVariables, "complete" | "streaming" | "partial">;
403
+ /**
404
+ * @deprecated Avoid manually specifying generics on `preloadQuery`.
405
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
406
+ *
407
+ *
408
+ * A function that will begin loading a query when called. It's result can be
409
+ * read by `useReadQuery` which will suspend until the query is loaded.
410
+ * This is useful when you want to start loading a query as early as possible
411
+ * outside of a React component.
412
+ *
413
+ * @example
414
+ *
415
+ * ```js
416
+ * const preloadQuery = createQueryPreloader(client);
417
+ * const queryRef = preloadQuery(query, { variables, ...otherOptions });
418
+ *
419
+ * function App() {
420
+ * return (
421
+ * <Suspense fallback={<div>Loading</div>}>
422
+ * <MyQuery />
423
+ * </Suspense>
424
+ * );
425
+ * }
426
+ *
427
+ * function MyQuery() {
428
+ * const { data } = useReadQuery(queryRef);
429
+ *
430
+ * // do something with `data`
431
+ * }
432
+ * ```
433
+ */
434
+ <TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
435
+ options?: PreloadQueryOptions<NoInfer<TVariables>>
436
+ ] : [options: PreloadQueryOptions<NoInfer<TVariables>>]): PreloadedQueryRef<TData, TVariables, "complete" | "streaming">;
437
+ }
438
+ /**
439
+ * A function that will begin loading a query when called. It's result can be
440
+ * read by `useReadQuery` which will suspend until the query is loaded.
441
+ * This is useful when you want to start loading a query as early as possible
442
+ * outside of a React component.
443
+ *
444
+ * @example
445
+ *
446
+ * ```js
447
+ * const preloadQuery = createQueryPreloader(client);
448
+ * const queryRef = preloadQuery(query, { variables, ...otherOptions });
449
+ *
450
+ * function App() {
451
+ * return (
452
+ * <Suspense fallback={<div>Loading</div>}>
453
+ * <MyQuery />
454
+ * </Suspense>
455
+ * );
456
+ * }
457
+ *
458
+ * function MyQuery() {
459
+ * const { data } = useReadQuery(queryRef);
460
+ *
461
+ * // do something with `data`
462
+ * }
463
+ * ```
464
+ */
465
+ interface Modern {
466
+ /**
467
+ * A function that will begin loading a query when called. It's result can be
468
+ * read by `useReadQuery` which will suspend until the query is loaded.
469
+ * This is useful when you want to start loading a query as early as possible
470
+ * outside of a React component.
471
+ *
472
+ * @example
473
+ *
474
+ * ```js
475
+ * const preloadQuery = createQueryPreloader(client);
476
+ * const queryRef = preloadQuery(query, { variables, ...otherOptions });
477
+ *
478
+ * function App() {
479
+ * return (
480
+ * <Suspense fallback={<div>Loading</div>}>
481
+ * <MyQuery />
482
+ * </Suspense>
483
+ * );
484
+ * }
485
+ *
486
+ * function MyQuery() {
487
+ * const { data } = useReadQuery(queryRef);
488
+ *
489
+ * // do something with `data`
490
+ * }
491
+ * ```
492
+ */
493
+ <TData, TVariables extends OperationVariables, TOptions extends never>(query: {} extends TVariables ? DocumentNode | TypedDocumentNode<TData, TVariables> : never): PreloadQueryFunction.ResultForOptions<TData, TVariables, Record<string, never>>;
494
+ /**
495
+ * A function that will begin loading a query when called. It's result can be
496
+ * read by `useReadQuery` which will suspend until the query is loaded.
497
+ * This is useful when you want to start loading a query as early as possible
498
+ * outside of a React component.
499
+ *
500
+ * @example
501
+ *
502
+ * ```js
503
+ * const preloadQuery = createQueryPreloader(client);
504
+ * const queryRef = preloadQuery(query, { variables, ...otherOptions });
505
+ *
506
+ * function App() {
507
+ * return (
508
+ * <Suspense fallback={<div>Loading</div>}>
509
+ * <MyQuery />
510
+ * </Suspense>
511
+ * );
512
+ * }
513
+ *
514
+ * function MyQuery() {
515
+ * const { data } = useReadQuery(queryRef);
516
+ *
517
+ * // do something with `data`
518
+ * }
519
+ * ```
520
+ */
521
+ <TData, TVariables extends OperationVariables, TOptions extends PreloadQueryOptions<NoInfer<TVariables>> & VariablesOption<TVariables & {
522
+ [K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
523
+ }>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [options?: TOptions] : [options: TOptions]): PreloadQueryFunction.ResultForOptions<TData, TVariables, TOptions>;
524
+ }
525
+ type Evaluated = SignatureStyle extends "classic" ? Classic : Modern;
526
+ }
527
+ }
256
528
  /**
257
529
  * A higher order function that returns a `preloadQuery` function which
258
530
  * can be used to begin loading a query with the given `client`. This is useful
package/__cjs/version.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.build = exports.version = void 0;
4
- exports.version = "4.2.0-alpha.5";
4
+ exports.version = "4.2.0-alpha.7";
5
5
  exports.build = "cjs";
6
6
  //# sourceMappingURL=version.cjs.map
@@ -235,6 +235,17 @@ export declare namespace ApolloClient {
235
235
  type ResultForOptions<TData, TVariables extends OperationVariables, TCache extends ApolloCache, TOptions extends Record<string, unknown> | MutateOptions<any, TVariables, TCache>> = LazyType<MutateResult<MaybeMasked<TData>, OptionWithFallback<TOptions, DefaultOptions, "errorPolicy"> & ErrorPolicy>>;
236
236
  namespace Signatures {
237
237
  interface Classic {
238
+ /**
239
+ * This resolves a single mutation according to the options specified and returns a
240
+ * Promise which is either resolved with the resulting data or rejected with an
241
+ * error. In some cases both `data` and `errors` might be undefined, for example
242
+ * when `errorPolicy` is set to `'ignore'`.
243
+ *
244
+ * It takes options as an object with the following keys and values:
245
+ */
246
+ <TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred", TErrorPolicy extends ErrorPolicy | undefined = undefined>(options: ApolloClient.MutateOptions<TData, TVariables, ApolloCache> & {
247
+ errorPolicy?: TErrorPolicy;
248
+ }): Promise<ApolloClient.MutateResult<MaybeMasked<TData>, TErrorPolicy>>;
238
249
  /**
239
250
  * @deprecated Avoid manually specifying generics on `client.mutate`.
240
251
  * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your mutation results.
@@ -247,7 +258,9 @@ export declare namespace ApolloClient {
247
258
  *
248
259
  * It takes options as an object with the following keys and values:
249
260
  */
250
- <TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache>(options: ApolloClient.MutateOptions<TData, TVariables, TCache>): Promise<ApolloClient.MutateResult<MaybeMasked<TData>>>;
261
+ <TData, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache, TErrorPolicy extends ErrorPolicy | undefined = undefined>(options: ApolloClient.MutateOptions<TData, TVariables, TCache> & (TErrorPolicy extends undefined ? {} : {
262
+ errorPolicy: TErrorPolicy;
263
+ })): Promise<ApolloClient.MutateResult<MaybeMasked<TData>, TErrorPolicy>>;
251
264
  }
252
265
  interface Modern {
253
266
  /**
@@ -463,6 +476,18 @@ export declare namespace ApolloClient {
463
476
  type ResultForOptions<TData, TVariables extends OperationVariables, TOptions extends Record<string, unknown> | QueryOptions<any, TVariables>> = LazyType<QueryResult<MaybeMasked<TData>, OptionWithFallback<TOptions, DefaultOptions, "errorPolicy"> & ErrorPolicy>>;
464
477
  namespace Signatures {
465
478
  interface Classic {
479
+ /**
480
+ * This resolves a single query according to the options specified and
481
+ * returns a `Promise` which is either resolved with the resulting data
482
+ * or rejected with an error.
483
+ *
484
+ * @param options - An object of type `QueryOptions` that allows us to
485
+ * describe how this query should be treated e.g. whether it should hit the
486
+ * server at all or just resolve from the cache, etc.
487
+ */
488
+ <TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred", TErrorPolicy extends ErrorPolicy | undefined = undefined>(options: ApolloClient.QueryOptions<TData, TVariables> & {
489
+ errorPolicy?: TErrorPolicy;
490
+ }): Promise<ApolloClient.QueryResult<MaybeMasked<TData>, TErrorPolicy>>;
466
491
  /**
467
492
  * @deprecated Avoid manually specifying generics on `client.query`.
468
493
  * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
@@ -476,7 +501,9 @@ export declare namespace ApolloClient {
476
501
  * describe how this query should be treated e.g. whether it should hit the
477
502
  * server at all or just resolve from the cache, etc.
478
503
  */
479
- <TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.QueryOptions<TData, TVariables>): Promise<ApolloClient.QueryResult<MaybeMasked<TData>>>;
504
+ <TData, TVariables extends OperationVariables = OperationVariables, TErrorPolicy extends ErrorPolicy | undefined = undefined>(options: ApolloClient.QueryOptions<TData, TVariables> & (TErrorPolicy extends undefined ? {} : {
505
+ errorPolicy: TErrorPolicy;
506
+ })): Promise<ApolloClient.QueryResult<MaybeMasked<TData>, TErrorPolicy>>;
480
507
  }
481
508
  interface Modern {
482
509
  /**