@apollo/client 4.2.10 → 4.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/__cjs/cache/core/cache.cjs +1 -1
  3. package/__cjs/cache/inmemory/entityStore.cjs +3 -3
  4. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  5. package/__cjs/cache/inmemory/policies.cjs +4 -4
  6. package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
  7. package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
  8. package/__cjs/core/QueryInfo.cjs +24 -1
  9. package/__cjs/core/QueryInfo.cjs.map +1 -1
  10. package/__cjs/core/QueryManager.cjs +12 -12
  11. package/__cjs/core/RefetchEventManager.cjs +3 -3
  12. package/__cjs/invariantErrorCodes.cjs +49 -30
  13. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  14. package/__cjs/react/hooks/useBackgroundQuery.d.cts +10 -2
  15. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  16. package/__cjs/react/hooks/useQuery.d.cts +9 -1
  17. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  18. package/__cjs/react/hooks/useSuspenseQuery.d.cts +9 -1
  19. package/__cjs/version.cjs +1 -1
  20. package/cache/core/cache.js +1 -1
  21. package/cache/inmemory/entityStore.js +3 -3
  22. package/cache/inmemory/key-extractor.js +1 -1
  23. package/cache/inmemory/policies.js +4 -4
  24. package/cache/inmemory/readFromStore.js +2 -2
  25. package/cache/inmemory/writeToStore.js +4 -4
  26. package/core/QueryInfo.js +19 -0
  27. package/core/QueryInfo.js.map +1 -1
  28. package/core/QueryManager.js +12 -12
  29. package/core/QueryManager.js.map +1 -1
  30. package/core/RefetchEventManager.js +3 -3
  31. package/invariantErrorCodes.js +49 -30
  32. package/package.json +1 -1
  33. package/react/hooks/useBackgroundQuery.d.ts +10 -2
  34. package/react/hooks/useBackgroundQuery.js.map +1 -1
  35. package/react/hooks/useQuery.d.ts +9 -1
  36. package/react/hooks/useQuery.js.map +1 -1
  37. package/react/hooks/useSuspenseQuery.d.ts +9 -1
  38. package/react/hooks/useSuspenseQuery.js.map +1 -1
  39. package/react/hooks-compiled/useBackgroundQuery.d.ts +10 -2
  40. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  41. package/react/hooks-compiled/useQuery.d.ts +9 -1
  42. package/react/hooks-compiled/useQuery.js.map +1 -1
  43. package/react/hooks-compiled/useSuspenseQuery.d.ts +9 -1
  44. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  45. package/version.js +1 -1
@@ -27,7 +27,7 @@ export class RefetchEventManager {
27
27
  }
28
28
  if (this.client) {
29
29
  if (__DEV__) {
30
- __DEV__ && invariant.warn(101);
30
+ __DEV__ && invariant.warn(102);
31
31
  }
32
32
  this.disconnect();
33
33
  }
