@apollo/client 4.2.0-alpha.5 → 4.2.0-alpha.6
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.
- package/CHANGELOG.md +6 -0
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +29 -2
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +1019 -19
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +115 -7
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +195 -8
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +20 -9
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +280 -11
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +405 -13
- package/__cjs/version.cjs +1 -1
- package/core/ApolloClient.d.ts +29 -2
- package/core/ApolloClient.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +1019 -19
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +115 -7
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +195 -8
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +20 -9
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +280 -11
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +405 -13
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +1019 -19
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +115 -7
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +195 -8
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +20 -9
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +280 -11
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +405 -13
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/version.js +1 -1
|
@@ -299,10 +299,6 @@ export declare namespace useSuspenseQuery {
|
|
|
299
299
|
}
|
|
300
300
|
namespace Signatures {
|
|
301
301
|
/**
|
|
302
|
-
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
303
|
-
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
302
|
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
307
303
|
*
|
|
308
304
|
* @example
|
|
@@ -344,6 +340,402 @@ export declare namespace useSuspenseQuery {
|
|
|
344
340
|
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
345
341
|
*/
|
|
346
342
|
interface Classic {
|
|
343
|
+
/**
|
|
344
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
*
|
|
348
|
+
* ```jsx
|
|
349
|
+
* import { Suspense } from "react";
|
|
350
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
351
|
+
*
|
|
352
|
+
* const listQuery = gql`
|
|
353
|
+
* query {
|
|
354
|
+
* list {
|
|
355
|
+
* id
|
|
356
|
+
* }
|
|
357
|
+
* }
|
|
358
|
+
* `;
|
|
359
|
+
*
|
|
360
|
+
* function App() {
|
|
361
|
+
* return (
|
|
362
|
+
* <Suspense fallback={<Spinner />}>
|
|
363
|
+
* <List />
|
|
364
|
+
* </Suspense>
|
|
365
|
+
* );
|
|
366
|
+
* }
|
|
367
|
+
*
|
|
368
|
+
* function List() {
|
|
369
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
370
|
+
*
|
|
371
|
+
* return (
|
|
372
|
+
* <ol>
|
|
373
|
+
* {data.list.map((item) => (
|
|
374
|
+
* <Item key={item.id} id={item.id} />
|
|
375
|
+
* ))}
|
|
376
|
+
* </ol>
|
|
377
|
+
* );
|
|
378
|
+
* }
|
|
379
|
+
* ```
|
|
380
|
+
*
|
|
381
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
382
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
383
|
+
*/
|
|
384
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
385
|
+
returnPartialData: true;
|
|
386
|
+
errorPolicy: "ignore" | "all";
|
|
387
|
+
}): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "partial" | "empty">;
|
|
388
|
+
/**
|
|
389
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
*
|
|
393
|
+
* ```jsx
|
|
394
|
+
* import { Suspense } from "react";
|
|
395
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
396
|
+
*
|
|
397
|
+
* const listQuery = gql`
|
|
398
|
+
* query {
|
|
399
|
+
* list {
|
|
400
|
+
* id
|
|
401
|
+
* }
|
|
402
|
+
* }
|
|
403
|
+
* `;
|
|
404
|
+
*
|
|
405
|
+
* function App() {
|
|
406
|
+
* return (
|
|
407
|
+
* <Suspense fallback={<Spinner />}>
|
|
408
|
+
* <List />
|
|
409
|
+
* </Suspense>
|
|
410
|
+
* );
|
|
411
|
+
* }
|
|
412
|
+
*
|
|
413
|
+
* function List() {
|
|
414
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
415
|
+
*
|
|
416
|
+
* return (
|
|
417
|
+
* <ol>
|
|
418
|
+
* {data.list.map((item) => (
|
|
419
|
+
* <Item key={item.id} id={item.id} />
|
|
420
|
+
* ))}
|
|
421
|
+
* </ol>
|
|
422
|
+
* );
|
|
423
|
+
* }
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
427
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
428
|
+
*/
|
|
429
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
430
|
+
errorPolicy: "ignore" | "all";
|
|
431
|
+
}): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
|
|
432
|
+
/**
|
|
433
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
*
|
|
437
|
+
* ```jsx
|
|
438
|
+
* import { Suspense } from "react";
|
|
439
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
440
|
+
*
|
|
441
|
+
* const listQuery = gql`
|
|
442
|
+
* query {
|
|
443
|
+
* list {
|
|
444
|
+
* id
|
|
445
|
+
* }
|
|
446
|
+
* }
|
|
447
|
+
* `;
|
|
448
|
+
*
|
|
449
|
+
* function App() {
|
|
450
|
+
* return (
|
|
451
|
+
* <Suspense fallback={<Spinner />}>
|
|
452
|
+
* <List />
|
|
453
|
+
* </Suspense>
|
|
454
|
+
* );
|
|
455
|
+
* }
|
|
456
|
+
*
|
|
457
|
+
* function List() {
|
|
458
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
459
|
+
*
|
|
460
|
+
* return (
|
|
461
|
+
* <ol>
|
|
462
|
+
* {data.list.map((item) => (
|
|
463
|
+
* <Item key={item.id} id={item.id} />
|
|
464
|
+
* ))}
|
|
465
|
+
* </ol>
|
|
466
|
+
* );
|
|
467
|
+
* }
|
|
468
|
+
* ```
|
|
469
|
+
*
|
|
470
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
471
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
472
|
+
*/
|
|
473
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
474
|
+
skip: boolean;
|
|
475
|
+
returnPartialData: true;
|
|
476
|
+
}): useSuspenseQuery.Result<TData, TVariables, "complete" | "empty" | "streaming" | "partial">;
|
|
477
|
+
/**
|
|
478
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
*
|
|
482
|
+
* ```jsx
|
|
483
|
+
* import { Suspense } from "react";
|
|
484
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
485
|
+
*
|
|
486
|
+
* const listQuery = gql`
|
|
487
|
+
* query {
|
|
488
|
+
* list {
|
|
489
|
+
* id
|
|
490
|
+
* }
|
|
491
|
+
* }
|
|
492
|
+
* `;
|
|
493
|
+
*
|
|
494
|
+
* function App() {
|
|
495
|
+
* return (
|
|
496
|
+
* <Suspense fallback={<Spinner />}>
|
|
497
|
+
* <List />
|
|
498
|
+
* </Suspense>
|
|
499
|
+
* );
|
|
500
|
+
* }
|
|
501
|
+
*
|
|
502
|
+
* function List() {
|
|
503
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
504
|
+
*
|
|
505
|
+
* return (
|
|
506
|
+
* <ol>
|
|
507
|
+
* {data.list.map((item) => (
|
|
508
|
+
* <Item key={item.id} id={item.id} />
|
|
509
|
+
* ))}
|
|
510
|
+
* </ol>
|
|
511
|
+
* );
|
|
512
|
+
* }
|
|
513
|
+
* ```
|
|
514
|
+
*
|
|
515
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
516
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
517
|
+
*/
|
|
518
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
519
|
+
returnPartialData: true;
|
|
520
|
+
}): useSuspenseQuery.Result<TData, TVariables, "partial" | "streaming" | "complete">;
|
|
521
|
+
/**
|
|
522
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
*
|
|
526
|
+
* ```jsx
|
|
527
|
+
* import { Suspense } from "react";
|
|
528
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
529
|
+
*
|
|
530
|
+
* const listQuery = gql`
|
|
531
|
+
* query {
|
|
532
|
+
* list {
|
|
533
|
+
* id
|
|
534
|
+
* }
|
|
535
|
+
* }
|
|
536
|
+
* `;
|
|
537
|
+
*
|
|
538
|
+
* function App() {
|
|
539
|
+
* return (
|
|
540
|
+
* <Suspense fallback={<Spinner />}>
|
|
541
|
+
* <List />
|
|
542
|
+
* </Suspense>
|
|
543
|
+
* );
|
|
544
|
+
* }
|
|
545
|
+
*
|
|
546
|
+
* function List() {
|
|
547
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
548
|
+
*
|
|
549
|
+
* return (
|
|
550
|
+
* <ol>
|
|
551
|
+
* {data.list.map((item) => (
|
|
552
|
+
* <Item key={item.id} id={item.id} />
|
|
553
|
+
* ))}
|
|
554
|
+
* </ol>
|
|
555
|
+
* );
|
|
556
|
+
* }
|
|
557
|
+
* ```
|
|
558
|
+
*
|
|
559
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
560
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
561
|
+
*/
|
|
562
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
563
|
+
skip: boolean;
|
|
564
|
+
}): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
|
|
565
|
+
/**
|
|
566
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
567
|
+
*
|
|
568
|
+
* @example
|
|
569
|
+
*
|
|
570
|
+
* ```jsx
|
|
571
|
+
* import { Suspense } from "react";
|
|
572
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
573
|
+
*
|
|
574
|
+
* const listQuery = gql`
|
|
575
|
+
* query {
|
|
576
|
+
* list {
|
|
577
|
+
* id
|
|
578
|
+
* }
|
|
579
|
+
* }
|
|
580
|
+
* `;
|
|
581
|
+
*
|
|
582
|
+
* function App() {
|
|
583
|
+
* return (
|
|
584
|
+
* <Suspense fallback={<Spinner />}>
|
|
585
|
+
* <List />
|
|
586
|
+
* </Suspense>
|
|
587
|
+
* );
|
|
588
|
+
* }
|
|
589
|
+
*
|
|
590
|
+
* function List() {
|
|
591
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
592
|
+
*
|
|
593
|
+
* return (
|
|
594
|
+
* <ol>
|
|
595
|
+
* {data.list.map((item) => (
|
|
596
|
+
* <Item key={item.id} id={item.id} />
|
|
597
|
+
* ))}
|
|
598
|
+
* </ol>
|
|
599
|
+
* );
|
|
600
|
+
* }
|
|
601
|
+
* ```
|
|
602
|
+
*
|
|
603
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
604
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
605
|
+
*/
|
|
606
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
607
|
+
returnPartialData: true;
|
|
608
|
+
})): useSuspenseQuery.Result<TData, TVariables, "empty" | "streaming" | "complete" | "partial">;
|
|
609
|
+
/**
|
|
610
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
*
|
|
614
|
+
* ```jsx
|
|
615
|
+
* import { Suspense } from "react";
|
|
616
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
617
|
+
*
|
|
618
|
+
* const listQuery = gql`
|
|
619
|
+
* query {
|
|
620
|
+
* list {
|
|
621
|
+
* id
|
|
622
|
+
* }
|
|
623
|
+
* }
|
|
624
|
+
* `;
|
|
625
|
+
*
|
|
626
|
+
* function App() {
|
|
627
|
+
* return (
|
|
628
|
+
* <Suspense fallback={<Spinner />}>
|
|
629
|
+
* <List />
|
|
630
|
+
* </Suspense>
|
|
631
|
+
* );
|
|
632
|
+
* }
|
|
633
|
+
*
|
|
634
|
+
* function List() {
|
|
635
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
636
|
+
*
|
|
637
|
+
* return (
|
|
638
|
+
* <ol>
|
|
639
|
+
* {data.list.map((item) => (
|
|
640
|
+
* <Item key={item.id} id={item.id} />
|
|
641
|
+
* ))}
|
|
642
|
+
* </ol>
|
|
643
|
+
* );
|
|
644
|
+
* }
|
|
645
|
+
* ```
|
|
646
|
+
*
|
|
647
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
648
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
649
|
+
*/
|
|
650
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
651
|
+
options?: useSuspenseQuery.Options<NoInfer<TVariables>>
|
|
652
|
+
] : [options: useSuspenseQuery.Options<NoInfer<TVariables>>]): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming">;
|
|
653
|
+
/**
|
|
654
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
655
|
+
*
|
|
656
|
+
* @example
|
|
657
|
+
*
|
|
658
|
+
* ```jsx
|
|
659
|
+
* import { Suspense } from "react";
|
|
660
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
661
|
+
*
|
|
662
|
+
* const listQuery = gql`
|
|
663
|
+
* query {
|
|
664
|
+
* list {
|
|
665
|
+
* id
|
|
666
|
+
* }
|
|
667
|
+
* }
|
|
668
|
+
* `;
|
|
669
|
+
*
|
|
670
|
+
* function App() {
|
|
671
|
+
* return (
|
|
672
|
+
* <Suspense fallback={<Spinner />}>
|
|
673
|
+
* <List />
|
|
674
|
+
* </Suspense>
|
|
675
|
+
* );
|
|
676
|
+
* }
|
|
677
|
+
*
|
|
678
|
+
* function List() {
|
|
679
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
680
|
+
*
|
|
681
|
+
* return (
|
|
682
|
+
* <ol>
|
|
683
|
+
* {data.list.map((item) => (
|
|
684
|
+
* <Item key={item.id} id={item.id} />
|
|
685
|
+
* ))}
|
|
686
|
+
* </ol>
|
|
687
|
+
* );
|
|
688
|
+
* }
|
|
689
|
+
* ```
|
|
690
|
+
*
|
|
691
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
692
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
693
|
+
*/
|
|
694
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
695
|
+
options?: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>
|
|
696
|
+
] : [options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>]): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
|
|
697
|
+
/**
|
|
698
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
699
|
+
*
|
|
700
|
+
* @example
|
|
701
|
+
*
|
|
702
|
+
* ```jsx
|
|
703
|
+
* import { Suspense } from "react";
|
|
704
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
705
|
+
*
|
|
706
|
+
* const listQuery = gql`
|
|
707
|
+
* query {
|
|
708
|
+
* list {
|
|
709
|
+
* id
|
|
710
|
+
* }
|
|
711
|
+
* }
|
|
712
|
+
* `;
|
|
713
|
+
*
|
|
714
|
+
* function App() {
|
|
715
|
+
* return (
|
|
716
|
+
* <Suspense fallback={<Spinner />}>
|
|
717
|
+
* <List />
|
|
718
|
+
* </Suspense>
|
|
719
|
+
* );
|
|
720
|
+
* }
|
|
721
|
+
*
|
|
722
|
+
* function List() {
|
|
723
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
724
|
+
*
|
|
725
|
+
* return (
|
|
726
|
+
* <ol>
|
|
727
|
+
* {data.list.map((item) => (
|
|
728
|
+
* <Item key={item.id} id={item.id} />
|
|
729
|
+
* ))}
|
|
730
|
+
* </ol>
|
|
731
|
+
* );
|
|
732
|
+
* }
|
|
733
|
+
* ```
|
|
734
|
+
*
|
|
735
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
736
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
737
|
+
*/
|
|
738
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
|
|
347
739
|
/**
|
|
348
740
|
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
349
741
|
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
@@ -389,7 +781,7 @@ export declare namespace useSuspenseQuery {
|
|
|
389
781
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
390
782
|
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
391
783
|
*/
|
|
392
|
-
<TData
|
|
784
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
393
785
|
returnPartialData: true;
|
|
394
786
|
errorPolicy: "ignore" | "all";
|
|
395
787
|
}): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "partial" | "empty">;
|
|
@@ -438,7 +830,7 @@ export declare namespace useSuspenseQuery {
|
|
|
438
830
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
439
831
|
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
440
832
|
*/
|
|
441
|
-
<TData
|
|
833
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
442
834
|
errorPolicy: "ignore" | "all";
|
|
443
835
|
}): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
|
|
444
836
|
/**
|
|
@@ -486,7 +878,7 @@ export declare namespace useSuspenseQuery {
|
|
|
486
878
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
487
879
|
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
488
880
|
*/
|
|
489
|
-
<TData
|
|
881
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
490
882
|
skip: boolean;
|
|
491
883
|
returnPartialData: true;
|
|
492
884
|
}): useSuspenseQuery.Result<TData, TVariables, "complete" | "empty" | "streaming" | "partial">;
|
|
@@ -535,7 +927,7 @@ export declare namespace useSuspenseQuery {
|
|
|
535
927
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
536
928
|
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
537
929
|
*/
|
|
538
|
-
<TData
|
|
930
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
539
931
|
returnPartialData: true;
|
|
540
932
|
}): useSuspenseQuery.Result<TData, TVariables, "partial" | "streaming" | "complete">;
|
|
541
933
|
/**
|
|
@@ -583,7 +975,7 @@ export declare namespace useSuspenseQuery {
|
|
|
583
975
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
584
976
|
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
585
977
|
*/
|
|
586
|
-
<TData
|
|
978
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
587
979
|
skip: boolean;
|
|
588
980
|
}): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
|
|
589
981
|
/**
|
|
@@ -631,7 +1023,7 @@ export declare namespace useSuspenseQuery {
|
|
|
631
1023
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
632
1024
|
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
633
1025
|
*/
|
|
634
|
-
<TData
|
|
1026
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
635
1027
|
returnPartialData: true;
|
|
636
1028
|
})): useSuspenseQuery.Result<TData, TVariables, "empty" | "streaming" | "complete" | "partial">;
|
|
637
1029
|
/**
|
|
@@ -679,7 +1071,7 @@ export declare namespace useSuspenseQuery {
|
|
|
679
1071
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
680
1072
|
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
681
1073
|
*/
|
|
682
|
-
<TData
|
|
1074
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
683
1075
|
options?: useSuspenseQuery.Options<NoInfer<TVariables>>
|
|
684
1076
|
] : [options: useSuspenseQuery.Options<NoInfer<TVariables>>]): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming">;
|
|
685
1077
|
/**
|
|
@@ -727,7 +1119,7 @@ export declare namespace useSuspenseQuery {
|
|
|
727
1119
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
728
1120
|
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
729
1121
|
*/
|
|
730
|
-
<TData
|
|
1122
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
731
1123
|
options?: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>
|
|
732
1124
|
] : [options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>]): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
|
|
733
1125
|
/**
|
|
@@ -775,7 +1167,7 @@ export declare namespace useSuspenseQuery {
|
|
|
775
1167
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
776
1168
|
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
777
1169
|
*/
|
|
778
|
-
<TData
|
|
1170
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
|
|
779
1171
|
}
|
|
780
1172
|
/**
|
|
781
1173
|
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
package/__cjs/version.cjs
CHANGED
package/core/ApolloClient.d.ts
CHANGED
|
@@ -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
|
|
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 =
|
|
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
|
/**
|