@apollo/client 4.2.0-alpha.4 → 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 +12 -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 +1023 -23
- 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 +288 -19
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +409 -17
- 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 +1023 -23
- 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 +288 -19
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +409 -17
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +1023 -23
- 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 +288 -19
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +409 -17
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/version.js +1 -1
|
@@ -312,10 +312,6 @@ export declare namespace useBackgroundQuery {
|
|
|
312
312
|
}
|
|
313
313
|
namespace Signatures {
|
|
314
314
|
/**
|
|
315
|
-
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
316
|
-
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
315
|
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
320
316
|
*
|
|
321
317
|
* @returns A tuple containing:
|
|
@@ -377,6 +373,1010 @@ export declare namespace useBackgroundQuery {
|
|
|
377
373
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
378
374
|
*/
|
|
379
375
|
interface Classic {
|
|
376
|
+
/**
|
|
377
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
378
|
+
*
|
|
379
|
+
* @returns A tuple containing:
|
|
380
|
+
*
|
|
381
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
382
|
+
* 2. An object containing helper functions for the query:
|
|
383
|
+
* - `refetch`: A function to re-execute the query
|
|
384
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
385
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
*
|
|
389
|
+
* ```jsx
|
|
390
|
+
* import { Suspense } from "react";
|
|
391
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
392
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
393
|
+
*
|
|
394
|
+
* const query = gql`
|
|
395
|
+
* foo {
|
|
396
|
+
* bar
|
|
397
|
+
* }
|
|
398
|
+
* `;
|
|
399
|
+
*
|
|
400
|
+
* const client = new ApolloClient({
|
|
401
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
402
|
+
* cache: new InMemoryCache(),
|
|
403
|
+
* });
|
|
404
|
+
*
|
|
405
|
+
* function SuspenseFallback() {
|
|
406
|
+
* return <div>Loading...</div>;
|
|
407
|
+
* }
|
|
408
|
+
*
|
|
409
|
+
* function Child({ queryRef }) {
|
|
410
|
+
* const { data } = useReadQuery(queryRef);
|
|
411
|
+
*
|
|
412
|
+
* return <div>{data.foo.bar}</div>;
|
|
413
|
+
* }
|
|
414
|
+
*
|
|
415
|
+
* function Parent() {
|
|
416
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
417
|
+
*
|
|
418
|
+
* return (
|
|
419
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
420
|
+
* <Child queryRef={queryRef} />
|
|
421
|
+
* </Suspense>
|
|
422
|
+
* );
|
|
423
|
+
* }
|
|
424
|
+
*
|
|
425
|
+
* function App() {
|
|
426
|
+
* return (
|
|
427
|
+
* <ApolloProvider client={client}>
|
|
428
|
+
* <Parent />
|
|
429
|
+
* </ApolloProvider>
|
|
430
|
+
* );
|
|
431
|
+
* }
|
|
432
|
+
* ```
|
|
433
|
+
*
|
|
434
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
435
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
436
|
+
*/
|
|
437
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
438
|
+
/** @deprecated `returnPartialData` has no effect on `no-cache` queries */
|
|
439
|
+
returnPartialData: boolean;
|
|
440
|
+
fetchPolicy: "no-cache";
|
|
441
|
+
}): [
|
|
442
|
+
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
443
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
444
|
+
];
|
|
445
|
+
/**
|
|
446
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
447
|
+
*
|
|
448
|
+
* @returns A tuple containing:
|
|
449
|
+
*
|
|
450
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
451
|
+
* 2. An object containing helper functions for the query:
|
|
452
|
+
* - `refetch`: A function to re-execute the query
|
|
453
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
454
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
*
|
|
458
|
+
* ```jsx
|
|
459
|
+
* import { Suspense } from "react";
|
|
460
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
461
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
462
|
+
*
|
|
463
|
+
* const query = gql`
|
|
464
|
+
* foo {
|
|
465
|
+
* bar
|
|
466
|
+
* }
|
|
467
|
+
* `;
|
|
468
|
+
*
|
|
469
|
+
* const client = new ApolloClient({
|
|
470
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
471
|
+
* cache: new InMemoryCache(),
|
|
472
|
+
* });
|
|
473
|
+
*
|
|
474
|
+
* function SuspenseFallback() {
|
|
475
|
+
* return <div>Loading...</div>;
|
|
476
|
+
* }
|
|
477
|
+
*
|
|
478
|
+
* function Child({ queryRef }) {
|
|
479
|
+
* const { data } = useReadQuery(queryRef);
|
|
480
|
+
*
|
|
481
|
+
* return <div>{data.foo.bar}</div>;
|
|
482
|
+
* }
|
|
483
|
+
*
|
|
484
|
+
* function Parent() {
|
|
485
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
486
|
+
*
|
|
487
|
+
* return (
|
|
488
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
489
|
+
* <Child queryRef={queryRef} />
|
|
490
|
+
* </Suspense>
|
|
491
|
+
* );
|
|
492
|
+
* }
|
|
493
|
+
*
|
|
494
|
+
* function App() {
|
|
495
|
+
* return (
|
|
496
|
+
* <ApolloProvider client={client}>
|
|
497
|
+
* <Parent />
|
|
498
|
+
* </ApolloProvider>
|
|
499
|
+
* );
|
|
500
|
+
* }
|
|
501
|
+
* ```
|
|
502
|
+
*
|
|
503
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
504
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
505
|
+
*/
|
|
506
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
507
|
+
returnPartialData: false;
|
|
508
|
+
errorPolicy: "ignore" | "all";
|
|
509
|
+
}): [
|
|
510
|
+
QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
|
|
511
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
512
|
+
];
|
|
513
|
+
/**
|
|
514
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
515
|
+
*
|
|
516
|
+
* @returns A tuple containing:
|
|
517
|
+
*
|
|
518
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
519
|
+
* 2. An object containing helper functions for the query:
|
|
520
|
+
* - `refetch`: A function to re-execute the query
|
|
521
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
522
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
*
|
|
526
|
+
* ```jsx
|
|
527
|
+
* import { Suspense } from "react";
|
|
528
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
529
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
530
|
+
*
|
|
531
|
+
* const query = gql`
|
|
532
|
+
* foo {
|
|
533
|
+
* bar
|
|
534
|
+
* }
|
|
535
|
+
* `;
|
|
536
|
+
*
|
|
537
|
+
* const client = new ApolloClient({
|
|
538
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
539
|
+
* cache: new InMemoryCache(),
|
|
540
|
+
* });
|
|
541
|
+
*
|
|
542
|
+
* function SuspenseFallback() {
|
|
543
|
+
* return <div>Loading...</div>;
|
|
544
|
+
* }
|
|
545
|
+
*
|
|
546
|
+
* function Child({ queryRef }) {
|
|
547
|
+
* const { data } = useReadQuery(queryRef);
|
|
548
|
+
*
|
|
549
|
+
* return <div>{data.foo.bar}</div>;
|
|
550
|
+
* }
|
|
551
|
+
*
|
|
552
|
+
* function Parent() {
|
|
553
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
554
|
+
*
|
|
555
|
+
* return (
|
|
556
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
557
|
+
* <Child queryRef={queryRef} />
|
|
558
|
+
* </Suspense>
|
|
559
|
+
* );
|
|
560
|
+
* }
|
|
561
|
+
*
|
|
562
|
+
* function App() {
|
|
563
|
+
* return (
|
|
564
|
+
* <ApolloProvider client={client}>
|
|
565
|
+
* <Parent />
|
|
566
|
+
* </ApolloProvider>
|
|
567
|
+
* );
|
|
568
|
+
* }
|
|
569
|
+
* ```
|
|
570
|
+
*
|
|
571
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
572
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
573
|
+
*/
|
|
574
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
575
|
+
returnPartialData: boolean;
|
|
576
|
+
errorPolicy: "ignore" | "all";
|
|
577
|
+
}): [
|
|
578
|
+
QueryRef<TData, TVariables, "complete" | "streaming" | "partial" | "empty">,
|
|
579
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
580
|
+
];
|
|
581
|
+
/**
|
|
582
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
583
|
+
*
|
|
584
|
+
* @returns A tuple containing:
|
|
585
|
+
*
|
|
586
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
587
|
+
* 2. An object containing helper functions for the query:
|
|
588
|
+
* - `refetch`: A function to re-execute the query
|
|
589
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
590
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
591
|
+
*
|
|
592
|
+
* @example
|
|
593
|
+
*
|
|
594
|
+
* ```jsx
|
|
595
|
+
* import { Suspense } from "react";
|
|
596
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
597
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
598
|
+
*
|
|
599
|
+
* const query = gql`
|
|
600
|
+
* foo {
|
|
601
|
+
* bar
|
|
602
|
+
* }
|
|
603
|
+
* `;
|
|
604
|
+
*
|
|
605
|
+
* const client = new ApolloClient({
|
|
606
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
607
|
+
* cache: new InMemoryCache(),
|
|
608
|
+
* });
|
|
609
|
+
*
|
|
610
|
+
* function SuspenseFallback() {
|
|
611
|
+
* return <div>Loading...</div>;
|
|
612
|
+
* }
|
|
613
|
+
*
|
|
614
|
+
* function Child({ queryRef }) {
|
|
615
|
+
* const { data } = useReadQuery(queryRef);
|
|
616
|
+
*
|
|
617
|
+
* return <div>{data.foo.bar}</div>;
|
|
618
|
+
* }
|
|
619
|
+
*
|
|
620
|
+
* function Parent() {
|
|
621
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
622
|
+
*
|
|
623
|
+
* return (
|
|
624
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
625
|
+
* <Child queryRef={queryRef} />
|
|
626
|
+
* </Suspense>
|
|
627
|
+
* );
|
|
628
|
+
* }
|
|
629
|
+
*
|
|
630
|
+
* function App() {
|
|
631
|
+
* return (
|
|
632
|
+
* <ApolloProvider client={client}>
|
|
633
|
+
* <Parent />
|
|
634
|
+
* </ApolloProvider>
|
|
635
|
+
* );
|
|
636
|
+
* }
|
|
637
|
+
* ```
|
|
638
|
+
*
|
|
639
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
640
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
641
|
+
*/
|
|
642
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
643
|
+
errorPolicy: "ignore" | "all";
|
|
644
|
+
}): [
|
|
645
|
+
QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
|
|
646
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
647
|
+
];
|
|
648
|
+
/**
|
|
649
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
650
|
+
*
|
|
651
|
+
* @returns A tuple containing:
|
|
652
|
+
*
|
|
653
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
654
|
+
* 2. An object containing helper functions for the query:
|
|
655
|
+
* - `refetch`: A function to re-execute the query
|
|
656
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
657
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
658
|
+
*
|
|
659
|
+
* @example
|
|
660
|
+
*
|
|
661
|
+
* ```jsx
|
|
662
|
+
* import { Suspense } from "react";
|
|
663
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
664
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
665
|
+
*
|
|
666
|
+
* const query = gql`
|
|
667
|
+
* foo {
|
|
668
|
+
* bar
|
|
669
|
+
* }
|
|
670
|
+
* `;
|
|
671
|
+
*
|
|
672
|
+
* const client = new ApolloClient({
|
|
673
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
674
|
+
* cache: new InMemoryCache(),
|
|
675
|
+
* });
|
|
676
|
+
*
|
|
677
|
+
* function SuspenseFallback() {
|
|
678
|
+
* return <div>Loading...</div>;
|
|
679
|
+
* }
|
|
680
|
+
*
|
|
681
|
+
* function Child({ queryRef }) {
|
|
682
|
+
* const { data } = useReadQuery(queryRef);
|
|
683
|
+
*
|
|
684
|
+
* return <div>{data.foo.bar}</div>;
|
|
685
|
+
* }
|
|
686
|
+
*
|
|
687
|
+
* function Parent() {
|
|
688
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
689
|
+
*
|
|
690
|
+
* return (
|
|
691
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
692
|
+
* <Child queryRef={queryRef} />
|
|
693
|
+
* </Suspense>
|
|
694
|
+
* );
|
|
695
|
+
* }
|
|
696
|
+
*
|
|
697
|
+
* function App() {
|
|
698
|
+
* return (
|
|
699
|
+
* <ApolloProvider client={client}>
|
|
700
|
+
* <Parent />
|
|
701
|
+
* </ApolloProvider>
|
|
702
|
+
* );
|
|
703
|
+
* }
|
|
704
|
+
* ```
|
|
705
|
+
*
|
|
706
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
707
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
708
|
+
*/
|
|
709
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
710
|
+
skip: boolean;
|
|
711
|
+
returnPartialData: false;
|
|
712
|
+
}): [
|
|
713
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
714
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
715
|
+
];
|
|
716
|
+
/**
|
|
717
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
718
|
+
*
|
|
719
|
+
* @returns A tuple containing:
|
|
720
|
+
*
|
|
721
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
722
|
+
* 2. An object containing helper functions for the query:
|
|
723
|
+
* - `refetch`: A function to re-execute the query
|
|
724
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
725
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
726
|
+
*
|
|
727
|
+
* @example
|
|
728
|
+
*
|
|
729
|
+
* ```jsx
|
|
730
|
+
* import { Suspense } from "react";
|
|
731
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
732
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
733
|
+
*
|
|
734
|
+
* const query = gql`
|
|
735
|
+
* foo {
|
|
736
|
+
* bar
|
|
737
|
+
* }
|
|
738
|
+
* `;
|
|
739
|
+
*
|
|
740
|
+
* const client = new ApolloClient({
|
|
741
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
742
|
+
* cache: new InMemoryCache(),
|
|
743
|
+
* });
|
|
744
|
+
*
|
|
745
|
+
* function SuspenseFallback() {
|
|
746
|
+
* return <div>Loading...</div>;
|
|
747
|
+
* }
|
|
748
|
+
*
|
|
749
|
+
* function Child({ queryRef }) {
|
|
750
|
+
* const { data } = useReadQuery(queryRef);
|
|
751
|
+
*
|
|
752
|
+
* return <div>{data.foo.bar}</div>;
|
|
753
|
+
* }
|
|
754
|
+
*
|
|
755
|
+
* function Parent() {
|
|
756
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
757
|
+
*
|
|
758
|
+
* return (
|
|
759
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
760
|
+
* <Child queryRef={queryRef} />
|
|
761
|
+
* </Suspense>
|
|
762
|
+
* );
|
|
763
|
+
* }
|
|
764
|
+
*
|
|
765
|
+
* function App() {
|
|
766
|
+
* return (
|
|
767
|
+
* <ApolloProvider client={client}>
|
|
768
|
+
* <Parent />
|
|
769
|
+
* </ApolloProvider>
|
|
770
|
+
* );
|
|
771
|
+
* }
|
|
772
|
+
* ```
|
|
773
|
+
*
|
|
774
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
775
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
776
|
+
*/
|
|
777
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
778
|
+
skip: boolean;
|
|
779
|
+
returnPartialData: boolean;
|
|
780
|
+
}): [
|
|
781
|
+
(QueryRef<TData, TVariables, "complete" | "streaming" | "partial"> | undefined),
|
|
782
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
783
|
+
];
|
|
784
|
+
/**
|
|
785
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
786
|
+
*
|
|
787
|
+
* @returns A tuple containing:
|
|
788
|
+
*
|
|
789
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
790
|
+
* 2. An object containing helper functions for the query:
|
|
791
|
+
* - `refetch`: A function to re-execute the query
|
|
792
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
793
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
*
|
|
797
|
+
* ```jsx
|
|
798
|
+
* import { Suspense } from "react";
|
|
799
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
800
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
801
|
+
*
|
|
802
|
+
* const query = gql`
|
|
803
|
+
* foo {
|
|
804
|
+
* bar
|
|
805
|
+
* }
|
|
806
|
+
* `;
|
|
807
|
+
*
|
|
808
|
+
* const client = new ApolloClient({
|
|
809
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
810
|
+
* cache: new InMemoryCache(),
|
|
811
|
+
* });
|
|
812
|
+
*
|
|
813
|
+
* function SuspenseFallback() {
|
|
814
|
+
* return <div>Loading...</div>;
|
|
815
|
+
* }
|
|
816
|
+
*
|
|
817
|
+
* function Child({ queryRef }) {
|
|
818
|
+
* const { data } = useReadQuery(queryRef);
|
|
819
|
+
*
|
|
820
|
+
* return <div>{data.foo.bar}</div>;
|
|
821
|
+
* }
|
|
822
|
+
*
|
|
823
|
+
* function Parent() {
|
|
824
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
825
|
+
*
|
|
826
|
+
* return (
|
|
827
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
828
|
+
* <Child queryRef={queryRef} />
|
|
829
|
+
* </Suspense>
|
|
830
|
+
* );
|
|
831
|
+
* }
|
|
832
|
+
*
|
|
833
|
+
* function App() {
|
|
834
|
+
* return (
|
|
835
|
+
* <ApolloProvider client={client}>
|
|
836
|
+
* <Parent />
|
|
837
|
+
* </ApolloProvider>
|
|
838
|
+
* );
|
|
839
|
+
* }
|
|
840
|
+
* ```
|
|
841
|
+
*
|
|
842
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
843
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
844
|
+
*/
|
|
845
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
846
|
+
returnPartialData: false;
|
|
847
|
+
}): [
|
|
848
|
+
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
849
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
850
|
+
];
|
|
851
|
+
/**
|
|
852
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
853
|
+
*
|
|
854
|
+
* @returns A tuple containing:
|
|
855
|
+
*
|
|
856
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
857
|
+
* 2. An object containing helper functions for the query:
|
|
858
|
+
* - `refetch`: A function to re-execute the query
|
|
859
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
860
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
861
|
+
*
|
|
862
|
+
* @example
|
|
863
|
+
*
|
|
864
|
+
* ```jsx
|
|
865
|
+
* import { Suspense } from "react";
|
|
866
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
867
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
868
|
+
*
|
|
869
|
+
* const query = gql`
|
|
870
|
+
* foo {
|
|
871
|
+
* bar
|
|
872
|
+
* }
|
|
873
|
+
* `;
|
|
874
|
+
*
|
|
875
|
+
* const client = new ApolloClient({
|
|
876
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
877
|
+
* cache: new InMemoryCache(),
|
|
878
|
+
* });
|
|
879
|
+
*
|
|
880
|
+
* function SuspenseFallback() {
|
|
881
|
+
* return <div>Loading...</div>;
|
|
882
|
+
* }
|
|
883
|
+
*
|
|
884
|
+
* function Child({ queryRef }) {
|
|
885
|
+
* const { data } = useReadQuery(queryRef);
|
|
886
|
+
*
|
|
887
|
+
* return <div>{data.foo.bar}</div>;
|
|
888
|
+
* }
|
|
889
|
+
*
|
|
890
|
+
* function Parent() {
|
|
891
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
892
|
+
*
|
|
893
|
+
* return (
|
|
894
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
895
|
+
* <Child queryRef={queryRef} />
|
|
896
|
+
* </Suspense>
|
|
897
|
+
* );
|
|
898
|
+
* }
|
|
899
|
+
*
|
|
900
|
+
* function App() {
|
|
901
|
+
* return (
|
|
902
|
+
* <ApolloProvider client={client}>
|
|
903
|
+
* <Parent />
|
|
904
|
+
* </ApolloProvider>
|
|
905
|
+
* );
|
|
906
|
+
* }
|
|
907
|
+
* ```
|
|
908
|
+
*
|
|
909
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
910
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
911
|
+
*/
|
|
912
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
913
|
+
returnPartialData: boolean;
|
|
914
|
+
}): [
|
|
915
|
+
QueryRef<TData, TVariables, "complete" | "streaming" | "partial">,
|
|
916
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
917
|
+
];
|
|
918
|
+
/**
|
|
919
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
920
|
+
*
|
|
921
|
+
* @returns A tuple containing:
|
|
922
|
+
*
|
|
923
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
924
|
+
* 2. An object containing helper functions for the query:
|
|
925
|
+
* - `refetch`: A function to re-execute the query
|
|
926
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
927
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
928
|
+
*
|
|
929
|
+
* @example
|
|
930
|
+
*
|
|
931
|
+
* ```jsx
|
|
932
|
+
* import { Suspense } from "react";
|
|
933
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
934
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
935
|
+
*
|
|
936
|
+
* const query = gql`
|
|
937
|
+
* foo {
|
|
938
|
+
* bar
|
|
939
|
+
* }
|
|
940
|
+
* `;
|
|
941
|
+
*
|
|
942
|
+
* const client = new ApolloClient({
|
|
943
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
944
|
+
* cache: new InMemoryCache(),
|
|
945
|
+
* });
|
|
946
|
+
*
|
|
947
|
+
* function SuspenseFallback() {
|
|
948
|
+
* return <div>Loading...</div>;
|
|
949
|
+
* }
|
|
950
|
+
*
|
|
951
|
+
* function Child({ queryRef }) {
|
|
952
|
+
* const { data } = useReadQuery(queryRef);
|
|
953
|
+
*
|
|
954
|
+
* return <div>{data.foo.bar}</div>;
|
|
955
|
+
* }
|
|
956
|
+
*
|
|
957
|
+
* function Parent() {
|
|
958
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
959
|
+
*
|
|
960
|
+
* return (
|
|
961
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
962
|
+
* <Child queryRef={queryRef} />
|
|
963
|
+
* </Suspense>
|
|
964
|
+
* );
|
|
965
|
+
* }
|
|
966
|
+
*
|
|
967
|
+
* function App() {
|
|
968
|
+
* return (
|
|
969
|
+
* <ApolloProvider client={client}>
|
|
970
|
+
* <Parent />
|
|
971
|
+
* </ApolloProvider>
|
|
972
|
+
* );
|
|
973
|
+
* }
|
|
974
|
+
* ```
|
|
975
|
+
*
|
|
976
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
977
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
978
|
+
*/
|
|
979
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
980
|
+
skip: boolean;
|
|
981
|
+
}): [
|
|
982
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
983
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
984
|
+
];
|
|
985
|
+
/**
|
|
986
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
987
|
+
*
|
|
988
|
+
* @returns A tuple containing:
|
|
989
|
+
*
|
|
990
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
991
|
+
* 2. An object containing helper functions for the query:
|
|
992
|
+
* - `refetch`: A function to re-execute the query
|
|
993
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
994
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
*
|
|
998
|
+
* ```jsx
|
|
999
|
+
* import { Suspense } from "react";
|
|
1000
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1001
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1002
|
+
*
|
|
1003
|
+
* const query = gql`
|
|
1004
|
+
* foo {
|
|
1005
|
+
* bar
|
|
1006
|
+
* }
|
|
1007
|
+
* `;
|
|
1008
|
+
*
|
|
1009
|
+
* const client = new ApolloClient({
|
|
1010
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1011
|
+
* cache: new InMemoryCache(),
|
|
1012
|
+
* });
|
|
1013
|
+
*
|
|
1014
|
+
* function SuspenseFallback() {
|
|
1015
|
+
* return <div>Loading...</div>;
|
|
1016
|
+
* }
|
|
1017
|
+
*
|
|
1018
|
+
* function Child({ queryRef }) {
|
|
1019
|
+
* const { data } = useReadQuery(queryRef);
|
|
1020
|
+
*
|
|
1021
|
+
* return <div>{data.foo.bar}</div>;
|
|
1022
|
+
* }
|
|
1023
|
+
*
|
|
1024
|
+
* function Parent() {
|
|
1025
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1026
|
+
*
|
|
1027
|
+
* return (
|
|
1028
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1029
|
+
* <Child queryRef={queryRef} />
|
|
1030
|
+
* </Suspense>
|
|
1031
|
+
* );
|
|
1032
|
+
* }
|
|
1033
|
+
*
|
|
1034
|
+
* function App() {
|
|
1035
|
+
* return (
|
|
1036
|
+
* <ApolloProvider client={client}>
|
|
1037
|
+
* <Parent />
|
|
1038
|
+
* </ApolloProvider>
|
|
1039
|
+
* );
|
|
1040
|
+
* }
|
|
1041
|
+
* ```
|
|
1042
|
+
*
|
|
1043
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1044
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1045
|
+
*/
|
|
1046
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): [undefined, useBackgroundQuery.Result<TData, TVariables>];
|
|
1047
|
+
/**
|
|
1048
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1049
|
+
*
|
|
1050
|
+
* @returns A tuple containing:
|
|
1051
|
+
*
|
|
1052
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1053
|
+
* 2. An object containing helper functions for the query:
|
|
1054
|
+
* - `refetch`: A function to re-execute the query
|
|
1055
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1056
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1057
|
+
*
|
|
1058
|
+
* @example
|
|
1059
|
+
*
|
|
1060
|
+
* ```jsx
|
|
1061
|
+
* import { Suspense } from "react";
|
|
1062
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1063
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1064
|
+
*
|
|
1065
|
+
* const query = gql`
|
|
1066
|
+
* foo {
|
|
1067
|
+
* bar
|
|
1068
|
+
* }
|
|
1069
|
+
* `;
|
|
1070
|
+
*
|
|
1071
|
+
* const client = new ApolloClient({
|
|
1072
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1073
|
+
* cache: new InMemoryCache(),
|
|
1074
|
+
* });
|
|
1075
|
+
*
|
|
1076
|
+
* function SuspenseFallback() {
|
|
1077
|
+
* return <div>Loading...</div>;
|
|
1078
|
+
* }
|
|
1079
|
+
*
|
|
1080
|
+
* function Child({ queryRef }) {
|
|
1081
|
+
* const { data } = useReadQuery(queryRef);
|
|
1082
|
+
*
|
|
1083
|
+
* return <div>{data.foo.bar}</div>;
|
|
1084
|
+
* }
|
|
1085
|
+
*
|
|
1086
|
+
* function Parent() {
|
|
1087
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1088
|
+
*
|
|
1089
|
+
* return (
|
|
1090
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1091
|
+
* <Child queryRef={queryRef} />
|
|
1092
|
+
* </Suspense>
|
|
1093
|
+
* );
|
|
1094
|
+
* }
|
|
1095
|
+
*
|
|
1096
|
+
* function App() {
|
|
1097
|
+
* return (
|
|
1098
|
+
* <ApolloProvider client={client}>
|
|
1099
|
+
* <Parent />
|
|
1100
|
+
* </ApolloProvider>
|
|
1101
|
+
* );
|
|
1102
|
+
* }
|
|
1103
|
+
* ```
|
|
1104
|
+
*
|
|
1105
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1106
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1107
|
+
*/
|
|
1108
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
1109
|
+
returnPartialData: false;
|
|
1110
|
+
})): [
|
|
1111
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
1112
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
1113
|
+
];
|
|
1114
|
+
/**
|
|
1115
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1116
|
+
*
|
|
1117
|
+
* @returns A tuple containing:
|
|
1118
|
+
*
|
|
1119
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1120
|
+
* 2. An object containing helper functions for the query:
|
|
1121
|
+
* - `refetch`: A function to re-execute the query
|
|
1122
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1123
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1124
|
+
*
|
|
1125
|
+
* @example
|
|
1126
|
+
*
|
|
1127
|
+
* ```jsx
|
|
1128
|
+
* import { Suspense } from "react";
|
|
1129
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1130
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1131
|
+
*
|
|
1132
|
+
* const query = gql`
|
|
1133
|
+
* foo {
|
|
1134
|
+
* bar
|
|
1135
|
+
* }
|
|
1136
|
+
* `;
|
|
1137
|
+
*
|
|
1138
|
+
* const client = new ApolloClient({
|
|
1139
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1140
|
+
* cache: new InMemoryCache(),
|
|
1141
|
+
* });
|
|
1142
|
+
*
|
|
1143
|
+
* function SuspenseFallback() {
|
|
1144
|
+
* return <div>Loading...</div>;
|
|
1145
|
+
* }
|
|
1146
|
+
*
|
|
1147
|
+
* function Child({ queryRef }) {
|
|
1148
|
+
* const { data } = useReadQuery(queryRef);
|
|
1149
|
+
*
|
|
1150
|
+
* return <div>{data.foo.bar}</div>;
|
|
1151
|
+
* }
|
|
1152
|
+
*
|
|
1153
|
+
* function Parent() {
|
|
1154
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1155
|
+
*
|
|
1156
|
+
* return (
|
|
1157
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1158
|
+
* <Child queryRef={queryRef} />
|
|
1159
|
+
* </Suspense>
|
|
1160
|
+
* );
|
|
1161
|
+
* }
|
|
1162
|
+
*
|
|
1163
|
+
* function App() {
|
|
1164
|
+
* return (
|
|
1165
|
+
* <ApolloProvider client={client}>
|
|
1166
|
+
* <Parent />
|
|
1167
|
+
* </ApolloProvider>
|
|
1168
|
+
* );
|
|
1169
|
+
* }
|
|
1170
|
+
* ```
|
|
1171
|
+
*
|
|
1172
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1173
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1174
|
+
*/
|
|
1175
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
1176
|
+
returnPartialData: boolean;
|
|
1177
|
+
})): [
|
|
1178
|
+
(QueryRef<TData, TVariables, "complete" | "streaming" | "partial"> | undefined),
|
|
1179
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
1180
|
+
];
|
|
1181
|
+
/**
|
|
1182
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1183
|
+
*
|
|
1184
|
+
* @returns A tuple containing:
|
|
1185
|
+
*
|
|
1186
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1187
|
+
* 2. An object containing helper functions for the query:
|
|
1188
|
+
* - `refetch`: A function to re-execute the query
|
|
1189
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1190
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1191
|
+
*
|
|
1192
|
+
* @example
|
|
1193
|
+
*
|
|
1194
|
+
* ```jsx
|
|
1195
|
+
* import { Suspense } from "react";
|
|
1196
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1197
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1198
|
+
*
|
|
1199
|
+
* const query = gql`
|
|
1200
|
+
* foo {
|
|
1201
|
+
* bar
|
|
1202
|
+
* }
|
|
1203
|
+
* `;
|
|
1204
|
+
*
|
|
1205
|
+
* const client = new ApolloClient({
|
|
1206
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1207
|
+
* cache: new InMemoryCache(),
|
|
1208
|
+
* });
|
|
1209
|
+
*
|
|
1210
|
+
* function SuspenseFallback() {
|
|
1211
|
+
* return <div>Loading...</div>;
|
|
1212
|
+
* }
|
|
1213
|
+
*
|
|
1214
|
+
* function Child({ queryRef }) {
|
|
1215
|
+
* const { data } = useReadQuery(queryRef);
|
|
1216
|
+
*
|
|
1217
|
+
* return <div>{data.foo.bar}</div>;
|
|
1218
|
+
* }
|
|
1219
|
+
*
|
|
1220
|
+
* function Parent() {
|
|
1221
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1222
|
+
*
|
|
1223
|
+
* return (
|
|
1224
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1225
|
+
* <Child queryRef={queryRef} />
|
|
1226
|
+
* </Suspense>
|
|
1227
|
+
* );
|
|
1228
|
+
* }
|
|
1229
|
+
*
|
|
1230
|
+
* function App() {
|
|
1231
|
+
* return (
|
|
1232
|
+
* <ApolloProvider client={client}>
|
|
1233
|
+
* <Parent />
|
|
1234
|
+
* </ApolloProvider>
|
|
1235
|
+
* );
|
|
1236
|
+
* }
|
|
1237
|
+
* ```
|
|
1238
|
+
*
|
|
1239
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1240
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1241
|
+
*/
|
|
1242
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
1243
|
+
options?: useBackgroundQuery.Options<NoInfer<TVariables>>
|
|
1244
|
+
] : [options: useBackgroundQuery.Options<NoInfer<TVariables>>]): [
|
|
1245
|
+
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
1246
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
1247
|
+
];
|
|
1248
|
+
/**
|
|
1249
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1250
|
+
*
|
|
1251
|
+
* @returns A tuple containing:
|
|
1252
|
+
*
|
|
1253
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1254
|
+
* 2. An object containing helper functions for the query:
|
|
1255
|
+
* - `refetch`: A function to re-execute the query
|
|
1256
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1257
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1258
|
+
*
|
|
1259
|
+
* @example
|
|
1260
|
+
*
|
|
1261
|
+
* ```jsx
|
|
1262
|
+
* import { Suspense } from "react";
|
|
1263
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1264
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1265
|
+
*
|
|
1266
|
+
* const query = gql`
|
|
1267
|
+
* foo {
|
|
1268
|
+
* bar
|
|
1269
|
+
* }
|
|
1270
|
+
* `;
|
|
1271
|
+
*
|
|
1272
|
+
* const client = new ApolloClient({
|
|
1273
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1274
|
+
* cache: new InMemoryCache(),
|
|
1275
|
+
* });
|
|
1276
|
+
*
|
|
1277
|
+
* function SuspenseFallback() {
|
|
1278
|
+
* return <div>Loading...</div>;
|
|
1279
|
+
* }
|
|
1280
|
+
*
|
|
1281
|
+
* function Child({ queryRef }) {
|
|
1282
|
+
* const { data } = useReadQuery(queryRef);
|
|
1283
|
+
*
|
|
1284
|
+
* return <div>{data.foo.bar}</div>;
|
|
1285
|
+
* }
|
|
1286
|
+
*
|
|
1287
|
+
* function Parent() {
|
|
1288
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1289
|
+
*
|
|
1290
|
+
* return (
|
|
1291
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1292
|
+
* <Child queryRef={queryRef} />
|
|
1293
|
+
* </Suspense>
|
|
1294
|
+
* );
|
|
1295
|
+
* }
|
|
1296
|
+
*
|
|
1297
|
+
* function App() {
|
|
1298
|
+
* return (
|
|
1299
|
+
* <ApolloProvider client={client}>
|
|
1300
|
+
* <Parent />
|
|
1301
|
+
* </ApolloProvider>
|
|
1302
|
+
* );
|
|
1303
|
+
* }
|
|
1304
|
+
* ```
|
|
1305
|
+
*
|
|
1306
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1307
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1308
|
+
*/
|
|
1309
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
1310
|
+
options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>
|
|
1311
|
+
] : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]): [
|
|
1312
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
1313
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
1314
|
+
];
|
|
1315
|
+
/**
|
|
1316
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1317
|
+
*
|
|
1318
|
+
* @returns A tuple containing:
|
|
1319
|
+
*
|
|
1320
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1321
|
+
* 2. An object containing helper functions for the query:
|
|
1322
|
+
* - `refetch`: A function to re-execute the query
|
|
1323
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1324
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1325
|
+
*
|
|
1326
|
+
* @example
|
|
1327
|
+
*
|
|
1328
|
+
* ```jsx
|
|
1329
|
+
* import { Suspense } from "react";
|
|
1330
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1331
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1332
|
+
*
|
|
1333
|
+
* const query = gql`
|
|
1334
|
+
* foo {
|
|
1335
|
+
* bar
|
|
1336
|
+
* }
|
|
1337
|
+
* `;
|
|
1338
|
+
*
|
|
1339
|
+
* const client = new ApolloClient({
|
|
1340
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1341
|
+
* cache: new InMemoryCache(),
|
|
1342
|
+
* });
|
|
1343
|
+
*
|
|
1344
|
+
* function SuspenseFallback() {
|
|
1345
|
+
* return <div>Loading...</div>;
|
|
1346
|
+
* }
|
|
1347
|
+
*
|
|
1348
|
+
* function Child({ queryRef }) {
|
|
1349
|
+
* const { data } = useReadQuery(queryRef);
|
|
1350
|
+
*
|
|
1351
|
+
* return <div>{data.foo.bar}</div>;
|
|
1352
|
+
* }
|
|
1353
|
+
*
|
|
1354
|
+
* function Parent() {
|
|
1355
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1356
|
+
*
|
|
1357
|
+
* return (
|
|
1358
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1359
|
+
* <Child queryRef={queryRef} />
|
|
1360
|
+
* </Suspense>
|
|
1361
|
+
* );
|
|
1362
|
+
* }
|
|
1363
|
+
*
|
|
1364
|
+
* function App() {
|
|
1365
|
+
* return (
|
|
1366
|
+
* <ApolloProvider client={client}>
|
|
1367
|
+
* <Parent />
|
|
1368
|
+
* </ApolloProvider>
|
|
1369
|
+
* );
|
|
1370
|
+
* }
|
|
1371
|
+
* ```
|
|
1372
|
+
*
|
|
1373
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1374
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1375
|
+
*/
|
|
1376
|
+
<TData, TVariables extends OperationVariables, _INFERENCE_ONLY_DO_NOT_SPECIFY extends "inferred">(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>): [
|
|
1377
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
1378
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
1379
|
+
];
|
|
380
1380
|
/**
|
|
381
1381
|
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
382
1382
|
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
@@ -442,7 +1442,7 @@ export declare namespace useBackgroundQuery {
|
|
|
442
1442
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
443
1443
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
444
1444
|
*/
|
|
445
|
-
<TData
|
|
1445
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
446
1446
|
/** @deprecated `returnPartialData` has no effect on `no-cache` queries */
|
|
447
1447
|
returnPartialData: boolean;
|
|
448
1448
|
fetchPolicy: "no-cache";
|
|
@@ -515,7 +1515,7 @@ export declare namespace useBackgroundQuery {
|
|
|
515
1515
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
516
1516
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
517
1517
|
*/
|
|
518
|
-
<TData
|
|
1518
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
519
1519
|
returnPartialData: false;
|
|
520
1520
|
errorPolicy: "ignore" | "all";
|
|
521
1521
|
}): [
|
|
@@ -587,7 +1587,7 @@ export declare namespace useBackgroundQuery {
|
|
|
587
1587
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
588
1588
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
589
1589
|
*/
|
|
590
|
-
<TData
|
|
1590
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
591
1591
|
returnPartialData: boolean;
|
|
592
1592
|
errorPolicy: "ignore" | "all";
|
|
593
1593
|
}): [
|
|
@@ -659,7 +1659,7 @@ export declare namespace useBackgroundQuery {
|
|
|
659
1659
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
660
1660
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
661
1661
|
*/
|
|
662
|
-
<TData
|
|
1662
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
663
1663
|
errorPolicy: "ignore" | "all";
|
|
664
1664
|
}): [
|
|
665
1665
|
QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
|
|
@@ -730,7 +1730,7 @@ export declare namespace useBackgroundQuery {
|
|
|
730
1730
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
731
1731
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
732
1732
|
*/
|
|
733
|
-
<TData
|
|
1733
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
734
1734
|
skip: boolean;
|
|
735
1735
|
returnPartialData: false;
|
|
736
1736
|
}): [
|
|
@@ -802,7 +1802,7 @@ export declare namespace useBackgroundQuery {
|
|
|
802
1802
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
803
1803
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
804
1804
|
*/
|
|
805
|
-
<TData
|
|
1805
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
806
1806
|
skip: boolean;
|
|
807
1807
|
returnPartialData: boolean;
|
|
808
1808
|
}): [
|
|
@@ -874,7 +1874,7 @@ export declare namespace useBackgroundQuery {
|
|
|
874
1874
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
875
1875
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
876
1876
|
*/
|
|
877
|
-
<TData
|
|
1877
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
878
1878
|
returnPartialData: false;
|
|
879
1879
|
}): [
|
|
880
1880
|
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
@@ -945,7 +1945,7 @@ export declare namespace useBackgroundQuery {
|
|
|
945
1945
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
946
1946
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
947
1947
|
*/
|
|
948
|
-
<TData
|
|
1948
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
949
1949
|
returnPartialData: boolean;
|
|
950
1950
|
}): [
|
|
951
1951
|
QueryRef<TData, TVariables, "complete" | "streaming" | "partial">,
|
|
@@ -1016,7 +2016,7 @@ export declare namespace useBackgroundQuery {
|
|
|
1016
2016
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1017
2017
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1018
2018
|
*/
|
|
1019
|
-
<TData
|
|
2019
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
1020
2020
|
skip: boolean;
|
|
1021
2021
|
}): [
|
|
1022
2022
|
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
@@ -1087,7 +2087,7 @@ export declare namespace useBackgroundQuery {
|
|
|
1087
2087
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1088
2088
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1089
2089
|
*/
|
|
1090
|
-
<TData
|
|
2090
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): [undefined, useBackgroundQuery.Result<TData, TVariables>];
|
|
1091
2091
|
/**
|
|
1092
2092
|
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
1093
2093
|
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
@@ -1153,7 +2153,7 @@ export declare namespace useBackgroundQuery {
|
|
|
1153
2153
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1154
2154
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1155
2155
|
*/
|
|
1156
|
-
<TData
|
|
2156
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
1157
2157
|
returnPartialData: false;
|
|
1158
2158
|
})): [
|
|
1159
2159
|
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
@@ -1224,7 +2224,7 @@ export declare namespace useBackgroundQuery {
|
|
|
1224
2224
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1225
2225
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1226
2226
|
*/
|
|
1227
|
-
<TData
|
|
2227
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
1228
2228
|
returnPartialData: boolean;
|
|
1229
2229
|
})): [
|
|
1230
2230
|
(QueryRef<TData, TVariables, "complete" | "streaming" | "partial"> | undefined),
|
|
@@ -1295,7 +2295,7 @@ export declare namespace useBackgroundQuery {
|
|
|
1295
2295
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1296
2296
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1297
2297
|
*/
|
|
1298
|
-
<TData
|
|
2298
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
1299
2299
|
options?: useBackgroundQuery.Options<NoInfer<TVariables>>
|
|
1300
2300
|
] : [options: useBackgroundQuery.Options<NoInfer<TVariables>>]): [
|
|
1301
2301
|
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
@@ -1366,7 +2366,7 @@ export declare namespace useBackgroundQuery {
|
|
|
1366
2366
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1367
2367
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1368
2368
|
*/
|
|
1369
|
-
<TData
|
|
2369
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
1370
2370
|
options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>
|
|
1371
2371
|
] : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]): [
|
|
1372
2372
|
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
@@ -1437,7 +2437,7 @@ export declare namespace useBackgroundQuery {
|
|
|
1437
2437
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1438
2438
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1439
2439
|
*/
|
|
1440
|
-
<TData
|
|
2440
|
+
<TData, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>): [
|
|
1441
2441
|
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
1442
2442
|
useBackgroundQuery.Result<TData, TVariables>
|
|
1443
2443
|
];
|
|
@@ -1627,7 +2627,9 @@ export declare namespace useBackgroundQuery {
|
|
|
1627
2627
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1628
2628
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1629
2629
|
*/
|
|
1630
|
-
<TData, TVariables extends OperationVariables, TOptions extends
|
|
2630
|
+
<TData, TVariables extends OperationVariables, TOptions extends useBackgroundQuery.Options<NoInfer<TVariables>> & VariablesOption<TVariables & {
|
|
2631
|
+
[K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
|
|
2632
|
+
}>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [options?: TOptions] : [options: TOptions]): useBackgroundQuery.ResultForOptions<TData, TVariables, TOptions>;
|
|
1631
2633
|
/**
|
|
1632
2634
|
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1633
2635
|
*
|
|
@@ -1689,9 +2691,7 @@ export declare namespace useBackgroundQuery {
|
|
|
1689
2691
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1690
2692
|
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
1691
2693
|
*/
|
|
1692
|
-
<TData, TVariables extends OperationVariables, TOptions extends
|
|
1693
|
-
[K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
|
|
1694
|
-
}>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [options?: TOptions] : [options: TOptions]): useBackgroundQuery.ResultForOptions<TData, TVariables, TOptions>;
|
|
2694
|
+
<TData, TVariables extends OperationVariables, TOptions extends never>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, skipToken: SkipToken): useBackgroundQuery.ResultForOptions<TData, TVariables, SkipToken>;
|
|
1695
2695
|
/**
|
|
1696
2696
|
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1697
2697
|
*
|