@@ -96,13 +96,13 @@ export class RefetchEventManager {
96
96
  const [payload] = args;
97
97
  if (!this.client) {
98
98
  if (__DEV__) {
99
- __DEV__ && invariant.warn(102, source);
99
+ __DEV__ && invariant.warn(103, source);
100
100
  }
101
101
  return;
102
102
  }
103
103
  if (!this.hasSource(source)) {
104
104
  if (__DEV__) {
105
- __DEV__ && invariant.warn(103, source);
105
+ __DEV__ && invariant.warn(104, source);
106
106
  }
107
107
  return;
108
108
  }
@@ -444,98 +444,98 @@ const client = new ApolloClient({
444
444
  message: "You must provide an `updateQuery` function when using `fetchMore` with a `no-cache` fetch policy."
445
445
  },
446
446
 
447
- 89: {
447
+ 90: {
448
448
  file: "@apollo/client/core/QueryManager.js",
449
449
  message: "QueryManager stopped while query was in flight"
450
450
  },
451
451
 
452
- 90: {
452
+ 91: {
453
453
  file: "@apollo/client/core/QueryManager.js",
454
454
  condition: "this.localState",
455
455
  message: "Mutation '%s' contains `@client` fields with variables provided by `@export` but local state has not been configured."
456
456
  },
457
457
 
458
- 91: {
458
+ 92: {
459
459
  file: "@apollo/client/core/QueryManager.js",
460
460
  message: "Store reset while query was in flight (not completed in link chain)"
461
461
  },
462
462
 
463
- 94: {
463
+ 95: {
464
464
  file: "@apollo/client/core/QueryManager.js",
465
465
  condition: "!this.getDocumentInfo(query).hasClientExports || this.localState",
466
466
  message: "Subscription '%s' contains `@client` fields with variables provided by `@export` but local state has not been configured."
467
467
  },
468
468
 
469
- 95: {
469
+ 96: {
470
470
  file: "@apollo/client/core/QueryManager.js",
471
471
  condition: "this.localState",
472
472
  message: "%s '%s' contains `@client` fields but local state has not been configured."
473
473
  },
474
474
 
475
- 96: {
475
+ 97: {
476
476
  file: "@apollo/client/core/QueryManager.js",
477
477
  condition: "!hasIncrementalDirective",
478
478
  message: "%s '%s' contains `@client` and `@defer` directives. These cannot be used together."
479
479
  },
480
480
 
481
- 97: {
481
+ 98: {
482
482
  file: "@apollo/client/core/QueryManager.js",
483
483
  condition: "this.localState",
484
484
  message: "Query '%s' contains `@client` fields with variables provided by `@export` but local state has not been configured."
485
485
  },
486
486
 
487
- 99: {
487
+ 100: {
488
488
  file: "@apollo/client/core/QueryManager.js",
489
489
  condition: "this.localState",
490
490
  message: "Query '%s' contains `@client` fields but local state has not been configured."
491
491
  },
492
492
 
493
- 100: {
493
+ 101: {
494
494
  file: "@apollo/client/core/QueryManager.js",
495
495
  condition: "didEmitValue",
496
496
  message: "The link chain completed without emitting a value. This is likely unintentional and should be updated to emit a value before completing."
497
497
  },
498
498
 
499
- 104: {
499
+ 105: {
500
500
  file: "@apollo/client/cache/inmemory/entityStore.js",
501
501
  condition: "typeof dataId === \"string\"",
502
502
  message: "store.merge expects a string ID"
503
503
  },
504
504
 
505
- 107: {
505
+ 108: {
506
506
  file: "@apollo/client/cache/inmemory/key-extractor.js",
507
507
  condition: "extracted !== void 0",
508
508
  message: `Missing field '%s' while extracting keyFields from %s`
509
509
  },
510
510
 
511
- 108: {
511
+ 109: {
512
512
  file: "@apollo/client/cache/inmemory/policies.js",
513
513
  condition: "!old || old === which",
514
514
  message: `Cannot change root %s __typename more than once`
515
515
  },
516
516
 
517
- 111: {
517
+ 112: {
518
518
  file: "@apollo/client/cache/inmemory/policies.js",
519
519
  message: "Cannot automatically merge arrays"
520
520
  },
521
521
 
522
- 112: {
522
+ 113: {
523
523
  file: "@apollo/client/cache/inmemory/readFromStore.js",
524
524
  message: `No fragment named %s`
525
525
  },
526
526
 
527
- 113: {
527
+ 114: {
528
528
  file: "@apollo/client/cache/inmemory/readFromStore.js",
529
529
  condition: "!isReference(value)",
530
530
  message: `Missing selection set for object of type %s returned for query field %s`
531
531
  },
532
532
 
533
- 114: {
533
+ 115: {
534
534
  file: "@apollo/client/cache/inmemory/writeToStore.js",
535
535
  message: `Could not identify object %s`
536
536
  },
537
537
 
538
- 116: {
538
+ 117: {
539
539
  file: "@apollo/client/cache/inmemory/writeToStore.js",
540
540
  message: `No fragment named %s`
541
541
  }
@@ -647,37 +647,56 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`
647
647
  message: "Cannot poll on 'cache-only' query '%s' and as such, polling is disabled. Please use a different fetch policy."
648
648
  },
649
649
 
650
- 92: {
650
+ 89: {
651
+ file: "@apollo/client/core/QueryInfo.js",
652
+
653
+ message: `The network result for query %s was written to the cache, but reading it back returned a partial result.
654
+
655
+ A \`read\` or \`merge\` function left missing fields after this write. Because the cache result is incomplete, Apollo Client cannot apply it to the network result. The raw network result was returned instead, and doesn't include any transformed values returned from \`read\` functions.
656
+
657
+ To address this problem (which is not a bug in Apollo Client), check the \`read\` and \`merge\` functions for the fields in this query. A \`read\` or \`merge\` function that leaves missing fields leaves the cache unable to fulfill the query's data requirements.
658
+
659
+ missing fields: %o
660
+ network result: %o
661
+ cache result: %o
662
+
663
+ For more information, please refer to the documentation:
664
+
665
+ * Customizing cache field behavior: https://go.apollo.dev/c/cache-field-behavior
666
+ `
667
+ },
668
+
669
+ 93: {
651
670
  file: "@apollo/client/core/QueryManager.js",
652
671
  message: `Unknown query named "%s" requested in refetchQueries options.include array`
653
672
  },
654
673
 
655
- 93: {
674
+ 94: {
656
675
  file: "@apollo/client/core/QueryManager.js",
657
676
  message: `Unknown anonymous query requested in refetchQueries options.include array`
658
677
  },
659
678
 
660
- 98: {
679
+ 99: {
661
680
  file: "@apollo/client/core/QueryManager.js",
662
681
  message: '[%s]: Fragments masked by data masking are inaccessible when using fetch policy "no-cache". Please add `@unmask` to each fragment spread to access the data.'
663
682
  },
664
683
 
665
- 101: {
684
+ 102: {
666
685
  file: "@apollo/client/core/RefetchEventManager.js",
667
686
  message: "Connected an `ApolloClient` instance to a `RefetchEventManager` that was already connected to a different `ApolloClient`. The previous client has been disconnected and will no longer receive refetch events from this manager."
668
687
  },
669
688
 
670
- 102: {
689
+ 103: {
671
690
  file: "@apollo/client/core/RefetchEventManager.js",
672
691
  message: "Received '%s' event but an `ApolloClient` instance is not connected to the `RefetchEventManager`. No queries will refetch. Pass the manager to the `refetchEventManager` option on the `ApolloClient` constructor."
673
692
  },
674
693
 
675
- 103: {
694
+ 104: {
676
695
  file: "@apollo/client/core/RefetchEventManager.js",
677
696
  message: "Received '%s' event but no source is configured for it on the `RefetchEventManager`. No queries will refetch. Add the event to the `sources` option or call `setEventSource`."
678
697
  },
679
698
 
680
- 105: {
699
+ 106: {
681
700
  file: "@apollo/client/cache/inmemory/entityStore.js",
682
701
 
683
702
  message: "cache.modify: You are trying to write a Reference that is not part of the store: %o\n" +
@@ -685,24 +704,24 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`
685
704
  "`toReference(object, true)`"
686
705
  },
687
706
 
688
- 106: {
707
+ 107: {
689
708
  file: "@apollo/client/cache/inmemory/entityStore.js",
690
709
 
691
710
  message: "cache.modify: Writing an array with a mix of both References and Objects will not result in the Objects being normalized correctly.\n" +
692
711
  "Please convert the object instance %o to a Reference before writing it to the cache by calling `toReference(object, true)`."
693
712
  },
694
713
 
695
- 109: {
714
+ 110: {
696
715
  file: "@apollo/client/cache/inmemory/policies.js",
697
716
  message: `Inferring subtype %s of supertype %s`
698
717
  },
699
718
 
700
- 110: {
719
+ 111: {
701
720
  file: "@apollo/client/cache/inmemory/policies.js",
702
721
  message: `Undefined 'from' passed to readField with arguments %s`
703
722
  },
704
723
 
705
- 117: {
724
+ 118: {
706
725
  file: "@apollo/client/cache/inmemory/writeToStore.js",
707
726
 
708
727
  message: `Cache data may be lost when replacing the %s field of a %s object.
@@ -721,7 +740,7 @@ For more information about these options, please refer to the documentation:
721
740
  `
722
741
  },
723
742
 
724
- 118: {
743
+ 119: {
725
744
  file: "@apollo/client/cache/core/cache.js",
726
745
  message: "Could not identify object passed to `from` for '%s' fragment, either because the object is non-normalized or the key fields are missing. If you are masking this object, please ensure the key fields are requested by the parent object."
727
746
  }
@@ -743,7 +762,7 @@ export const devError = {
743
762
  message: "Unhandled GraphQL subscription error"
744
763
  },
745
764
 
746
- 115: {
765
+ 116: {
747
766
  file: "@apollo/client/cache/inmemory/writeToStore.js",
748
767
  message: `Missing field '%s' while writing result %o`
749
768
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo/client",
3
- "version": "4.2.10",
3
+ "version": "4.2.11",
4
4
  "description": "A fully-featured caching GraphQL client.",
5
5
  "private": false,
6
6
  "keywords": [
@@ -2,7 +2,7 @@ import type { ApolloClient, DefaultContext, DocumentNode, ErrorPolicy, Operation
2
2
  import type { SubscribeToMoreFunction } from "@apollo/client";
3
3
  import type { QueryRef } from "@apollo/client/react";
4
4
  import type { FetchMoreFunction, RefetchFunction } from "@apollo/client/react/internal";
5
- import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, OptionWithFallback, Prettify, SignatureStyle, VariablesOption } from "@apollo/client/utilities/internal";
5
+ import type { NoInfer, OptionWithFallback, Prettify, SignatureStyle, VariablesOption } from "@apollo/client/utilities/internal";
6
6
  import type { SkipToken } from "./constants.js";
7
7
  export declare namespace useBackgroundQuery {
8
8
  import _self = useBackgroundQuery;
@@ -127,7 +127,15 @@ export declare namespace useBackgroundQuery {
127
127
  type Options<TVariables extends OperationVariables = OperationVariables> = Base.Options & VariablesOption<TVariables>;
128
128
  namespace DocumentationTypes {
129
129
  namespace useBackgroundQuery {
130
- interface Options<TVariables extends OperationVariables = OperationVariables> extends Omit<Base.Options, "variables">, UtilityDocumentationTypes.VariableOptions<TVariables> {
130
+ interface Options<TVariables extends OperationVariables = OperationVariables> extends Base.Options {
131
+ /**
132
+ * An object containing all of the GraphQL variables your query requires to execute.
133
+ *
134
+ * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.
135
+ *
136
+ * @docGroup 1. Operation options
137
+ */
138
+ variables?: TVariables;
131
139
  }
132
140
  }
133
141
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useBackgroundQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useBackgroundQuery.ts"],"names":[],"mappings":"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","sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n ObservableQuery,\n OperationVariables,\n RefetchOn,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n} from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport type { QueryRef } from \"@apollo/client/react\";\nimport type {\n FetchMoreFunction,\n RefetchFunction,\n} from \"@apollo/client/react/internal\";\nimport {\n getSuspenseCache,\n unwrapQueryRef,\n updateWrappedQueryRef,\n wrapQueryRef,\n} from \"@apollo/client/react/internal\";\nimport type {\n DocumentationTypes as UtilityDocumentationTypes,\n NoInfer,\n OptionWithFallback,\n Prettify,\n SignatureStyle,\n VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { SkipToken } from \"./constants.js\";\nimport { useSuspenseHookCacheKey, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\nimport { useWatchQueryOptions } from \"./useSuspenseQuery.js\";\n\nexport declare namespace useBackgroundQuery {\n import _self = useBackgroundQuery;\n export type FetchPolicy = Extract<\n WatchQueryFetchPolicy,\n \"cache-first\" | \"network-only\" | \"no-cache\" | \"cache-and-network\"\n >;\n\n export namespace Base {\n export interface Options {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */\n client?: ApolloClient;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#refetchWritePolicy_suspense:member} */\n refetchWritePolicy?: RefetchWritePolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */\n context?: DefaultContext;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#returnPartialData:member} */\n returnPartialData?: boolean;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#fetchPolicy:member} */\n fetchPolicy?: FetchPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#queryKey:member} */\n queryKey?: string | number | any[];\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#refetchOn:member} */\n refetchOn?: RefetchOn.Option;\n\n /**\n * {@inheritDoc @apollo/client!QueryOptionsDocumentation#skip_deprecated:member}\n *\n * @example Recommended usage of `skipToken`:\n *\n * ```ts\n * import { skipToken, useBackgroundQuery } from \"@apollo/client\";\n *\n * const [queryRef] = useBackgroundQuery(\n * query,\n * id ? { variables: { id } } : skipToken\n * );\n * ```\n */\n skip?: boolean;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#variables:member} */\n variables?: unknown;\n }\n }\n\n export type Options<\n TVariables extends OperationVariables = OperationVariables,\n > = Base.Options & VariablesOption<TVariables>;\n\n export namespace DocumentationTypes {\n namespace useBackgroundQuery {\n export interface Options<\n TVariables extends OperationVariables = OperationVariables,\n > extends Omit<Base.Options, \"variables\">,\n UtilityDocumentationTypes.VariableOptions<TVariables> {}\n }\n }\n\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n > {\n /** {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)}\n *\n * @remarks\n * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).\n */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n\n /**\n * {@inheritDoc @apollo/client!QueryResultDocumentation#refetch:member}\n *\n * @remarks\n * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).\n */\n refetch: RefetchFunction<TData, TVariables, TErrorPolicy>;\n }\n\n namespace DocumentationTypes {\n namespace useBackgroundQuery {\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends _self.Result<TData, TVariables> {}\n }\n }\n\n export interface DefaultOptions\n extends ApolloClient.DefaultOptions.WatchQuery.Calculated {\n skip: false;\n }\n\n export type OptionsFor<\n TVariables extends OperationVariables,\n TOptions extends { variables?: unknown },\n > = useBackgroundQuery.Options<NoInfer<TVariables>> & {\n variables?: Prettify<\n TVariables & {\n // variables that are not part of `TVariables`\n [K in keyof TOptions[\"variables\"]]: K extends keyof TVariables ?\n TVariables[K]\n : never;\n }\n >;\n } & (Exclude<\n keyof Exclude<TOptions, SkipToken>,\n keyof useBackgroundQuery.Options<any>\n > extends infer InvalidOptionNames extends string ?\n [InvalidOptionNames] extends [never] ?\n unknown\n : { [K in InvalidOptionNames]: never }\n : never);\n\n export type ResultForOptions<\n TData,\n TVariables extends OperationVariables,\n TOptions extends Record<string, never> | Base.Options | SkipToken,\n > = [\n queryRef: TOptions extends any ?\n TOptions extends SkipToken ?\n undefined\n : | QueryRef<\n TData,\n TVariables,\n | \"complete\"\n | \"streaming\"\n | (\n | (OptionWithFallback<\n TOptions,\n DefaultOptions,\n \"errorPolicy\"\n > extends \"none\" ?\n never\n : \"empty\")\n | (OptionWithFallback<\n TOptions,\n DefaultOptions,\n \"returnPartialData\"\n > extends false ?\n never\n : \"partial\")\n )\n >\n | (OptionWithFallback<TOptions, DefaultOptions, \"skip\"> extends false ?\n never\n : undefined)\n : never,\n result: useBackgroundQuery.Result<\n TData,\n TVariables,\n OptionWithFallback<TOptions, DefaultOptions, \"errorPolicy\"> & ErrorPolicy\n >,\n ];\n\n export namespace DocumentationTypes {\n export interface useBackgroundQuery {\n /**\n * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).\n *\n * @returns A tuple containing:\n *\n * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.\n * 2. An object containing helper functions for the query:\n * - `refetch`: A function to re-execute the query\n * - `fetchMore`: A function to fetch more results for pagination\n * - `subscribeToMore`: A function to subscribe to updates\n *\n * @example\n *\n * ```jsx\n * import { Suspense } from \"react\";\n * import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\";\n * import { useBackgroundQuery, useReadQuery } from \"@apollo/client/react\";\n *\n * const query = gql`\n * foo {\n * bar\n * }\n * `;\n *\n * const client = new ApolloClient({\n * link: new HttpLink({ uri: \"http://localhost:4000/graphql\" }),\n * cache: new InMemoryCache(),\n * });\n *\n * function SuspenseFallback() {\n * return <div>Loading...</div>;\n * }\n *\n * function Child({ queryRef }) {\n * const { data } = useReadQuery(queryRef);\n *\n * return <div>{data.foo.bar}</div>;\n * }\n *\n * function Parent() {\n * const [queryRef] = useBackgroundQuery(query);\n *\n * return (\n * <Suspense fallback={<SuspenseFallback />}>\n * <Child queryRef={queryRef} />\n * </Suspense>\n * );\n * }\n *\n * function App() {\n * return (\n * <ApolloProvider client={client}>\n * <Parent />\n * </ApolloProvider>\n * );\n * }\n * ```\n *\n * @param query - A GraphQL query document parsed into an AST by `gql`.\n * @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.\n */\n <\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken | useBackgroundQuery.Options<TVariables>\n ): [\n QueryRef<TData, TVariables> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n }\n\n export interface useBackgroundQuery_Deprecated {\n /**\n * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.\n * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.\n *\n * {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)}\n */\n <\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken | useBackgroundQuery.Options<TVariables>\n ): [\n QueryRef<TData, TVariables> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n }\n }\n\n export namespace Signatures {\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n export interface Classic {\n // _INFERENCE_ONLY_DO_NOT_SPECIFY is used to distinguish between inferred\n // generics arguments and explicit generic arguments so that we can\n // provide a `@deprecated` signature for explicit generic arguments. As\n // soon as a user provides a generic arg (e.g. useBackgroundQuery<TData>(query))`,\n // the overload falls through to the overloads without\n // _INFERENCE_ONLY_DO_NOT_SPECIFY.\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n /** @deprecated `returnPartialData` has no effect on `no-cache` queries */\n returnPartialData: boolean;\n fetchPolicy: \"no-cache\";\n errorPolicy?: TErrorPolicy;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n errorPolicy: TErrorPolicy & (\"ignore\" | \"all\");\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n errorPolicy: TErrorPolicy & (\"ignore\" | \"all\");\n }\n ): [\n QueryRef<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\" | \"empty\"\n >,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy: TErrorPolicy & (\"ignore\" | \"all\");\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: false;\n errorPolicy?: TErrorPolicy;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: boolean;\n errorPolicy?: TErrorPolicy;\n }\n ): [\n (\n | QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">\n | undefined\n ),\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n errorPolicy?: TErrorPolicy;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n errorPolicy?: TErrorPolicy;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n errorPolicy?: TErrorPolicy;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken\n ): [undefined, useBackgroundQuery.Result<TData, TVariables>];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n errorPolicy?: TErrorPolicy;\n })\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n errorPolicy?: TErrorPolicy;\n })\n ): [\n (\n | QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">\n | undefined\n ),\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [\n options?: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy?: TErrorPolicy;\n },\n ]\n : [\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy?: TErrorPolicy;\n },\n ]\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [\n options?:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy?: TErrorPolicy;\n }),\n ]\n : [\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy?: TErrorPolicy;\n }),\n ]\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy?: TErrorPolicy;\n })\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n /** @deprecated `returnPartialData` has no effect on `no-cache` queries */\n returnPartialData: boolean;\n fetchPolicy: \"no-cache\";\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n errorPolicy: \"ignore\" | \"all\";\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n errorPolicy: \"ignore\" | \"all\";\n }\n ): [\n QueryRef<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\" | \"empty\"\n >,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy: \"ignore\" | \"all\";\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: false;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: boolean;\n }\n ): [\n (\n | QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">\n | undefined\n ),\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken\n ): [undefined, useBackgroundQuery.Result<TData, TVariables>];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n })\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n })\n ): [\n (\n | QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">\n | undefined\n ),\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: useBackgroundQuery.Options<NoInfer<TVariables>>]\n : [options: useBackgroundQuery.Options<NoInfer<TVariables>>]\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [\n options?:\n | SkipToken\n | useBackgroundQuery.Options<NoInfer<TVariables>>,\n ]\n : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n }\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n export interface Modern {\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n // this overload should never be manually defined, it should always be inferred\n TOptions extends never,\n >(\n query: {} extends TVariables ?\n DocumentNode | TypedDocumentNode<TData, TVariables>\n : // this overload should only be accessible if all `TVariables` are optional\n never\n ): useBackgroundQuery.ResultForOptions<\n TData,\n TVariables,\n Record<string, never>\n >;\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n // this overload should never be manually defined, it should always be inferred\n TOptions extends Base.Options,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [\n options?: TOptions &\n useBackgroundQuery.OptionsFor<TVariables, TOptions>,\n ]\n : [\n options: TOptions &\n useBackgroundQuery.OptionsFor<TVariables, TOptions>,\n ]\n ): useBackgroundQuery.ResultForOptions<TData, TVariables, TOptions>;\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n // this overload should never be manually defined, it should always be inferred\n TOptions extends never,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n skipToken: SkipToken\n ): useBackgroundQuery.ResultForOptions<TData, TVariables, SkipToken>;\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n // this overload should never be manually defined, it should always be inferred\n TOptions extends Base.Options,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [\n options?:\n | (TOptions & useBackgroundQuery.OptionsFor<TVariables, TOptions>)\n | SkipToken,\n ]\n : [\n options:\n | (TOptions & useBackgroundQuery.OptionsFor<TVariables, TOptions>)\n | SkipToken,\n ]\n ): useBackgroundQuery.ResultForOptions<\n TData,\n TVariables,\n TOptions | SkipToken\n >;\n }\n\n export type Evaluated = SignatureStyle extends \"classic\" ? Classic : Modern;\n }\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n export interface Signature extends Signatures.Evaluated {}\n}\n\nexport const useBackgroundQuery: useBackgroundQuery.Signature =\n function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>\n ): [\n QueryRef<TData, TVariables, DataState<TData>[\"dataState\"]> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ] {\n \"use no memo\";\n return wrapHook(\n \"useBackgroundQuery\",\n useBackgroundQuery_,\n useApolloClient(typeof options === \"object\" ? options.client : undefined)\n )(query, options ?? ({} as any));\n } as any;\n\nfunction useBackgroundQuery_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n TStates extends DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | (SkipToken & Partial<useBackgroundQuery.Options<NoInfer<TVariables>>>)\n | useBackgroundQuery.Options<NoInfer<TVariables>>\n): [\n QueryRef<TData, TVariables, TStates> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n] {\n const client = useApolloClient(options.client);\n const suspenseCache = getSuspenseCache(client);\n const watchQueryOptions = useWatchQueryOptions({ client, query, options });\n const { fetchPolicy } = watchQueryOptions;\n const cacheKey = useSuspenseHookCacheKey(query, options);\n\n // This ref tracks the first time query execution is enabled to determine\n // whether to return a query ref or `undefined`. When initialized\n // in a skipped state (either via `skip: true` or `skipToken`) we return\n // `undefined` for the `queryRef` until the query has been enabled. Once\n // enabled, a query ref is always returned regardless of whether the query is\n // skipped again later.\n const didFetchResult = React.useRef(fetchPolicy !== \"standby\");\n didFetchResult.current ||= fetchPolicy !== \"standby\";\n\n const queryRef = suspenseCache.getQueryRef<TData, TStates>(cacheKey, () =>\n client.watchQuery(\n watchQueryOptions as ApolloClient.WatchQueryOptions<any, any>\n )\n );\n\n const [wrappedQueryRef, setWrappedQueryRef] = React.useState(\n wrapQueryRef(queryRef)\n );\n if (unwrapQueryRef(wrappedQueryRef) !== queryRef) {\n setWrappedQueryRef(wrapQueryRef(queryRef));\n }\n if (queryRef.didChangeOptions(watchQueryOptions)) {\n const promise = queryRef.applyOptions(watchQueryOptions);\n updateWrappedQueryRef(wrappedQueryRef, promise);\n }\n\n // This prevents issues where rerendering useBackgroundQuery after the\n // queryRef has been disposed would cause the hook to return a new queryRef\n // instance since disposal also removes it from the suspense cache. We add\n // the queryRef back in the suspense cache so that the next render will reuse\n // this queryRef rather than initializing a new instance.\n React.useEffect(() => {\n // Since the queryRef is disposed async via `setTimeout`, we have to wait a\n // tick before checking it and adding back to the suspense cache.\n const id = setTimeout(() => {\n if (queryRef.disposed) {\n suspenseCache.add(cacheKey, queryRef);\n }\n });\n\n return () => clearTimeout(id);\n // Omitting the deps is intentional. This avoids stale closures and the\n // conditional ensures we aren't running the logic on each render.\n });\n\n const fetchMore = React.useCallback(\n (\n options: ObservableQuery.FetchMoreOptions<TData, TVariables, any, any>\n ) => {\n const promise = queryRef.fetchMore(options);\n\n setWrappedQueryRef(wrapQueryRef(queryRef));\n\n return promise;\n },\n [queryRef]\n ) as FetchMoreFunction<TData, TVariables>;\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (variables) => {\n const promise = queryRef.refetch(variables);\n\n setWrappedQueryRef(wrapQueryRef(queryRef));\n\n return promise;\n },\n [queryRef]\n );\n\n React.useEffect(() => queryRef.softRetain(), [queryRef]);\n\n return [\n didFetchResult.current ? wrappedQueryRef : void 0,\n {\n fetchMore,\n refetch,\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n subscribeToMore: queryRef.observable\n .subscribeToMore as SubscribeToMoreFunction<TData, TVariables>,\n },\n ];\n}\n"]}
1
+ {"version":3,"file":"useBackgroundQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useBackgroundQuery.ts"],"names":[],"mappings":"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","sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n ObservableQuery,\n OperationVariables,\n RefetchOn,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n} from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport type { QueryRef } from \"@apollo/client/react\";\nimport type {\n FetchMoreFunction,\n RefetchFunction,\n} from \"@apollo/client/react/internal\";\nimport {\n getSuspenseCache,\n unwrapQueryRef,\n updateWrappedQueryRef,\n wrapQueryRef,\n} from \"@apollo/client/react/internal\";\nimport type {\n NoInfer,\n OptionWithFallback,\n Prettify,\n SignatureStyle,\n VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { SkipToken } from \"./constants.js\";\nimport { useSuspenseHookCacheKey, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\nimport { useWatchQueryOptions } from \"./useSuspenseQuery.js\";\n\nexport declare namespace useBackgroundQuery {\n import _self = useBackgroundQuery;\n export type FetchPolicy = Extract<\n WatchQueryFetchPolicy,\n \"cache-first\" | \"network-only\" | \"no-cache\" | \"cache-and-network\"\n >;\n\n export namespace Base {\n export interface Options {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */\n client?: ApolloClient;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#refetchWritePolicy_suspense:member} */\n refetchWritePolicy?: RefetchWritePolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */\n context?: DefaultContext;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#returnPartialData:member} */\n returnPartialData?: boolean;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#fetchPolicy:member} */\n fetchPolicy?: FetchPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#queryKey:member} */\n queryKey?: string | number | any[];\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#refetchOn:member} */\n refetchOn?: RefetchOn.Option;\n\n /**\n * {@inheritDoc @apollo/client!QueryOptionsDocumentation#skip_deprecated:member}\n *\n * @example Recommended usage of `skipToken`:\n *\n * ```ts\n * import { skipToken, useBackgroundQuery } from \"@apollo/client\";\n *\n * const [queryRef] = useBackgroundQuery(\n * query,\n * id ? { variables: { id } } : skipToken\n * );\n * ```\n */\n skip?: boolean;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#variables:member} */\n variables?: unknown;\n }\n }\n\n export type Options<\n TVariables extends OperationVariables = OperationVariables,\n > = Base.Options & VariablesOption<TVariables>;\n\n export namespace DocumentationTypes {\n namespace useBackgroundQuery {\n export interface Options<\n TVariables extends OperationVariables = OperationVariables,\n > extends Base.Options {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#variables:member} */\n variables?: TVariables;\n }\n }\n }\n\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n > {\n /** {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n\n /**\n * {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)}\n *\n * @remarks\n * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).\n */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n\n /**\n * {@inheritDoc @apollo/client!QueryResultDocumentation#refetch:member}\n *\n * @remarks\n * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).\n */\n refetch: RefetchFunction<TData, TVariables, TErrorPolicy>;\n }\n\n namespace DocumentationTypes {\n namespace useBackgroundQuery {\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends _self.Result<TData, TVariables> {}\n }\n }\n\n export interface DefaultOptions\n extends ApolloClient.DefaultOptions.WatchQuery.Calculated {\n skip: false;\n }\n\n export type OptionsFor<\n TVariables extends OperationVariables,\n TOptions extends { variables?: unknown },\n > = useBackgroundQuery.Options<NoInfer<TVariables>> & {\n variables?: Prettify<\n TVariables & {\n // variables that are not part of `TVariables`\n [K in keyof TOptions[\"variables\"]]: K extends keyof TVariables ?\n TVariables[K]\n : never;\n }\n >;\n } & (Exclude<\n keyof Exclude<TOptions, SkipToken>,\n keyof useBackgroundQuery.Options<any>\n > extends infer InvalidOptionNames extends string ?\n [InvalidOptionNames] extends [never] ?\n unknown\n : { [K in InvalidOptionNames]: never }\n : never);\n\n export type ResultForOptions<\n TData,\n TVariables extends OperationVariables,\n TOptions extends Record<string, never> | Base.Options | SkipToken,\n > = [\n queryRef: TOptions extends any ?\n TOptions extends SkipToken ?\n undefined\n : | QueryRef<\n TData,\n TVariables,\n | \"complete\"\n | \"streaming\"\n | (\n | (OptionWithFallback<\n TOptions,\n DefaultOptions,\n \"errorPolicy\"\n > extends \"none\" ?\n never\n : \"empty\")\n | (OptionWithFallback<\n TOptions,\n DefaultOptions,\n \"returnPartialData\"\n > extends false ?\n never\n : \"partial\")\n )\n >\n | (OptionWithFallback<TOptions, DefaultOptions, \"skip\"> extends false ?\n never\n : undefined)\n : never,\n result: useBackgroundQuery.Result<\n TData,\n TVariables,\n OptionWithFallback<TOptions, DefaultOptions, \"errorPolicy\"> & ErrorPolicy\n >,\n ];\n\n export namespace DocumentationTypes {\n export interface useBackgroundQuery {\n /**\n * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).\n *\n * @returns A tuple containing:\n *\n * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.\n * 2. An object containing helper functions for the query:\n * - `refetch`: A function to re-execute the query\n * - `fetchMore`: A function to fetch more results for pagination\n * - `subscribeToMore`: A function to subscribe to updates\n *\n * @example\n *\n * ```jsx\n * import { Suspense } from \"react\";\n * import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\";\n * import { useBackgroundQuery, useReadQuery } from \"@apollo/client/react\";\n *\n * const query = gql`\n * foo {\n * bar\n * }\n * `;\n *\n * const client = new ApolloClient({\n * link: new HttpLink({ uri: \"http://localhost:4000/graphql\" }),\n * cache: new InMemoryCache(),\n * });\n *\n * function SuspenseFallback() {\n * return <div>Loading...</div>;\n * }\n *\n * function Child({ queryRef }) {\n * const { data } = useReadQuery(queryRef);\n *\n * return <div>{data.foo.bar}</div>;\n * }\n *\n * function Parent() {\n * const [queryRef] = useBackgroundQuery(query);\n *\n * return (\n * <Suspense fallback={<SuspenseFallback />}>\n * <Child queryRef={queryRef} />\n * </Suspense>\n * );\n * }\n *\n * function App() {\n * return (\n * <ApolloProvider client={client}>\n * <Parent />\n * </ApolloProvider>\n * );\n * }\n * ```\n *\n * @param query - A GraphQL query document parsed into an AST by `gql`.\n * @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.\n */\n <\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken | useBackgroundQuery.Options<TVariables>\n ): [\n QueryRef<TData, TVariables> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n }\n\n export interface useBackgroundQuery_Deprecated {\n /**\n * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.\n * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.\n *\n * {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)}\n */\n <\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken | useBackgroundQuery.Options<TVariables>\n ): [\n QueryRef<TData, TVariables> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n }\n }\n\n export namespace Signatures {\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n export interface Classic {\n // _INFERENCE_ONLY_DO_NOT_SPECIFY is used to distinguish between inferred\n // generics arguments and explicit generic arguments so that we can\n // provide a `@deprecated` signature for explicit generic arguments. As\n // soon as a user provides a generic arg (e.g. useBackgroundQuery<TData>(query))`,\n // the overload falls through to the overloads without\n // _INFERENCE_ONLY_DO_NOT_SPECIFY.\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n /** @deprecated `returnPartialData` has no effect on `no-cache` queries */\n returnPartialData: boolean;\n fetchPolicy: \"no-cache\";\n errorPolicy?: TErrorPolicy;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n errorPolicy: TErrorPolicy & (\"ignore\" | \"all\");\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n errorPolicy: TErrorPolicy & (\"ignore\" | \"all\");\n }\n ): [\n QueryRef<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\" | \"empty\"\n >,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy: TErrorPolicy & (\"ignore\" | \"all\");\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: false;\n errorPolicy?: TErrorPolicy;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: boolean;\n errorPolicy?: TErrorPolicy;\n }\n ): [\n (\n | QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">\n | undefined\n ),\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n errorPolicy?: TErrorPolicy;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n errorPolicy?: TErrorPolicy;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n errorPolicy?: TErrorPolicy;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken\n ): [undefined, useBackgroundQuery.Result<TData, TVariables>];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n errorPolicy?: TErrorPolicy;\n })\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n errorPolicy?: TErrorPolicy;\n })\n ): [\n (\n | QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">\n | undefined\n ),\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [\n options?: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy?: TErrorPolicy;\n },\n ]\n : [\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy?: TErrorPolicy;\n },\n ]\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [\n options?:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy?: TErrorPolicy;\n }),\n ]\n : [\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy?: TErrorPolicy;\n }),\n ]\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n _INFERENCE_ONLY_DO_NOT_SPECIFY extends \"inferred\",\n TErrorPolicy extends ErrorPolicy | undefined = undefined,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy?: TErrorPolicy;\n })\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables, TErrorPolicy>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n /** @deprecated `returnPartialData` has no effect on `no-cache` queries */\n returnPartialData: boolean;\n fetchPolicy: \"no-cache\";\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n errorPolicy: \"ignore\" | \"all\";\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n errorPolicy: \"ignore\" | \"all\";\n }\n ): [\n QueryRef<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\" | \"empty\"\n >,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n errorPolicy: \"ignore\" | \"all\";\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: false;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: boolean;\n }\n ): [\n (\n | QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">\n | undefined\n ),\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n }\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken\n ): [undefined, useBackgroundQuery.Result<TData, TVariables>];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: false;\n })\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n })\n ): [\n (\n | QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\">\n | undefined\n ),\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: useBackgroundQuery.Options<NoInfer<TVariables>>]\n : [options: useBackgroundQuery.Options<NoInfer<TVariables>>]\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [\n options?:\n | SkipToken\n | useBackgroundQuery.Options<NoInfer<TVariables>>,\n ]\n : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery_Deprecated:call(1)} */\n <TData, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>\n ): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ];\n }\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n export interface Modern {\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n // this overload should never be manually defined, it should always be inferred\n TOptions extends never,\n >(\n query: {} extends TVariables ?\n DocumentNode | TypedDocumentNode<TData, TVariables>\n : // this overload should only be accessible if all `TVariables` are optional\n never\n ): useBackgroundQuery.ResultForOptions<\n TData,\n TVariables,\n Record<string, never>\n >;\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n // this overload should never be manually defined, it should always be inferred\n TOptions extends Base.Options,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [\n options?: TOptions &\n useBackgroundQuery.OptionsFor<TVariables, TOptions>,\n ]\n : [\n options: TOptions &\n useBackgroundQuery.OptionsFor<TVariables, TOptions>,\n ]\n ): useBackgroundQuery.ResultForOptions<TData, TVariables, TOptions>;\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n // this overload should never be manually defined, it should always be inferred\n TOptions extends never,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n skipToken: SkipToken\n ): useBackgroundQuery.ResultForOptions<TData, TVariables, SkipToken>;\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n <\n TData,\n TVariables extends OperationVariables,\n // this overload should never be manually defined, it should always be inferred\n TOptions extends Base.Options,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [\n options?:\n | (TOptions & useBackgroundQuery.OptionsFor<TVariables, TOptions>)\n | SkipToken,\n ]\n : [\n options:\n | (TOptions & useBackgroundQuery.OptionsFor<TVariables, TOptions>)\n | SkipToken,\n ]\n ): useBackgroundQuery.ResultForOptions<\n TData,\n TVariables,\n TOptions | SkipToken\n >;\n }\n\n export type Evaluated = SignatureStyle extends \"classic\" ? Classic : Modern;\n }\n\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery.DocumentationTypes.useBackgroundQuery:call(1)} */\n export interface Signature extends Signatures.Evaluated {}\n}\n\nexport const useBackgroundQuery: useBackgroundQuery.Signature =\n function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>\n ): [\n QueryRef<TData, TVariables, DataState<TData>[\"dataState\"]> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n ] {\n \"use no memo\";\n return wrapHook(\n \"useBackgroundQuery\",\n useBackgroundQuery_,\n useApolloClient(typeof options === \"object\" ? options.client : undefined)\n )(query, options ?? ({} as any));\n } as any;\n\nfunction useBackgroundQuery_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n TStates extends DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | (SkipToken & Partial<useBackgroundQuery.Options<NoInfer<TVariables>>>)\n | useBackgroundQuery.Options<NoInfer<TVariables>>\n): [\n QueryRef<TData, TVariables, TStates> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n] {\n const client = useApolloClient(options.client);\n const suspenseCache = getSuspenseCache(client);\n const watchQueryOptions = useWatchQueryOptions({ client, query, options });\n const { fetchPolicy } = watchQueryOptions;\n const cacheKey = useSuspenseHookCacheKey(query, options);\n\n // This ref tracks the first time query execution is enabled to determine\n // whether to return a query ref or `undefined`. When initialized\n // in a skipped state (either via `skip: true` or `skipToken`) we return\n // `undefined` for the `queryRef` until the query has been enabled. Once\n // enabled, a query ref is always returned regardless of whether the query is\n // skipped again later.\n const didFetchResult = React.useRef(fetchPolicy !== \"standby\");\n didFetchResult.current ||= fetchPolicy !== \"standby\";\n\n const queryRef = suspenseCache.getQueryRef<TData, TStates>(cacheKey, () =>\n client.watchQuery(\n watchQueryOptions as ApolloClient.WatchQueryOptions<any, any>\n )\n );\n\n const [wrappedQueryRef, setWrappedQueryRef] = React.useState(\n wrapQueryRef(queryRef)\n );\n if (unwrapQueryRef(wrappedQueryRef) !== queryRef) {\n setWrappedQueryRef(wrapQueryRef(queryRef));\n }\n if (queryRef.didChangeOptions(watchQueryOptions)) {\n const promise = queryRef.applyOptions(watchQueryOptions);\n updateWrappedQueryRef(wrappedQueryRef, promise);\n }\n\n // This prevents issues where rerendering useBackgroundQuery after the\n // queryRef has been disposed would cause the hook to return a new queryRef\n // instance since disposal also removes it from the suspense cache. We add\n // the queryRef back in the suspense cache so that the next render will reuse\n // this queryRef rather than initializing a new instance.\n React.useEffect(() => {\n // Since the queryRef is disposed async via `setTimeout`, we have to wait a\n // tick before checking it and adding back to the suspense cache.\n const id = setTimeout(() => {\n if (queryRef.disposed) {\n suspenseCache.add(cacheKey, queryRef);\n }\n });\n\n return () => clearTimeout(id);\n // Omitting the deps is intentional. This avoids stale closures and the\n // conditional ensures we aren't running the logic on each render.\n });\n\n const fetchMore = React.useCallback(\n (\n options: ObservableQuery.FetchMoreOptions<TData, TVariables, any, any>\n ) => {\n const promise = queryRef.fetchMore(options);\n\n setWrappedQueryRef(wrapQueryRef(queryRef));\n\n return promise;\n },\n [queryRef]\n ) as FetchMoreFunction<TData, TVariables>;\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (variables) => {\n const promise = queryRef.refetch(variables);\n\n setWrappedQueryRef(wrapQueryRef(queryRef));\n\n return promise;\n },\n [queryRef]\n );\n\n React.useEffect(() => queryRef.softRetain(), [queryRef]);\n\n return [\n didFetchResult.current ? wrappedQueryRef : void 0,\n {\n fetchMore,\n refetch,\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n subscribeToMore: queryRef.observable\n .subscribeToMore as SubscribeToMoreFunction<TData, TVariables>,\n },\n ];\n}\n"]}
@@ -144,7 +144,15 @@ export declare namespace useQuery {
144
144
  type Options<TData = unknown, TVariables extends OperationVariables = OperationVariables> = Base.Options<TData, TVariables> & VariablesOption<TVariables>;
145
145
  namespace DocumentationTypes {
146
146
  namespace useQuery {
147
- interface Options<TData = unknown, TVariables extends OperationVariables = OperationVariables> extends Omit<Base.Options<TData, TVariables>, "variables">, UtilityDocumentationTypes.VariableOptions<TVariables> {
147
+ interface Options<TData = unknown, TVariables extends OperationVariables = OperationVariables> extends Base.Options<TData, TVariables> {
148
+ /**
149
+ * An object containing all of the GraphQL variables your query requires to execute.
150
+ *
151
+ * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.
152
+ *
153
+ * @docGroup 1. Operation options
154
+ */
155
+ variables?: TVariables;
148
156
  }
149
157
  }
150
158
  }