@apollo/client 4.0.0-rc.9 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/CHANGELOG.md +2476 -0
  2. package/README.md +6 -2
  3. package/__cjs/cache/inmemory/inMemoryCache.cjs +2 -2
  4. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  5. package/__cjs/cache/inmemory/policies.cjs +18 -12
  6. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  7. package/__cjs/core/ObservableQuery.d.cts +1 -1
  8. package/__cjs/core/index.cjs.map +1 -1
  9. package/__cjs/core/index.d.cts +1 -1
  10. package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
  11. package/__cjs/incremental/handlers/defer20220824.d.cts +9 -6
  12. package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
  13. package/__cjs/incremental/handlers/notImplemented.d.cts +11 -0
  14. package/__cjs/link/core/ApolloLink.cjs.map +1 -1
  15. package/__cjs/link/core/ApolloLink.d.cts +5 -2
  16. package/__cjs/link/core/types.d.cts +0 -4
  17. package/__cjs/link/index.cjs.map +1 -1
  18. package/__cjs/link/index.d.cts +2 -1
  19. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +2 -2
  20. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
  21. package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +2 -2
  22. package/__cjs/local-state/LocalState.cjs.map +1 -1
  23. package/__cjs/masking/GraphQLCodegenDataMasking.d.cts +10 -42
  24. package/__cjs/masking/PreserveTypes.cjs +3 -0
  25. package/__cjs/masking/PreserveTypes.cjs.map +1 -0
  26. package/__cjs/masking/PreserveTypes.d.cts +26 -0
  27. package/__cjs/masking/index.cjs.map +1 -1
  28. package/__cjs/masking/index.d.cts +1 -1
  29. package/__cjs/masking/internal/types.d.cts +0 -1
  30. package/__cjs/masking/types.d.cts +6 -23
  31. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  32. package/__cjs/react/hooks/useBackgroundQuery.d.cts +2 -1
  33. package/__cjs/react/hooks/useLazyQuery.d.cts +1 -1
  34. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  35. package/__cjs/react/hooks/useLoadableQuery.d.cts +2 -1
  36. package/__cjs/react/hooks/useQuery.d.cts +1 -1
  37. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  38. package/__cjs/react/hooks/useQueryRefHandlers.d.cts +2 -1
  39. package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
  40. package/__cjs/react/hooks/useReadQuery.d.cts +1 -1
  41. package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
  42. package/__cjs/react/query-preloader/createQueryPreloader.d.cts +1 -1
  43. package/__cjs/react/types/deprecated.d.cts +1 -1
  44. package/__cjs/react/types/types.documentation.d.cts +1 -1
  45. package/__cjs/testing/core/mocking/mockSubscriptionLink.d.cts +1 -1
  46. package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
  47. package/__cjs/testing/react/MockedProvider.d.cts +5 -0
  48. package/__cjs/utilities/common/stripTypename.cjs +11 -0
  49. package/__cjs/utilities/common/stripTypename.cjs.map +1 -1
  50. package/__cjs/utilities/common/stripTypename.d.cts +11 -0
  51. package/__cjs/utilities/graphql/DocumentTransform.cjs +84 -1
  52. package/__cjs/utilities/graphql/DocumentTransform.cjs.map +1 -1
  53. package/__cjs/utilities/graphql/DocumentTransform.d.cts +94 -5
  54. package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs +27 -0
  55. package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs.map +1 -1
  56. package/__cjs/utilities/graphql/isFormattedExecutionResult.d.cts +27 -0
  57. package/__cjs/utilities/graphql/operations.cjs +54 -3
  58. package/__cjs/utilities/graphql/operations.cjs.map +1 -1
  59. package/__cjs/utilities/graphql/operations.d.cts +54 -3
  60. package/__cjs/utilities/graphql/storeUtils.cjs +9 -0
  61. package/__cjs/utilities/graphql/storeUtils.cjs.map +1 -1
  62. package/__cjs/utilities/graphql/storeUtils.d.cts +9 -0
  63. package/__cjs/utilities/graphql/transform.cjs +12 -1
  64. package/__cjs/utilities/graphql/transform.cjs.map +1 -1
  65. package/__cjs/utilities/graphql/transform.d.cts +12 -1
  66. package/__cjs/utilities/internal/canonicalStringify.cjs +30 -7
  67. package/__cjs/utilities/internal/canonicalStringify.cjs.map +1 -1
  68. package/__cjs/utilities/internal/canonicalStringify.d.cts +30 -7
  69. package/__cjs/utilities/internal/getMainDefinition.cjs +36 -8
  70. package/__cjs/utilities/internal/getMainDefinition.cjs.map +1 -1
  71. package/__cjs/utilities/internal/getMainDefinition.d.cts +36 -8
  72. package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +1 -1
  73. package/__cjs/v4-migration.cjs +9 -0
  74. package/__cjs/v4-migration.cjs.map +1 -0
  75. package/__cjs/v4-migration.d.cts +826 -0
  76. package/__cjs/version.cjs +1 -1
  77. package/__cjs/version.cjs.map +1 -1
  78. package/cache/inmemory/inMemoryCache.js +2 -2
  79. package/cache/inmemory/inMemoryCache.js.map +1 -1
  80. package/cache/inmemory/policies.js +18 -12
  81. package/cache/inmemory/policies.js.map +1 -1
  82. package/core/ObservableQuery.d.ts +1 -1
  83. package/core/index.d.ts +1 -1
  84. package/core/index.js.map +1 -1
  85. package/incremental/handlers/defer20220824.d.ts +9 -6
  86. package/incremental/handlers/defer20220824.js.map +1 -1
  87. package/incremental/handlers/notImplemented.d.ts +11 -0
  88. package/incremental/handlers/notImplemented.js.map +1 -1
  89. package/legacyEntryPoints/v4-migration/index.d.ts +1 -0
  90. package/legacyEntryPoints/v4-migration/index.js +1 -0
  91. package/legacyEntryPoints/v4-migration/v4-migration.cjs +1 -0
  92. package/legacyEntryPoints/v4-migration/v4-migration.d.cts +1 -0
  93. package/link/core/ApolloLink.d.ts +5 -2
  94. package/link/core/ApolloLink.js.map +1 -1
  95. package/link/core/types.d.ts +0 -4
  96. package/link/core/types.js.map +1 -1
  97. package/link/index.d.ts +2 -1
  98. package/link/index.js.map +1 -1
  99. package/link/remove-typename/removeTypenameFromVariables.d.ts +2 -2
  100. package/link/remove-typename/removeTypenameFromVariables.js +2 -2
  101. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  102. package/local-state/LocalState.js.map +1 -1
  103. package/masking/GraphQLCodegenDataMasking.d.ts +10 -42
  104. package/masking/GraphQLCodegenDataMasking.js.map +1 -1
  105. package/masking/PreserveTypes.d.ts +26 -0
  106. package/masking/PreserveTypes.js +2 -0
  107. package/masking/PreserveTypes.js.map +1 -0
  108. package/masking/index.d.ts +1 -1
  109. package/masking/index.js.map +1 -1
  110. package/masking/internal/types.d.ts +0 -1
  111. package/masking/internal/types.js.map +1 -1
  112. package/masking/types.d.ts +6 -23
  113. package/masking/types.js.map +1 -1
  114. package/package.json +8 -2
  115. package/react/hooks/useBackgroundQuery.d.ts +2 -1
  116. package/react/hooks/useBackgroundQuery.js.map +1 -1
  117. package/react/hooks/useLazyQuery.d.ts +1 -1
  118. package/react/hooks/useLoadableQuery.d.ts +2 -1
  119. package/react/hooks/useLoadableQuery.js.map +1 -1
  120. package/react/hooks/useQuery.d.ts +1 -1
  121. package/react/hooks/useQueryRefHandlers.d.ts +2 -1
  122. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  123. package/react/hooks/useReadQuery.d.ts +1 -1
  124. package/react/hooks/useReadQuery.js.map +1 -1
  125. package/react/hooks-compiled/useBackgroundQuery.d.ts +2 -1
  126. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  127. package/react/hooks-compiled/useLazyQuery.d.ts +1 -1
  128. package/react/hooks-compiled/useLoadableQuery.d.ts +2 -1
  129. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  130. package/react/hooks-compiled/useQuery.d.ts +1 -1
  131. package/react/hooks-compiled/useQueryRefHandlers.d.ts +2 -1
  132. package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
  133. package/react/hooks-compiled/useReadQuery.d.ts +1 -1
  134. package/react/hooks-compiled/useReadQuery.js.map +1 -1
  135. package/react/query-preloader/createQueryPreloader.d.ts +1 -1
  136. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  137. package/react/types/deprecated.d.ts +1 -1
  138. package/react/types/deprecated.js.map +1 -1
  139. package/react/types/types.documentation.d.ts +1 -1
  140. package/react/types/types.documentation.js.map +1 -1
  141. package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
  142. package/testing/react/MockedProvider.d.ts +5 -0
  143. package/testing/react/MockedProvider.js.map +1 -1
  144. package/utilities/common/stripTypename.d.ts +11 -0
  145. package/utilities/common/stripTypename.js +11 -0
  146. package/utilities/common/stripTypename.js.map +1 -1
  147. package/utilities/graphql/DocumentTransform.d.ts +94 -5
  148. package/utilities/graphql/DocumentTransform.js +84 -1
  149. package/utilities/graphql/DocumentTransform.js.map +1 -1
  150. package/utilities/graphql/isFormattedExecutionResult.d.ts +27 -0
  151. package/utilities/graphql/isFormattedExecutionResult.js +27 -0
  152. package/utilities/graphql/isFormattedExecutionResult.js.map +1 -1
  153. package/utilities/graphql/operations.d.ts +54 -3
  154. package/utilities/graphql/operations.js +54 -3
  155. package/utilities/graphql/operations.js.map +1 -1
  156. package/utilities/graphql/storeUtils.d.ts +9 -0
  157. package/utilities/graphql/storeUtils.js +9 -0
  158. package/utilities/graphql/storeUtils.js.map +1 -1
  159. package/utilities/graphql/transform.d.ts +12 -1
  160. package/utilities/graphql/transform.js +12 -1
  161. package/utilities/graphql/transform.js.map +1 -1
  162. package/utilities/internal/canonicalStringify.d.ts +30 -7
  163. package/utilities/internal/canonicalStringify.js +30 -7
  164. package/utilities/internal/canonicalStringify.js.map +1 -1
  165. package/utilities/internal/getMainDefinition.d.ts +37 -9
  166. package/utilities/internal/getMainDefinition.js +36 -8
  167. package/utilities/internal/getMainDefinition.js.map +1 -1
  168. package/utilities/internal/types/DocumentationTypes.d.ts +1 -1
  169. package/v4-migration.d.ts +826 -0
  170. package/v4-migration.js +8 -0
  171. package/v4-migration.js.map +1 -0
  172. package/version.js +1 -1
  173. package/version.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"GraphQLCodegenDataMasking.js","sourceRoot":"","sources":["../../src/masking/GraphQLCodegenDataMasking.ts"],"names":[],"mappings":"","sourcesContent":["import type { TypedDocumentNode } from \"@graphql-typed-document-node/core\";\n\nimport type { DataMasking } from \"@apollo/client\";\nimport type { HKT } from \"@apollo/client/utilities\";\nimport type { IsAny, Prettify } from \"@apollo/client/utilities/internal\";\n\nimport type {\n ContainsFragmentsRefs,\n RemoveFragmentName,\n RemoveMaskedMarker,\n UnwrapFragmentRefs,\n} from \"./internal/types.js\";\nexport declare namespace GraphQLCodegenDataMasking {\n export interface Implementation {\n Masked: HKTImplementation.Masked;\n MaskedDocumentNode: HKTImplementation.MaskedDocumentNode;\n FragmentType: HKTImplementation.FragmentType;\n MaybeMasked: HKTImplementation.MaybeMasked;\n Unmasked: HKTImplementation.Unmasked;\n }\n namespace HKTImplementation {\n export interface Masked extends HKT {\n arg1: unknown; // TData\n return: GraphQLCodegenDataMasking.Masked<this[\"arg1\"]>;\n }\n\n export interface MaskedDocumentNode extends HKT {\n arg1: unknown; // TData\n arg2: unknown; // TVariables\n return: GraphQLCodegenDataMasking.MaskedDocumentNode<\n this[\"arg1\"],\n this[\"arg2\"]\n >;\n }\n\n export interface FragmentType extends HKT {\n arg1: unknown; // TData\n return: GraphQLCodegenDataMasking.FragmentType<this[\"arg1\"]>;\n }\n\n export interface MaybeMasked extends HKT {\n arg1: unknown; // TData\n return: GraphQLCodegenDataMasking.MaybeMasked<this[\"arg1\"]>;\n }\n\n export interface Unmasked extends HKT {\n arg1: unknown; // TData\n return: GraphQLCodegenDataMasking.Unmasked<this[\"arg1\"]>;\n }\n }\n\n /**\n * Marks a type as masked. This is used by `MaybeMasked` when determining\n * whether to use the masked or unmasked type.\n */\n export type Masked<TData> = TData & {\n __masked?: true;\n };\n\n /**\n * Marks a type as masked. This is a shortcut for\n * `TypedDocumentNode<Masked<TData>, TVariables>`\n */\n export type MaskedDocumentNode<\n TData = { [key: string]: any },\n // eslint-disable-next-line local-rules/variables-should-extend-operation-variables\n TVariables = { [key: string]: any },\n > = TypedDocumentNode<Masked<TData>, TVariables>;\n\n export type FragmentType<TData> =\n [TData] extends [{ \" $fragmentName\"?: infer TKey }] ?\n TKey extends string ?\n { \" $fragmentRefs\"?: { [key in TKey]: TData } }\n : never\n : never;\n\n /**\n * Returns TData as either masked or unmasked depending on whether masking is\n * enabled.\n */\n export type MaybeMasked<TData> =\n DataMasking extends { mode: \"unmask\" } ?\n // distribute TData - in case of a union, do the next steps for each member\n TData extends any ?\n // prevent \"Type instantiation is excessively deep and possibly infinite.\"\n true extends IsAny<TData> ? TData\n : TData extends { __masked?: true } ?\n Prettify<RemoveMaskedMarker<TData>>\n : Unmasked<TData>\n : never\n : DataMasking extends { mode: \"preserveTypes\" } ? TData\n : TData;\n\n /**\n * Unmasks a type to provide its full result.\n */\n export type Unmasked<TData> =\n true extends IsAny<TData> ? TData\n : TData extends object ?\n true extends ContainsFragmentsRefs<TData> ?\n UnwrapFragmentRefs<RemoveMaskedMarker<RemoveFragmentName<TData>>>\n : TData\n : TData;\n}\n"]}
1
+ {"version":3,"file":"GraphQLCodegenDataMasking.js","sourceRoot":"","sources":["../../src/masking/GraphQLCodegenDataMasking.ts"],"names":[],"mappings":"","sourcesContent":["import type { HKT } from \"@apollo/client/utilities\";\nimport type { IsAny } from \"@apollo/client/utilities/internal\";\n\nimport type {\n ContainsFragmentsRefs,\n RemoveFragmentName,\n UnwrapFragmentRefs,\n} from \"./internal/types.js\";\nexport declare namespace GraphQLCodegenDataMasking {\n export interface TypeOverrides {\n FragmentType: HKTImplementation.FragmentType;\n MaybeMasked: HKTImplementation.MaybeMasked;\n Unmasked: HKTImplementation.Unmasked;\n }\n namespace HKTImplementation {\n export interface FragmentType extends HKT {\n arg1: unknown; // TData\n return: GraphQLCodegenDataMasking.FragmentType<this[\"arg1\"]>;\n }\n\n export interface MaybeMasked extends HKT {\n arg1: unknown; // TData\n return: GraphQLCodegenDataMasking.MaybeMasked<this[\"arg1\"]>;\n }\n\n export interface Unmasked extends HKT {\n arg1: unknown; // TData\n return: GraphQLCodegenDataMasking.Unmasked<this[\"arg1\"]>;\n }\n }\n\n export type FragmentType<TData> =\n [TData] extends [{ \" $fragmentName\"?: infer TKey }] ?\n TKey extends string ?\n { \" $fragmentRefs\"?: { [key in TKey]: TData } }\n : never\n : never;\n\n /**\n * Unwraps the type to its masked type.\n *\n * @remarks\n * GraphQL Codegen generates types as masked types. The implementation is an\n * identity type.\n */\n export type MaybeMasked<TData> = TData;\n\n /**\n * Unmasks a type to provide its full result.\n */\n export type Unmasked<TData> =\n true extends IsAny<TData> ? TData\n : TData extends object ?\n true extends ContainsFragmentsRefs<TData> ?\n UnwrapFragmentRefs<RemoveFragmentName<TData>>\n : TData\n : TData;\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import type { HKT } from "@apollo/client/utilities";
2
+ export declare namespace PreserveTypes {
3
+ interface TypeOverrides {
4
+ FragmentType: HKTImplementation.FragmentType;
5
+ MaybeMasked: HKTImplementation.MaybeMasked;
6
+ Unmasked: HKTImplementation.Unmasked;
7
+ }
8
+ namespace HKTImplementation {
9
+ interface FragmentType extends HKT {
10
+ arg1: unknown;
11
+ return: never;
12
+ }
13
+ interface MaybeMasked extends HKT {
14
+ arg1: unknown;
15
+ return: this["arg1"];
16
+ }
17
+ interface Unmasked extends HKT {
18
+ arg1: unknown;
19
+ return: this["arg1"];
20
+ }
21
+ }
22
+ type FragmentType<_TData> = never;
23
+ type MaybeMasked<TData> = TData;
24
+ type Unmasked<TData> = TData;
25
+ }
26
+ //# sourceMappingURL=PreserveTypes.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PreserveTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreserveTypes.js","sourceRoot":"","sources":["../../src/masking/PreserveTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { HKT } from \"@apollo/client/utilities\";\n\nexport declare namespace PreserveTypes {\n export interface TypeOverrides {\n FragmentType: HKTImplementation.FragmentType;\n MaybeMasked: HKTImplementation.MaybeMasked;\n Unmasked: HKTImplementation.Unmasked;\n }\n namespace HKTImplementation {\n export interface FragmentType extends HKT {\n arg1: unknown; // TData\n return: never;\n }\n\n export interface MaybeMasked extends HKT {\n arg1: unknown; // TData\n return: this[\"arg1\"];\n }\n\n export interface Unmasked extends HKT {\n arg1: unknown; // TData\n return: this[\"arg1\"];\n }\n }\n\n export type FragmentType<_TData> = never;\n export type MaybeMasked<TData> = TData;\n export type Unmasked<TData> = TData;\n}\n"]}
@@ -1,4 +1,4 @@
1
- export type { DataMasking, FragmentType, Masked, MaskedDocumentNode, MaybeMasked, Unmasked, } from "./types.js";
1
+ export type { FragmentType, MaybeMasked, Unmasked } from "./types.js";
2
2
  export type { GraphQLCodegenDataMasking } from "./GraphQLCodegenDataMasking.js";
3
3
  export { disableWarningsSlot } from "./utils.js";
4
4
  export { maskFragment } from "./maskFragment.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/masking/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export type {\n DataMasking,\n FragmentType,\n Masked,\n MaskedDocumentNode,\n MaybeMasked,\n Unmasked,\n} from \"./types.js\";\nexport type { GraphQLCodegenDataMasking } from \"./GraphQLCodegenDataMasking.js\";\nexport { disableWarningsSlot } from \"./utils.js\";\nexport { maskFragment } from \"./maskFragment.js\";\nexport { maskOperation } from \"./maskOperation.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/masking/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export type { FragmentType, MaybeMasked, Unmasked } from \"./types.js\";\nexport type { GraphQLCodegenDataMasking } from \"./GraphQLCodegenDataMasking.js\";\nexport { disableWarningsSlot } from \"./utils.js\";\nexport { maskFragment } from \"./maskFragment.js\";\nexport { maskOperation } from \"./maskOperation.js\";\n"]}
@@ -113,7 +113,6 @@ type MergeObjects<T, U> = Prettify<{
113
113
  infer UK extends object
114
114
  ]) ? TK extends unknown[] ? UK extends unknown[] ? CombineIntersection<TK[number] | UK[number]>[] | Extract<T[k] | U[k], undefined | null> : T[k] : CombineIntersection<TK | UK> | Extract<T[k] | U[k], undefined | null> : T[k] : T[k];
115
115
  } & Pick<U, Exclude<keyof U, keyof T>>>;
116
- export type RemoveMaskedMarker<T> = Omit<T, "__masked">;
117
116
  export type RemoveFragmentName<T> = T extends any ? Omit<T, " $fragmentName"> : T;
118
117
  type Exact<in out T> = (x: T) => T;
119
118
  export type ContainsFragmentsRefs<TData, Seen = never> = true extends (IsAny<TData>) ? false : TData extends object ? Exact<TData> extends Seen ? false : " $fragmentRefs" extends keyof RemoveIndexSignature<TData> ? true : ContainsFragmentsRefs<TData[keyof TData], Seen | Exact<TData>> : false;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/masking/internal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n IsAny,\n Prettify,\n Primitive,\n RemoveIndexSignature,\n} from \"@apollo/client/utilities/internal\";\n\nexport type UnwrapFragmentRefs<TData> =\n true extends IsAny<TData> ? TData\n : TData extends any ?\n // Ensure tagged/branded types are left alone (i.e. type UUID = string & { ... })\n TData extends Primitive ? TData\n : // Leave TData alone if it is Record<string, any> and not a specific shape\n string extends keyof TData ? TData\n : // short-circuit on empty object\n keyof TData extends never ? TData\n : TData extends { \" $fragmentRefs\"?: infer FragmentRefs } ?\n UnwrapFragmentRefs<\n CombineIntersection<\n | Omit<TData, \" $fragmentRefs\">\n | RemoveFragmentName<\n NonNullable<\n NonNullable<FragmentRefs>[keyof NonNullable<FragmentRefs>]\n >\n >\n >\n >\n : TData extends object ?\n {\n [K in keyof TData]: UnwrapFragmentRefs<TData[K]>;\n }\n : TData\n : never;\n\n/**\n * ```ts\n * CombineIntersection<\n * | { foo: string }\n * | { __typename: \"A\"; a: string }\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: string }\n * > =>\n * | { foo: string }\n * | CombineByTypeName<\n * | { __typename: \"A\"; a: string }\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: string }\n * >\n * ```\n */\ntype CombineIntersection<T> =\n | Exclude<T, { __typename?: string }>\n | CombineByTypeName<Extract<T, { __typename?: string }>>;\n/**\n * ```ts\n * CombineByTypeName<\n * | { __typename: \"A\"; a: string }\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: string }\n * > =>\n * | CombineWithArrays<\n * | { __typename: \"A\"; a: string }\n * >\n * | CombineWithArrays<\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: number }\n * >\n * ```\n */\ntype CombineByTypeName<T extends { __typename?: string }> = {\n [TypeName in NonNullable<T[\"__typename\"]>]: Prettify<\n MergeUnions<ExtractByMatchingTypeNames<T, TypeName>>\n >;\n}[NonNullable<T[\"__typename\"]>];\n\n/**\n * ```ts\n * CombineByTypeName<\n * | {\n * __typename: \"Person\" | \"Animatronic\" | \"CartoonCharacter\";\n * id: number;\n * name: string;\n * }\n * | {\n * __typename: \"Person\";\n * birthdate: string;\n * }\n * | {\n * __typename: \"Animatronic\";\n * manufacturer: string;\n * warrantyEndDate: string;\n * }\n * | {\n * __typename: \"CartoonCharacter\";\n * animator: string;\n * voiceActor: string;\n * }\n * >\n * =>\n * {\n * id: number;\n * name: string;\n * __typename: \"Person\";\n * birthdate: string;\n * } | {\n * id: number;\n * name: string;\n * __typename: \"Animatronic\";\n * manufacturer: string;\n * warrantyEndDate: string;\n * } | {\n * id: number;\n * name: string;\n * __typename: \"CartoonCharacter\";\n * animator: string;\n * voiceActor: string;\n * }\n * ```\n */\ntype ExtractByMatchingTypeNames<\n Union extends { __typename?: string },\n TypeName extends string,\n> = Union extends any ?\n TypeName extends NonNullable<Union[\"__typename\"]> ?\n Omit<Union, \"__typename\"> & {\n // preserve `?`, which `& { __typename: TypeName }` would not do\n [K in keyof Union as K extends \"__typename\" ? K : never]: TypeName;\n }\n : never\n: never;\n\ntype MergeUnions<TUnion> = MergeUnionsAcc<\n TUnion,\n takeOneFromUnion<TUnion>,\n never\n>;\n\ntype DistributedRequiredExclude<T, U> =\n T extends any ?\n Required<T> extends Required<U> ?\n Required<U> extends Required<T> ?\n never\n : T\n : T\n : T;\n\ntype MergeUnionsAcc<TUnion, Curr, Merged> =\n [Curr] extends [never] ? Merged\n : MergeUnionsAcc<\n DistributedRequiredExclude<TUnion, Curr>,\n takeOneFromUnion<DistributedRequiredExclude<TUnion, Curr>>,\n [Merged] extends [never] ? Curr : MergeObjects<Curr, Merged>\n >;\ntype unionToIntersection<T> =\n (T extends unknown ? (x: T) => unknown : never) extends (\n (x: infer U) => unknown\n ) ?\n U\n : never;\n\ntype takeOneFromUnion<T> =\n unionToIntersection<T extends T ? (x: T) => 0 : never> extends (\n (x: infer U) => 0\n ) ?\n U\n : never;\n\ntype MergeObjects<T, U> = Prettify<\n {\n [k in keyof T]: k extends keyof U ?\n [NonNullable<T[k]>, NonNullable<U[k]>] extends (\n [infer TK extends object, infer UK extends object]\n ) ?\n TK extends unknown[] ?\n UK extends unknown[] ?\n | CombineIntersection<TK[number] | UK[number]>[]\n | Extract<T[k] | U[k], undefined | null>\n : T[k]\n : CombineIntersection<TK | UK> | Extract<T[k] | U[k], undefined | null>\n : T[k]\n : T[k];\n } & Pick<U, Exclude<keyof U, keyof T>>\n>;\n\nexport type RemoveMaskedMarker<T> = Omit<T, \"__masked\">;\n// force distrubution when T is a union with | undefined\nexport type RemoveFragmentName<T> =\n T extends any ? Omit<T, \" $fragmentName\"> : T;\n\ntype Exact<in out T> = (x: T) => T;\nexport type ContainsFragmentsRefs<TData, Seen = never> = true extends (\n IsAny<TData>\n) ?\n false\n: TData extends object ?\n Exact<TData> extends Seen ? false\n : \" $fragmentRefs\" extends keyof RemoveIndexSignature<TData> ? true\n : ContainsFragmentsRefs<TData[keyof TData], Seen | Exact<TData>>\n: false;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/masking/internal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n IsAny,\n Prettify,\n Primitive,\n RemoveIndexSignature,\n} from \"@apollo/client/utilities/internal\";\n\nexport type UnwrapFragmentRefs<TData> =\n true extends IsAny<TData> ? TData\n : TData extends any ?\n // Ensure tagged/branded types are left alone (i.e. type UUID = string & { ... })\n TData extends Primitive ? TData\n : // Leave TData alone if it is Record<string, any> and not a specific shape\n string extends keyof TData ? TData\n : // short-circuit on empty object\n keyof TData extends never ? TData\n : TData extends { \" $fragmentRefs\"?: infer FragmentRefs } ?\n UnwrapFragmentRefs<\n CombineIntersection<\n | Omit<TData, \" $fragmentRefs\">\n | RemoveFragmentName<\n NonNullable<\n NonNullable<FragmentRefs>[keyof NonNullable<FragmentRefs>]\n >\n >\n >\n >\n : TData extends object ?\n {\n [K in keyof TData]: UnwrapFragmentRefs<TData[K]>;\n }\n : TData\n : never;\n\n/**\n * ```ts\n * CombineIntersection<\n * | { foo: string }\n * | { __typename: \"A\"; a: string }\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: string }\n * > =>\n * | { foo: string }\n * | CombineByTypeName<\n * | { __typename: \"A\"; a: string }\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: string }\n * >\n * ```\n */\ntype CombineIntersection<T> =\n | Exclude<T, { __typename?: string }>\n | CombineByTypeName<Extract<T, { __typename?: string }>>;\n/**\n * ```ts\n * CombineByTypeName<\n * | { __typename: \"A\"; a: string }\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: string }\n * > =>\n * | CombineWithArrays<\n * | { __typename: \"A\"; a: string }\n * >\n * | CombineWithArrays<\n * | { __typename: \"B\"; b1: number }\n * | { __typename: \"B\"; b2: number }\n * >\n * ```\n */\ntype CombineByTypeName<T extends { __typename?: string }> = {\n [TypeName in NonNullable<T[\"__typename\"]>]: Prettify<\n MergeUnions<ExtractByMatchingTypeNames<T, TypeName>>\n >;\n}[NonNullable<T[\"__typename\"]>];\n\n/**\n * ```ts\n * CombineByTypeName<\n * | {\n * __typename: \"Person\" | \"Animatronic\" | \"CartoonCharacter\";\n * id: number;\n * name: string;\n * }\n * | {\n * __typename: \"Person\";\n * birthdate: string;\n * }\n * | {\n * __typename: \"Animatronic\";\n * manufacturer: string;\n * warrantyEndDate: string;\n * }\n * | {\n * __typename: \"CartoonCharacter\";\n * animator: string;\n * voiceActor: string;\n * }\n * >\n * =>\n * {\n * id: number;\n * name: string;\n * __typename: \"Person\";\n * birthdate: string;\n * } | {\n * id: number;\n * name: string;\n * __typename: \"Animatronic\";\n * manufacturer: string;\n * warrantyEndDate: string;\n * } | {\n * id: number;\n * name: string;\n * __typename: \"CartoonCharacter\";\n * animator: string;\n * voiceActor: string;\n * }\n * ```\n */\ntype ExtractByMatchingTypeNames<\n Union extends { __typename?: string },\n TypeName extends string,\n> = Union extends any ?\n TypeName extends NonNullable<Union[\"__typename\"]> ?\n Omit<Union, \"__typename\"> & {\n // preserve `?`, which `& { __typename: TypeName }` would not do\n [K in keyof Union as K extends \"__typename\" ? K : never]: TypeName;\n }\n : never\n: never;\n\ntype MergeUnions<TUnion> = MergeUnionsAcc<\n TUnion,\n takeOneFromUnion<TUnion>,\n never\n>;\n\ntype DistributedRequiredExclude<T, U> =\n T extends any ?\n Required<T> extends Required<U> ?\n Required<U> extends Required<T> ?\n never\n : T\n : T\n : T;\n\ntype MergeUnionsAcc<TUnion, Curr, Merged> =\n [Curr] extends [never] ? Merged\n : MergeUnionsAcc<\n DistributedRequiredExclude<TUnion, Curr>,\n takeOneFromUnion<DistributedRequiredExclude<TUnion, Curr>>,\n [Merged] extends [never] ? Curr : MergeObjects<Curr, Merged>\n >;\ntype unionToIntersection<T> =\n (T extends unknown ? (x: T) => unknown : never) extends (\n (x: infer U) => unknown\n ) ?\n U\n : never;\n\ntype takeOneFromUnion<T> =\n unionToIntersection<T extends T ? (x: T) => 0 : never> extends (\n (x: infer U) => 0\n ) ?\n U\n : never;\n\ntype MergeObjects<T, U> = Prettify<\n {\n [k in keyof T]: k extends keyof U ?\n [NonNullable<T[k]>, NonNullable<U[k]>] extends (\n [infer TK extends object, infer UK extends object]\n ) ?\n TK extends unknown[] ?\n UK extends unknown[] ?\n | CombineIntersection<TK[number] | UK[number]>[]\n | Extract<T[k] | U[k], undefined | null>\n : T[k]\n : CombineIntersection<TK | UK> | Extract<T[k] | U[k], undefined | null>\n : T[k]\n : T[k];\n } & Pick<U, Exclude<keyof U, keyof T>>\n>;\n\n// force distrubution when T is a union with | undefined\nexport type RemoveFragmentName<T> =\n T extends any ? Omit<T, \" $fragmentName\"> : T;\n\ntype Exact<in out T> = (x: T) => T;\nexport type ContainsFragmentsRefs<TData, Seen = never> = true extends (\n IsAny<TData>\n) ?\n false\n: TData extends object ?\n Exact<TData> extends Seen ? false\n : \" $fragmentRefs\" extends keyof RemoveIndexSignature<TData> ? true\n : ContainsFragmentsRefs<TData[keyof TData], Seen | Exact<TData>>\n: false;\n"]}
@@ -1,32 +1,15 @@
1
1
  import type { TypeOverrides } from "@apollo/client";
2
2
  import type { ApplyHKTImplementationWithDefault } from "@apollo/client/utilities/internal";
3
- import type { GraphQLCodegenDataMasking } from "./GraphQLCodegenDataMasking.js";
4
- type DefaultImplementation = GraphQLCodegenDataMasking.Implementation;
5
- export interface DataMasking {
6
- }
3
+ import type { PreserveTypes } from "./PreserveTypes.js";
7
4
  /**
8
- * Returns TData as either masked or unmasked depending on whether masking is
9
- * enabled.
10
- */
11
- export type Masked<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Masked", DefaultImplementation, TData>;
12
- /**
13
- * Marks a type as masked. This is a shortcut for
14
- * `TypedDocumentNode<Masked<TData>, TVariables>`
5
+ * Type used with [fragments](https://apollographql.com/docs/react/data/fragments#using-with-fragments) to ensure parent objects contain the fragment spread from the type.
15
6
  */
16
- export type MaskedDocumentNode<TData = {
17
- [key: string]: any;
18
- }, TVariables = {
19
- [key: string]: any;
20
- }> = ApplyHKTImplementationWithDefault<TypeOverrides, "MaskedDocumentNode", DefaultImplementation, TData, TVariables>;
21
- export type FragmentType<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "FragmentType", DefaultImplementation, TData>;
7
+ export type FragmentType<TFragmentData> = ApplyHKTImplementationWithDefault<TypeOverrides, "FragmentType", PreserveTypes.TypeOverrides, TFragmentData>;
8
+ /** Unwraps `TData` into its unmasked type. */
9
+ export type Unmasked<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Unmasked", PreserveTypes.TypeOverrides, TData>;
22
10
  /**
23
11
  * Returns TData as either masked or unmasked depending on whether masking is
24
12
  * enabled.
25
13
  */
26
- export type MaybeMasked<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "MaybeMasked", DefaultImplementation, TData>;
27
- /**
28
- * Unmasks a type to provide its full result.
29
- */
30
- export type Unmasked<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "Unmasked", DefaultImplementation, TData>;
31
- export {};
14
+ export type MaybeMasked<TData> = ApplyHKTImplementationWithDefault<TypeOverrides, "MaybeMasked", PreserveTypes.TypeOverrides, TData>;
32
15
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/masking/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TypeOverrides } from \"@apollo/client\";\nimport type { ApplyHKTImplementationWithDefault } from \"@apollo/client/utilities/internal\";\n\nimport type { GraphQLCodegenDataMasking } from \"./GraphQLCodegenDataMasking.js\";\n\ntype DefaultImplementation = GraphQLCodegenDataMasking.Implementation;\n\nexport interface DataMasking {}\n\n/**\n * Returns TData as either masked or unmasked depending on whether masking is\n * enabled.\n */\nexport type Masked<TData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"Masked\",\n DefaultImplementation,\n TData\n>;\n\n/**\n * Marks a type as masked. This is a shortcut for\n * `TypedDocumentNode<Masked<TData>, TVariables>`\n */\nexport type MaskedDocumentNode<\n TData = { [key: string]: any },\n // eslint-disable-next-line local-rules/variables-should-extend-operation-variables\n TVariables = { [key: string]: any },\n> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"MaskedDocumentNode\",\n DefaultImplementation,\n TData,\n TVariables\n>;\n\nexport type FragmentType<TData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"FragmentType\",\n DefaultImplementation,\n TData\n>;\n\n/**\n * Returns TData as either masked or unmasked depending on whether masking is\n * enabled.\n */\nexport type MaybeMasked<TData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"MaybeMasked\",\n DefaultImplementation,\n TData\n>;\n\n/**\n * Unmasks a type to provide its full result.\n */\nexport type Unmasked<TData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"Unmasked\",\n DefaultImplementation,\n TData\n>;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/masking/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TypeOverrides } from \"@apollo/client\";\nimport type { ApplyHKTImplementationWithDefault } from \"@apollo/client/utilities/internal\";\n\nimport type { PreserveTypes } from \"./PreserveTypes.js\";\n\n/**\n * Type used with [fragments](https://apollographql.com/docs/react/data/fragments#using-with-fragments) to ensure parent objects contain the fragment spread from the type.\n */\nexport type FragmentType<TFragmentData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"FragmentType\",\n PreserveTypes.TypeOverrides,\n TFragmentData\n>;\n\n/** Unwraps `TData` into its unmasked type. */\nexport type Unmasked<TData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"Unmasked\",\n PreserveTypes.TypeOverrides,\n TData\n>;\n\n/**\n * Returns TData as either masked or unmasked depending on whether masking is\n * enabled.\n */\nexport type MaybeMasked<TData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"MaybeMasked\",\n PreserveTypes.TypeOverrides,\n TData\n>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo/client",
3
- "version": "4.0.0-rc.9",
3
+ "version": "4.0.0",
4
4
  "description": "A fully-featured caching GraphQL client.",
5
5
  "private": false,
6
6
  "keywords": [
@@ -277,6 +277,12 @@
277
277
  "default": "./utilities/environment/index.js"
278
278
  }
279
279
  },
280
+ "./v4-migration": {
281
+ "module": "./v4-migration.js",
282
+ "module-sync": "./v4-migration.js",
283
+ "require": "./__cjs/v4-migration.cjs",
284
+ "default": "./v4-migration.js"
285
+ },
280
286
  "./react/compiled": "./react/index.compiled.js"
281
287
  },
282
288
  "peerDependencies": {
@@ -314,7 +320,7 @@
314
320
  "access": "public"
315
321
  },
316
322
  "files": [
317
- "LICENSE",
323
+ "VERSIONING_POLICY.md",
318
324
  "**/*.md",
319
325
  "**/*.cjs",
320
326
  "**/*.cjs.map",
@@ -1,6 +1,7 @@
1
1
  import type { ApolloClient, DefaultContext, DocumentNode, ErrorPolicy, OperationVariables, RefetchWritePolicy, TypedDocumentNode, WatchQueryFetchPolicy } from "@apollo/client";
2
2
  import type { SubscribeToMoreFunction } from "@apollo/client";
3
- import type { FetchMoreFunction, QueryRef, RefetchFunction } from "@apollo/client/react/internal";
3
+ import type { QueryRef } from "@apollo/client/react";
4
+ import type { FetchMoreFunction, RefetchFunction } from "@apollo/client/react/internal";
4
5
  import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
5
6
  import type { SkipToken } from "./constants.js";
6
7
  export declare namespace useBackgroundQuery {
@@ -1 +1 @@
1
- {"version":3,"file":"useBackgroundQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useBackgroundQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,YAAY,GACb,MAAM,+BAA+B,CAAC;AAQvC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AA4X7D,MAAM,UAAU,kBAAkB,CAIhC,KAA0D,EAC1D,OAAqE;IAKrE,aAAa,CAAC;IACd,OAAO,QAAQ,CACb,oBAAoB;IACpB,yDAAyD;IACzD,mBAAmB,EACnB,eAAe,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAC1E,CAAC,KAAK,EAAE,OAAO,IAAK,EAAU,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,mBAAmB,CAK1B,KAA0D,EAC1D,OAEmD;IAKnD,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3E,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,iBAAiB,CAAC;IACrD,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAElC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AAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QAC9B,uEAAuE;QACvE,kEAAkE;IACpE,CAAC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAyC,KAAK,CAAC,WAAW,CACvE,CAAC,OAAO,EAAE,EAAE;QACV,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAE5C,kBAAkB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE3C,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,OAAO,GAAuC,KAAK,CAAC,WAAW,CACnE,CAAC,SAAS,EAAE,EAAE;QACZ,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAE5C,kBAAkB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE3C,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEzD,OAAO;QACL,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC;QACjD;YACE,SAAS;YACT,OAAO;YACP,kGAAkG;YAClG,eAAe,EAAE,QAAQ,CAAC,UAAU;iBACjC,eAA6D;SACjE;KACF,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n OperationVariables,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n} from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport { canonicalStringify } from \"@apollo/client/cache\";\nimport type {\n CacheKey,\n FetchMoreFunction,\n QueryRef,\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 VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { SkipToken } from \"./constants.js\";\nimport { 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 /**\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 }\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 UtilityDocumentationTypes.VariableOptions<TVariables> {}\n }\n }\n\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\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>;\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 namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\n export function useBackgroundQuery<\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/**\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 */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\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 }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n errorPolicy: \"ignore\" | \"all\";\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: boolean;\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken\n): [undefined, useBackgroundQuery.Result<TData, TVariables>];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n })\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]\n : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport 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, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport 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 // eslint-disable-next-line react-compiler/react-compiler\n useBackgroundQuery_,\n useApolloClient(typeof options === \"object\" ? options.client : undefined)\n )(query, options ?? ({} as any));\n}\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, variables } = watchQueryOptions;\n const { queryKey = [] } = 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 cacheKey: CacheKey = [\n query,\n canonicalStringify(variables),\n ...([] as any[]).concat(queryKey),\n ];\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: FetchMoreFunction<TData, TVariables> = React.useCallback(\n (options) => {\n const promise = queryRef.fetchMore(options);\n\n setWrappedQueryRef(wrapQueryRef(queryRef));\n\n return promise;\n },\n [queryRef]\n );\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":"AAAA,OAA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CACvE,CAAC,OAAO,EAAE,EAAE;QACV,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAE5C,kBAAkB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE3C,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,OAAO,GAAuC,KAAK,CAAC,WAAW,CACnE,CAAC,SAAS,EAAE,EAAE;QACZ,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAE5C,kBAAkB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE3C,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEzD,OAAO;QACL,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC;QACjD;YACE,SAAS;YACT,OAAO;YACP,kGAAkG;YAClG,eAAe,EAAE,QAAQ,CAAC,UAAU;iBACjC,eAA6D;SACjE;KACF,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n OperationVariables,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n} from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport { canonicalStringify } from \"@apollo/client/cache\";\nimport type { QueryRef } from \"@apollo/client/react\";\nimport type {\n CacheKey,\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 VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { SkipToken } from \"./constants.js\";\nimport { 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 /**\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 }\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 UtilityDocumentationTypes.VariableOptions<TVariables> {}\n }\n }\n\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\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>;\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 namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\n export function useBackgroundQuery<\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/**\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 */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\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 }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n errorPolicy: \"ignore\" | \"all\";\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\" | \"empty\">,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useBackgroundQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: boolean;\n }\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken\n): [undefined, useBackgroundQuery.Result<TData, TVariables>];\n\n/** {@inheritDoc @apollo/client/react!useBackgroundQuery:function(1)} */\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useBackgroundQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: boolean;\n })\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\" | \"partial\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\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\nexport function useBackgroundQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]\n : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]\n): [\n QueryRef<TData, TVariables, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport 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, \"complete\" | \"streaming\"> | undefined,\n useBackgroundQuery.Result<TData, TVariables>,\n];\n\nexport 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 // eslint-disable-next-line react-compiler/react-compiler\n useBackgroundQuery_,\n useApolloClient(typeof options === \"object\" ? options.client : undefined)\n )(query, options ?? ({} as any));\n}\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, variables } = watchQueryOptions;\n const { queryKey = [] } = 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 cacheKey: CacheKey = [\n query,\n canonicalStringify(variables),\n ...([] as any[]).concat(queryKey),\n ];\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: FetchMoreFunction<TData, TVariables> = React.useCallback(\n (options) => {\n const promise = queryRef.fetchMore(options);\n\n setWrappedQueryRef(wrapQueryRef(queryRef));\n\n return promise;\n },\n [queryRef]\n );\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"]}
@@ -173,7 +173,7 @@ export declare namespace useLazyQuery {
173
173
  */
174
174
  error?: ErrorLike;
175
175
  /**
176
- * If `true`, the query is still in flight and results have not yet been returned.
176
+ * If `true`, the query is still in flight.
177
177
  *
178
178
  * @docGroup 2. Network info
179
179
  */
@@ -1,6 +1,7 @@
1
1
  import type { ApolloClient, DataState, DefaultContext, DocumentNode, ErrorPolicy, OperationVariables, RefetchWritePolicy, TypedDocumentNode, WatchQueryFetchPolicy } from "@apollo/client";
2
2
  import type { SubscribeToMoreFunction } from "@apollo/client";
3
- import type { FetchMoreFunction, QueryRef, RefetchFunction } from "@apollo/client/react/internal";
3
+ import type { QueryRef } from "@apollo/client/react";
4
+ import type { FetchMoreFunction, RefetchFunction } from "@apollo/client/react/internal";
4
5
  type ResetFunction = () => void;
5
6
  export declare namespace useLoadableQuery {
6
7
  type LoadQueryFunction<TVariables extends OperationVariables> = (...args: {} extends TVariables ? [variables?: TVariables] : [variables: TVariables]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useLoadableQuery.js","sources":["../../../src/react/hooks/useLoadableQuery.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n ObservableQuery,\n OperationVariables,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n} from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport { canonicalStringify } from \"@apollo/client/cache\";\nimport type {\n CacheKey,\n FetchMoreFunction,\n QueryRef,\n RefetchFunction,\n} from \"@apollo/client/react/internal\";\nimport {\n assertWrappedQueryRef,\n getSuspenseCache,\n unwrapQueryRef,\n updateWrappedQueryRef,\n wrapQueryRef,\n} from \"@apollo/client/react/internal\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\n\nimport { __use, useDeepMemo, useRenderGuard } from \"./internal/index.js\";\nimport { validateSuspenseHookOptions } from \"./internal/validateSuspenseHookOptions.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\ntype ResetFunction = () => void;\n\nexport declare namespace useLoadableQuery {\n export type LoadQueryFunction<TVariables extends OperationVariables> = (\n // Use variadic args to handle cases where TVariables is type `never`, in\n // which case we don't want to allow a variables argument. In other\n // words, we don't want to allow variables to be passed as an argument to this\n // function if the query does not expect variables in the document.\n ...args: {} extends TVariables ? [variables?: TVariables]\n : [variables: TVariables]\n ) => void;\n\n export type Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n TStates extends\n DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n > = [\n loadQuery: LoadQueryFunction<TVariables>,\n queryRef: QueryRef<TData, TVariables, TStates> | null,\n handlers: Handlers<TData, TVariables>,\n ];\n export interface Handlers<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#fetchMore:member} */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#refetch:member} */\n refetch: RefetchFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n /**\n * A function that resets the `queryRef` back to `null`.\n */\n reset: ResetFunction;\n }\n\n export type FetchPolicy = Extract<\n WatchQueryFetchPolicy,\n \"cache-first\" | \"network-only\" | \"no-cache\" | \"cache-and-network\"\n >;\n\n export interface Options {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */\n client?: ApolloClient;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */\n context?: DefaultContext;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\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#refetchWritePolicy:member} */\n refetchWritePolicy?: RefetchWritePolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#returnPartialData:member} */\n returnPartialData?: boolean;\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\n export function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options\n ): useLoadableQuery.Result<TData, TVariables>;\n }\n}\n\n/**\n * A hook for imperatively loading a query, such as responding to a user\n * interaction.\n *\n * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.\n *\n * @example\n *\n * ```jsx\n * import { gql, useLoadableQuery } from \"@apollo/client\";\n *\n * const GET_GREETING = gql`\n * query GetGreeting($language: String!) {\n * greeting(language: $language) {\n * message\n * }\n * }\n * `;\n *\n * function App() {\n * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);\n *\n * return (\n * <>\n * <button onClick={() => loadGreeting({ language: \"english\" })}>\n * Load greeting\n * </button>\n * <Suspense fallback={<div>Loading...</div>}>\n * {queryRef && <Hello queryRef={queryRef} />}\n * </Suspense>\n * </>\n * );\n * }\n *\n * function Hello({ queryRef }) {\n * const { data } = useReadQuery(queryRef);\n *\n * return <div>{data.greeting.message}</div>;\n * }\n * ```\n *\n * @param query - A GraphQL query document parsed into an AST by `gql`.\n * @param options - Options to control how the query is executed.\n * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`\n */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options & {\n returnPartialData: true;\n errorPolicy: \"ignore\" | \"all\";\n }\n): useLoadableQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\" | \"empty\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options & {\n errorPolicy: \"ignore\" | \"all\";\n }\n): useLoadableQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"empty\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options & {\n returnPartialData: true;\n }\n): useLoadableQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: useLoadableQuery.Options\n): useLoadableQuery.Result<TData, TVariables, \"complete\" | \"streaming\">;\n\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options = {}\n): useLoadableQuery.Result<TData, TVariables> {\n const client = useApolloClient(options.client);\n const suspenseCache = getSuspenseCache(client);\n const watchQueryOptions = useWatchQueryOptions({ client, query, options });\n const { queryKey = [] } = options;\n\n const [queryRef, setQueryRef] = React.useState<QueryRef<\n TData,\n TVariables,\n DataState<TData>[\"dataState\"]\n > | null>(null);\n\n assertWrappedQueryRef(queryRef);\n\n const internalQueryRef = queryRef && unwrapQueryRef(queryRef);\n\n if (queryRef && internalQueryRef?.didChangeOptions(watchQueryOptions)) {\n const promise = internalQueryRef.applyOptions(watchQueryOptions);\n updateWrappedQueryRef(queryRef, promise);\n }\n\n const calledDuringRender = useRenderGuard();\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = React.useCallback(\n (options) => {\n if (!internalQueryRef) {\n throw new Error(\n \"The query has not been loaded. Please load the query.\"\n );\n }\n\n const promise = internalQueryRef.fetchMore(options);\n\n setQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (options) => {\n if (!internalQueryRef) {\n throw new Error(\n \"The query has not been loaded. Please load the query.\"\n );\n }\n\n const promise = internalQueryRef.refetch(options);\n\n setQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n const loadQuery: useLoadableQuery.LoadQueryFunction<TVariables> =\n React.useCallback(\n (...args) => {\n invariant(\n !calledDuringRender(),\n \"useLoadableQuery: 'loadQuery' should not be called during render. To start a query during render, use the 'useBackgroundQuery' hook.\"\n );\n\n const [variables] = args;\n\n const cacheKey: CacheKey = [\n query,\n canonicalStringify(variables),\n ...([] as any[]).concat(queryKey),\n ];\n\n const queryRef = suspenseCache.getQueryRef(cacheKey, () =>\n client.watchQuery({\n ...watchQueryOptions,\n variables,\n } as ApolloClient.WatchQueryOptions<any, any>)\n );\n\n setQueryRef(wrapQueryRef(queryRef));\n },\n [\n query,\n queryKey,\n suspenseCache,\n watchQueryOptions,\n calledDuringRender,\n client,\n ]\n );\n\n const subscribeToMore: SubscribeToMoreFunction<TData, TVariables> =\n React.useCallback(\n (options) => {\n invariant(\n internalQueryRef,\n \"The query has not been loaded. Please load the query.\"\n );\n\n return internalQueryRef.observable.subscribeToMore(\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n options as any as ObservableQuery.SubscribeToMoreOptions<\n TData,\n OperationVariables\n >\n );\n },\n [internalQueryRef]\n );\n\n const reset: ResetFunction = React.useCallback(() => {\n setQueryRef(null);\n }, []);\n\n return [loadQuery, queryRef, { fetchMore, refetch, reset, subscribeToMore }];\n}\n\nfunction useWatchQueryOptions<TData, TVariables extends OperationVariables>({\n client,\n query,\n options,\n}: {\n client: ApolloClient;\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n options: useLoadableQuery.Options;\n}): ApolloClient.WatchQueryOptions<TData, TVariables> {\n return useDeepMemo<ApolloClient.WatchQueryOptions<TData, TVariables>>(() => {\n const fetchPolicy =\n options.fetchPolicy ||\n client.defaultOptions.watchQuery?.fetchPolicy ||\n \"cache-first\";\n\n const watchQueryOptions = {\n ...options,\n fetchPolicy,\n query,\n notifyOnNetworkStatusChange: false,\n nextFetchPolicy: void 0,\n };\n\n if (__DEV__) {\n validateSuspenseHookOptions(watchQueryOptions as any);\n }\n\n return watchQueryOptions as ApolloClient.WatchQueryOptions<\n TData,\n TVariables\n >;\n }, [client, options, query]);\n}\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAP,CAAA,EAAY,CAAZ,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAuB,CAAvB,CAAA,CAAA,CAAA,CAAA,CAAA,CAA8B;AAe9B,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAmC,CAAnC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyD;AAOzD,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EACL,CADF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACuB,EACrB,CAFF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAEkB,EAChB,CAHF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAGgB,EACd,CAJF,CAAA,CAAA,CAAA,CAAA,C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A,CAAA,CAAA,CAAqB,EAAE,CAAvB,CAAA,CAAA,CAAA,CAA4B,CAAC,CAAC;AAC9B;"}
1
+ {"version":3,"file":"useLoadableQuery.js","sources":["../../../src/react/hooks/useLoadableQuery.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n DefaultContext,\n DocumentNode,\n ErrorPolicy,\n ObservableQuery,\n OperationVariables,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n} from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport { canonicalStringify } from \"@apollo/client/cache\";\nimport type { QueryRef } from \"@apollo/client/react\";\nimport type {\n CacheKey,\n FetchMoreFunction,\n RefetchFunction,\n} from \"@apollo/client/react/internal\";\nimport {\n assertWrappedQueryRef,\n getSuspenseCache,\n unwrapQueryRef,\n updateWrappedQueryRef,\n wrapQueryRef,\n} from \"@apollo/client/react/internal\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\n\nimport { __use, useDeepMemo, useRenderGuard } from \"./internal/index.js\";\nimport { validateSuspenseHookOptions } from \"./internal/validateSuspenseHookOptions.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\ntype ResetFunction = () => void;\n\nexport declare namespace useLoadableQuery {\n export type LoadQueryFunction<TVariables extends OperationVariables> = (\n // Use variadic args to handle cases where TVariables is type `never`, in\n // which case we don't want to allow a variables argument. In other\n // words, we don't want to allow variables to be passed as an argument to this\n // function if the query does not expect variables in the document.\n ...args: {} extends TVariables ? [variables?: TVariables]\n : [variables: TVariables]\n ) => void;\n\n export type Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n TStates extends\n DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n > = [\n loadQuery: LoadQueryFunction<TVariables>,\n queryRef: QueryRef<TData, TVariables, TStates> | null,\n handlers: Handlers<TData, TVariables>,\n ];\n export interface Handlers<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#fetchMore:member} */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#refetch:member} */\n refetch: RefetchFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n /**\n * A function that resets the `queryRef` back to `null`.\n */\n reset: ResetFunction;\n }\n\n export type FetchPolicy = Extract<\n WatchQueryFetchPolicy,\n \"cache-first\" | \"network-only\" | \"no-cache\" | \"cache-and-network\"\n >;\n\n export interface Options {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */\n client?: ApolloClient;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */\n context?: DefaultContext;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\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#refetchWritePolicy:member} */\n refetchWritePolicy?: RefetchWritePolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#returnPartialData:member} */\n returnPartialData?: boolean;\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\n export function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options\n ): useLoadableQuery.Result<TData, TVariables>;\n }\n}\n\n/**\n * A hook for imperatively loading a query, such as responding to a user\n * interaction.\n *\n * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.\n *\n * @example\n *\n * ```jsx\n * import { gql, useLoadableQuery } from \"@apollo/client\";\n *\n * const GET_GREETING = gql`\n * query GetGreeting($language: String!) {\n * greeting(language: $language) {\n * message\n * }\n * }\n * `;\n *\n * function App() {\n * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);\n *\n * return (\n * <>\n * <button onClick={() => loadGreeting({ language: \"english\" })}>\n * Load greeting\n * </button>\n * <Suspense fallback={<div>Loading...</div>}>\n * {queryRef && <Hello queryRef={queryRef} />}\n * </Suspense>\n * </>\n * );\n * }\n *\n * function Hello({ queryRef }) {\n * const { data } = useReadQuery(queryRef);\n *\n * return <div>{data.greeting.message}</div>;\n * }\n * ```\n *\n * @param query - A GraphQL query document parsed into an AST by `gql`.\n * @param options - Options to control how the query is executed.\n * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`\n */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options & {\n returnPartialData: true;\n errorPolicy: \"ignore\" | \"all\";\n }\n): useLoadableQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\" | \"empty\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options & {\n errorPolicy: \"ignore\" | \"all\";\n }\n): useLoadableQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"empty\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options & {\n returnPartialData: true;\n }\n): useLoadableQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useLoadableQuery:function(1)} */\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: useLoadableQuery.Options\n): useLoadableQuery.Result<TData, TVariables, \"complete\" | \"streaming\">;\n\nexport function useLoadableQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useLoadableQuery.Options = {}\n): useLoadableQuery.Result<TData, TVariables> {\n const client = useApolloClient(options.client);\n const suspenseCache = getSuspenseCache(client);\n const watchQueryOptions = useWatchQueryOptions({ client, query, options });\n const { queryKey = [] } = options;\n\n const [queryRef, setQueryRef] = React.useState<QueryRef<\n TData,\n TVariables,\n DataState<TData>[\"dataState\"]\n > | null>(null);\n\n assertWrappedQueryRef(queryRef);\n\n const internalQueryRef = queryRef && unwrapQueryRef(queryRef);\n\n if (queryRef && internalQueryRef?.didChangeOptions(watchQueryOptions)) {\n const promise = internalQueryRef.applyOptions(watchQueryOptions);\n updateWrappedQueryRef(queryRef, promise);\n }\n\n const calledDuringRender = useRenderGuard();\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = React.useCallback(\n (options) => {\n if (!internalQueryRef) {\n throw new Error(\n \"The query has not been loaded. Please load the query.\"\n );\n }\n\n const promise = internalQueryRef.fetchMore(options);\n\n setQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (options) => {\n if (!internalQueryRef) {\n throw new Error(\n \"The query has not been loaded. Please load the query.\"\n );\n }\n\n const promise = internalQueryRef.refetch(options);\n\n setQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n const loadQuery: useLoadableQuery.LoadQueryFunction<TVariables> =\n React.useCallback(\n (...args) => {\n invariant(\n !calledDuringRender(),\n \"useLoadableQuery: 'loadQuery' should not be called during render. To start a query during render, use the 'useBackgroundQuery' hook.\"\n );\n\n const [variables] = args;\n\n const cacheKey: CacheKey = [\n query,\n canonicalStringify(variables),\n ...([] as any[]).concat(queryKey),\n ];\n\n const queryRef = suspenseCache.getQueryRef(cacheKey, () =>\n client.watchQuery({\n ...watchQueryOptions,\n variables,\n } as ApolloClient.WatchQueryOptions<any, any>)\n );\n\n setQueryRef(wrapQueryRef(queryRef));\n },\n [\n query,\n queryKey,\n suspenseCache,\n watchQueryOptions,\n calledDuringRender,\n client,\n ]\n );\n\n const subscribeToMore: SubscribeToMoreFunction<TData, TVariables> =\n React.useCallback(\n (options) => {\n invariant(\n internalQueryRef,\n \"The query has not been loaded. Please load the query.\"\n );\n\n return internalQueryRef.observable.subscribeToMore(\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n options as any as ObservableQuery.SubscribeToMoreOptions<\n TData,\n OperationVariables\n >\n );\n },\n [internalQueryRef]\n );\n\n const reset: ResetFunction = React.useCallback(() => {\n setQueryRef(null);\n }, []);\n\n return [loadQuery, queryRef, { fetchMore, refetch, reset, subscribeToMore }];\n}\n\nfunction useWatchQueryOptions<TData, TVariables extends OperationVariables>({\n client,\n query,\n options,\n}: {\n client: ApolloClient;\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n options: useLoadableQuery.Options;\n}): ApolloClient.WatchQueryOptions<TData, TVariables> {\n return useDeepMemo<ApolloClient.WatchQueryOptions<TData, TVariables>>(() => {\n const fetchPolicy =\n options.fetchPolicy ||\n client.defaultOptions.watchQuery?.fetchPolicy ||\n \"cache-first\";\n\n const watchQueryOptions = {\n ...options,\n fetchPolicy,\n query,\n notifyOnNetworkStatusChange: false,\n nextFetchPolicy: void 0,\n };\n\n if (__DEV__) {\n validateSuspenseHookOptions(watchQueryOptions as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ACX,CAAN,CAAA,CAAA,CAAA,CAAW;YACL,CAAN,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiC,EAAE,CAAnC,CAAA,CAAA,CAAA,CAAwC;YAClC,CAAN,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAqB,EAAE,CAAvB,CAAA,CAAA,EAA4B,CAAC;QAC7B,CAAK;QAED,CAAJ,EAAA,CAAQ,CAAR,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,EAAE;YACX,CAAN,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiC,CAAC,CAAlC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA0D,CAAC;QACvD;QAEA,CAAJ,CAAA,CAAA,CAAA,CAAA,EAAW,CAAX,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAGK;IACH,CAAC,EAAE,CAAC,CAAN,CAAA,CAAA,CAAA,CAAA,CAAY,EAAE,CAAd,CAAA,CAAA,CAAA,CAAA,CAAA,CAAqB,EAAE,CAAvB,CAAA,CAAA,CAAA,CAA4B,CAAC,CAAC;AAC9B;"}
@@ -149,7 +149,7 @@ export declare namespace useQuery {
149
149
  */
150
150
  error?: ErrorLike;
151
151
  /**
152
- * If `true`, the query is still in flight and results have not yet been returned.
152
+ * If `true`, the query is still in flight.
153
153
  *
154
154
  * @docGroup 2. Network info
155
155
  */
@@ -1,6 +1,7 @@
1
1
  import type { DataState, OperationVariables } from "@apollo/client";
2
2
  import type { SubscribeToMoreFunction } from "@apollo/client";
3
- import type { FetchMoreFunction, QueryRef, RefetchFunction } from "@apollo/client/react/internal";
3
+ import type { QueryRef } from "@apollo/client/react";
4
+ import type { FetchMoreFunction, RefetchFunction } from "@apollo/client/react/internal";
4
5
  export declare namespace useQueryRefHandlers {
5
6
  interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> {
6
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"useQueryRefHandlers.js","sourceRoot":"","sources":["../../../src/react/hooks/useQueryRefHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,YAAY,GACb,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA0BvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB,CAIjC,QAAoE;IAEpE,aAAa,CAAC;IACd,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC3C,MAAM,gBAAgB,GAAG,eAAe,CACtC,SAAS,CAAC,CAAC;QACT,0EAA0E;QAC1E,iFAAiF;QAChF,SAAS,CAAC,YAAY,CAAS;QAClC,CAAC,CAAC,SAAS,CAC6B,CAAC;IAE3C,OAAO,QAAQ,CACb,qBAAqB;IACrB,yDAAyD;IACzD,oBAAoB,EACpB,gBAAgB,CACjB,CAAC,QAAQ,CAAC,CAAC;AACd,CAAC;AAED,SAAS,oBAAoB,CAI3B,QAAoE;IAEpE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACzE,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvE,MAAM,gBAAgB,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAElD,4EAA4E;IAC5E,2EAA2E;IAC3E,gEAAgE;IAChE,IAAI,gBAAgB,KAAK,QAAQ,EAAE,CAAC;QAClC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QAC9B,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,qBAAqB,CAAC,QAAQ,EAAE,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,OAAO,GAAuC,KAAK,CAAC,WAAW,CACnE,CAAC,SAAS,EAAE,EAAE;QACZ,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEpD,kBAAkB,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAEnD,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,CAAC,gBAAgB,CAAC,CACnB,CAAC;IAEF,MAAM,SAAS,GAAyC,KAAK,CAAC,WAAW,CACvE,CAAC,OAAO,EAAE,EAAE;QACV,MAAM,OAAO,GAAG,gBAAgB,CAAC,SAAS,CACxC,OAAqD,CACtD,CAAC;QAEF,kBAAkB,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAEnD,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,CAAC,gBAAgB,CAAC,CACnB,CAAC;IAEF,OAAO;QACL,OAAO;QACP,SAAS;QACT,kGAAkG;QAClG,eAAe,EAAE,gBAAgB,CAAC,UAAU;aACzC,eAA6D;KACjE,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type { DataState, OperationVariables } from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport type { ApolloClient } from \"@apollo/client\";\nimport type { ObservableQuery } from \"@apollo/client\";\nimport type {\n FetchMoreFunction,\n QueryRef,\n RefetchFunction,\n} from \"@apollo/client/react/internal\";\nimport {\n assertWrappedQueryRef,\n getWrappedPromise,\n unwrapQueryRef,\n updateWrappedQueryRef,\n wrapQueryRef,\n} from \"@apollo/client/react/internal\";\n\nimport { wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\nexport declare namespace useQueryRefHandlers {\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!ObservableQuery#refetch:member(1)} */\n refetch: RefetchFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)} */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useQueryRefHandlers:function(1)} */\n export function useQueryRefHandlers<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n queryRef: QueryRef<TData, TVariables>\n ): useQueryRefHandlers.Result<TData, TVariables>;\n }\n}\n\n/**\n * A React hook that returns a `refetch` and `fetchMore` function for a given\n * `queryRef`.\n *\n * This is useful to get access to handlers for a `queryRef` that was created by\n * `createQueryPreloader` or when the handlers for a `queryRef` produced in\n * a different component are inaccessible.\n *\n * @example\n *\n * ```tsx\n * const MyComponent({ queryRef }) {\n * const { refetch, fetchMore } = useQueryRefHandlers(queryRef);\n *\n * // ...\n * }\n * ```\n *\n * @param queryRef - A `QueryRef` returned from `useBackgroundQuery`, `useLoadableQuery`, or `createQueryPreloader`.\n */\nexport function useQueryRefHandlers<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n queryRef: QueryRef<TData, TVariables, DataState<TData>[\"dataState\"]>\n): useQueryRefHandlers.Result<TData, TVariables> {\n \"use no memo\";\n const unwrapped = unwrapQueryRef(queryRef);\n const clientOrObsQuery = useApolloClient(\n unwrapped ?\n // passing an `ObservableQuery` is not supported by the types, but it will\n // return any truthy value that is passed in as an override so we cast the result\n (unwrapped[\"observable\"] as any)\n : undefined\n ) as ApolloClient | ObservableQuery<TData>;\n\n return wrapHook(\n \"useQueryRefHandlers\",\n // eslint-disable-next-line react-compiler/react-compiler\n useQueryRefHandlers_,\n clientOrObsQuery\n )(queryRef);\n}\n\nfunction useQueryRefHandlers_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n queryRef: QueryRef<TData, TVariables, DataState<TData>[\"dataState\"]>\n): useQueryRefHandlers.Result<TData, TVariables> {\n assertWrappedQueryRef(queryRef);\n const [previousQueryRef, setPreviousQueryRef] = React.useState(queryRef);\n const [wrappedQueryRef, setWrappedQueryRef] = React.useState(queryRef);\n const internalQueryRef = unwrapQueryRef(queryRef);\n\n // To ensure we can support React transitions, this hook needs to manage the\n // queryRef state and apply React's state value immediately to the existing\n // queryRef since this hook doesn't return the queryRef directly\n if (previousQueryRef !== queryRef) {\n setPreviousQueryRef(queryRef);\n setWrappedQueryRef(queryRef);\n } else {\n updateWrappedQueryRef(queryRef, getWrappedPromise(wrappedQueryRef));\n }\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (variables) => {\n const promise = internalQueryRef.refetch(variables);\n\n setWrappedQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = React.useCallback(\n (options) => {\n const promise = internalQueryRef.fetchMore(\n options as ObservableQuery.FetchMoreOptions<any, any>\n );\n\n setWrappedQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n return {\n refetch,\n fetchMore,\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n subscribeToMore: internalQueryRef.observable\n .subscribeToMore as SubscribeToMoreFunction<TData, TVariables>,\n };\n}\n"]}
1
+ {"version":3,"file":"useQueryRefHandlers.js","sourceRoot":"","sources":["../../../src/react/hooks/useQueryRefHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,YAAY,GACb,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA0BvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB,CAIjC,QAAoE;IAEpE,aAAa,CAAC;IACd,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC3C,MAAM,gBAAgB,GAAG,eAAe,CACtC,SAAS,CAAC,CAAC;QACT,0EAA0E;QAC1E,iFAAiF;QAChF,SAAS,CAAC,YAAY,CAAS;QAClC,CAAC,CAAC,SAAS,CAC6B,CAAC;IAE3C,OAAO,QAAQ,CACb,qBAAqB;IACrB,yDAAyD;IACzD,oBAAoB,EACpB,gBAAgB,CACjB,CAAC,QAAQ,CAAC,CAAC;AACd,CAAC;AAED,SAAS,oBAAoB,CAI3B,QAAoE;IAEpE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACzE,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvE,MAAM,gBAAgB,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAElD,4EAA4E;IAC5E,2EAA2E;IAC3E,gEAAgE;IAChE,IAAI,gBAAgB,KAAK,QAAQ,EAAE,CAAC;QAClC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QAC9B,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,qBAAqB,CAAC,QAAQ,EAAE,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,OAAO,GAAuC,KAAK,CAAC,WAAW,CACnE,CAAC,SAAS,EAAE,EAAE;QACZ,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEpD,kBAAkB,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAEnD,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,CAAC,gBAAgB,CAAC,CACnB,CAAC;IAEF,MAAM,SAAS,GAAyC,KAAK,CAAC,WAAW,CACvE,CAAC,OAAO,EAAE,EAAE;QACV,MAAM,OAAO,GAAG,gBAAgB,CAAC,SAAS,CACxC,OAAqD,CACtD,CAAC;QAEF,kBAAkB,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAEnD,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,CAAC,gBAAgB,CAAC,CACnB,CAAC;IAEF,OAAO;QACL,OAAO;QACP,SAAS;QACT,kGAAkG;QAClG,eAAe,EAAE,gBAAgB,CAAC,UAAU;aACzC,eAA6D;KACjE,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type { DataState, OperationVariables } from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport type { ApolloClient } from \"@apollo/client\";\nimport type { ObservableQuery } from \"@apollo/client\";\nimport type { QueryRef } from \"@apollo/client/react\";\nimport type {\n FetchMoreFunction,\n RefetchFunction,\n} from \"@apollo/client/react/internal\";\nimport {\n assertWrappedQueryRef,\n getWrappedPromise,\n unwrapQueryRef,\n updateWrappedQueryRef,\n wrapQueryRef,\n} from \"@apollo/client/react/internal\";\n\nimport { wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\nexport declare namespace useQueryRefHandlers {\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!ObservableQuery#refetch:member(1)} */\n refetch: RefetchFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)} */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n /** {@inheritDoc @apollo/client!ObservableQuery#subscribeToMore:member(1)} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n }\n\n export namespace DocumentationTypes {\n /** {@inheritDoc @apollo/client/react!useQueryRefHandlers:function(1)} */\n export function useQueryRefHandlers<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n queryRef: QueryRef<TData, TVariables>\n ): useQueryRefHandlers.Result<TData, TVariables>;\n }\n}\n\n/**\n * A React hook that returns a `refetch` and `fetchMore` function for a given\n * `queryRef`.\n *\n * This is useful to get access to handlers for a `queryRef` that was created by\n * `createQueryPreloader` or when the handlers for a `queryRef` produced in\n * a different component are inaccessible.\n *\n * @example\n *\n * ```tsx\n * const MyComponent({ queryRef }) {\n * const { refetch, fetchMore } = useQueryRefHandlers(queryRef);\n *\n * // ...\n * }\n * ```\n *\n * @param queryRef - A `QueryRef` returned from `useBackgroundQuery`, `useLoadableQuery`, or `createQueryPreloader`.\n */\nexport function useQueryRefHandlers<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n queryRef: QueryRef<TData, TVariables, DataState<TData>[\"dataState\"]>\n): useQueryRefHandlers.Result<TData, TVariables> {\n \"use no memo\";\n const unwrapped = unwrapQueryRef(queryRef);\n const clientOrObsQuery = useApolloClient(\n unwrapped ?\n // passing an `ObservableQuery` is not supported by the types, but it will\n // return any truthy value that is passed in as an override so we cast the result\n (unwrapped[\"observable\"] as any)\n : undefined\n ) as ApolloClient | ObservableQuery<TData>;\n\n return wrapHook(\n \"useQueryRefHandlers\",\n // eslint-disable-next-line react-compiler/react-compiler\n useQueryRefHandlers_,\n clientOrObsQuery\n )(queryRef);\n}\n\nfunction useQueryRefHandlers_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n queryRef: QueryRef<TData, TVariables, DataState<TData>[\"dataState\"]>\n): useQueryRefHandlers.Result<TData, TVariables> {\n assertWrappedQueryRef(queryRef);\n const [previousQueryRef, setPreviousQueryRef] = React.useState(queryRef);\n const [wrappedQueryRef, setWrappedQueryRef] = React.useState(queryRef);\n const internalQueryRef = unwrapQueryRef(queryRef);\n\n // To ensure we can support React transitions, this hook needs to manage the\n // queryRef state and apply React's state value immediately to the existing\n // queryRef since this hook doesn't return the queryRef directly\n if (previousQueryRef !== queryRef) {\n setPreviousQueryRef(queryRef);\n setWrappedQueryRef(queryRef);\n } else {\n updateWrappedQueryRef(queryRef, getWrappedPromise(wrappedQueryRef));\n }\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (variables) => {\n const promise = internalQueryRef.refetch(variables);\n\n setWrappedQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = React.useCallback(\n (options) => {\n const promise = internalQueryRef.fetchMore(\n options as ObservableQuery.FetchMoreOptions<any, any>\n );\n\n setWrappedQueryRef(wrapQueryRef(internalQueryRef));\n\n return promise;\n },\n [internalQueryRef]\n );\n\n return {\n refetch,\n fetchMore,\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n subscribeToMore: internalQueryRef.observable\n .subscribeToMore as SubscribeToMoreFunction<TData, TVariables>,\n };\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { DataState, ErrorLike, GetDataState, NetworkStatus } from "@apollo/client";
2
2
  import type { MaybeMasked } from "@apollo/client/masking";
3
- import type { QueryRef } from "@apollo/client/react/internal";
3
+ import type { QueryRef } from "@apollo/client/react";
4
4
  import type { DocumentationTypes as UtilityDocumentationTypes } from "@apollo/client/utilities/internal";
5
5
  export declare namespace useReadQuery {
6
6
  namespace Base {
@@ -1 +1 @@
1
- {"version":3,"file":"useReadQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useReadQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAqCjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,YAAY,CAI1B,QAAuC;IAEvC,aAAa,CAAC;IACd,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC3C,MAAM,gBAAgB,GAAG,eAAe,CACtC,SAAS,CAAC,CAAC;QACT,0EAA0E;QAC1E,iFAAiF;QAChF,SAAS,CAAC,YAAY,CAAS;QAClC,CAAC,CAAC,SAAS,CAC6B,CAAC;IAE3C,OAAO,QAAQ,CACb,cAAc;IACd,yDAAyD;IACzD,aAAa,EACb,gBAAgB,CACjB,CAAC,QAAQ,CAAC,CAAC;AACd,CAAC;AAED,SAAS,aAAa,CACpB,QAAuC;IAEvC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CACpC,GAAG,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,EAC9B,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAClC,GAAG,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EACjC,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC;QAC9B,gBAAgB,CAAC,YAAY,EAAE,CAAC;QAChC,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAErE,MAAM,OAAO,GAAG,oBAAoB,CAClC,KAAK,CAAC,WAAW,CACf,CAAC,WAAW,EAAE,EAAE;QACd,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;YACzC,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACzC,WAAW,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,EACD,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAC7B,EACD,UAAU,EACV,UAAU,CACX,CAAC;IAEF,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAE9B,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACxB,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,KAAK,EAAE,MAAM,CAAC,KAAK;SACmB,CAAC;IAC3C,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AACf,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n ErrorLike,\n GetDataState,\n NetworkStatus,\n ObservableQuery,\n} from \"@apollo/client\";\nimport type { MaybeMasked } from \"@apollo/client/masking\";\nimport type { QueryRef } from \"@apollo/client/react/internal\";\nimport {\n assertWrappedQueryRef,\n getWrappedPromise,\n unwrapQueryRef,\n updateWrappedQueryRef,\n} from \"@apollo/client/react/internal\";\nimport type { DocumentationTypes as UtilityDocumentationTypes } from \"@apollo/client/utilities/internal\";\n\nimport { __use, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore.js\";\n\nexport declare namespace useReadQuery {\n export namespace Base {\n export interface Result<TData = unknown> {\n /**\n * {@inheritDoc @apollo/client!QueryResultDocumentation#error:member}\n *\n * This property can be ignored when using the default `errorPolicy` or an\n * `errorPolicy` of `none`. The hook will throw the error instead of setting\n * this property.\n */\n error: ErrorLike | undefined;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#networkStatus:member} */\n networkStatus: NetworkStatus;\n }\n }\n export type Result<\n TData = unknown,\n TStates extends\n DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n > = Base.Result<TData> & GetDataState<MaybeMasked<TData>, TStates>;\n\n export namespace DocumentationTypes {\n namespace useReadQuery {\n export interface Result<TData = unknown>\n extends Base.Result<TData>,\n UtilityDocumentationTypes.DataState<TData> {}\n }\n\n /** {@inheritDoc @apollo/client/react!useReadQuery:function(1)} */\n export function useReadQuery<TData>(\n queryRef: QueryRef<TData>\n ): useReadQuery.Result<TData>;\n }\n}\n\n/**\n * For a detailed explanation of `useReadQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense#avoiding-request-waterfalls).\n *\n * @param queryRef - The `QueryRef` that was generated via `useBackgroundQuery`.\n * @returns An object containing the query result data, error, and network status.\n *\n * @example\n *\n * ```jsx\n * import { Suspense } from \"react\";\n * import { useBackgroundQuery, useReadQuery } from \"@apollo/client\";\n *\n * function Parent() {\n * const [queryRef] = useBackgroundQuery(query);\n *\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Child queryRef={queryRef} />\n * </Suspense>\n * );\n * }\n *\n * function Child({ queryRef }) {\n * const { data } = useReadQuery(queryRef);\n *\n * return <div>{data.name}</div>;\n * }\n * ```\n */\nexport function useReadQuery<\n TData,\n TStates extends DataState<TData>[\"dataState\"],\n>(\n queryRef: QueryRef<TData, any, TStates>\n): useReadQuery.Result<TData, TStates> {\n \"use no memo\";\n const unwrapped = unwrapQueryRef(queryRef);\n const clientOrObsQuery = useApolloClient(\n unwrapped ?\n // passing an `ObservableQuery` is not supported by the types, but it will\n // return any truthy value that is passed in as an override so we cast the result\n (unwrapped[\"observable\"] as any)\n : undefined\n ) as ApolloClient | ObservableQuery<TData>;\n\n return wrapHook(\n \"useReadQuery\",\n // eslint-disable-next-line react-compiler/react-compiler\n useReadQuery_,\n clientOrObsQuery\n )(queryRef);\n}\n\nfunction useReadQuery_<TData, TStates extends DataState<TData>[\"dataState\"]>(\n queryRef: QueryRef<TData, any, TStates>\n): useReadQuery.Result<TData, TStates> {\n assertWrappedQueryRef(queryRef);\n const internalQueryRef = React.useMemo(\n () => unwrapQueryRef(queryRef),\n [queryRef]\n );\n\n const getPromise = React.useCallback(\n () => getWrappedPromise(queryRef),\n [queryRef]\n );\n\n if (internalQueryRef.disposed) {\n internalQueryRef.reinitialize();\n updateWrappedQueryRef(queryRef, internalQueryRef.promise);\n }\n\n React.useEffect(() => internalQueryRef.retain(), [internalQueryRef]);\n\n const promise = useSyncExternalStore(\n React.useCallback(\n (forceUpdate) => {\n return internalQueryRef.listen((promise) => {\n updateWrappedQueryRef(queryRef, promise);\n forceUpdate();\n });\n },\n [internalQueryRef, queryRef]\n ),\n getPromise,\n getPromise\n );\n\n const result = __use(promise);\n\n return React.useMemo(() => {\n return {\n data: result.data,\n dataState: result.dataState,\n networkStatus: result.networkStatus,\n error: result.error,\n } as useReadQuery.Result<TData, TStates>;\n }, [result]);\n}\n"]}
1
+ {"version":3,"file":"useReadQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useReadQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,KAAK,EAAE,Q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AAC,WAAW,EAAE,EAAE;QACd,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;YACzC,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACzC,WAAW,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,EACD,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAC7B,EACD,UAAU,EACV,UAAU,CACX,CAAC;IAEF,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAE9B,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACxB,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,KAAK,EAAE,MAAM,CAAC,KAAK;SACmB,CAAC;IAC3C,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AACf,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n ErrorLike,\n GetDataState,\n NetworkStatus,\n ObservableQuery,\n} from \"@apollo/client\";\nimport type { MaybeMasked } from \"@apollo/client/masking\";\nimport type { QueryRef } from \"@apollo/client/react\";\nimport {\n assertWrappedQueryRef,\n getWrappedPromise,\n unwrapQueryRef,\n updateWrappedQueryRef,\n} from \"@apollo/client/react/internal\";\nimport type { DocumentationTypes as UtilityDocumentationTypes } from \"@apollo/client/utilities/internal\";\n\nimport { __use, wrapHook } from \"./internal/index.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore.js\";\n\nexport declare namespace useReadQuery {\n export namespace Base {\n export interface Result<TData = unknown> {\n /**\n * {@inheritDoc @apollo/client!QueryResultDocumentation#error:member}\n *\n * This property can be ignored when using the default `errorPolicy` or an\n * `errorPolicy` of `none`. The hook will throw the error instead of setting\n * this property.\n */\n error: ErrorLike | undefined;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#networkStatus:member} */\n networkStatus: NetworkStatus;\n }\n }\n export type Result<\n TData = unknown,\n TStates extends\n DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n > = Base.Result<TData> & GetDataState<MaybeMasked<TData>, TStates>;\n\n export namespace DocumentationTypes {\n namespace useReadQuery {\n export interface Result<TData = unknown>\n extends Base.Result<TData>,\n UtilityDocumentationTypes.DataState<TData> {}\n }\n\n /** {@inheritDoc @apollo/client/react!useReadQuery:function(1)} */\n export function useReadQuery<TData>(\n queryRef: QueryRef<TData>\n ): useReadQuery.Result<TData>;\n }\n}\n\n/**\n * For a detailed explanation of `useReadQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense#avoiding-request-waterfalls).\n *\n * @param queryRef - The `QueryRef` that was generated via `useBackgroundQuery`.\n * @returns An object containing the query result data, error, and network status.\n *\n * @example\n *\n * ```jsx\n * import { Suspense } from \"react\";\n * import { useBackgroundQuery, useReadQuery } from \"@apollo/client\";\n *\n * function Parent() {\n * const [queryRef] = useBackgroundQuery(query);\n *\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Child queryRef={queryRef} />\n * </Suspense>\n * );\n * }\n *\n * function Child({ queryRef }) {\n * const { data } = useReadQuery(queryRef);\n *\n * return <div>{data.name}</div>;\n * }\n * ```\n */\nexport function useReadQuery<\n TData,\n TStates extends DataState<TData>[\"dataState\"],\n>(\n queryRef: QueryRef<TData, any, TStates>\n): useReadQuery.Result<TData, TStates> {\n \"use no memo\";\n const unwrapped = unwrapQueryRef(queryRef);\n const clientOrObsQuery = useApolloClient(\n unwrapped ?\n // passing an `ObservableQuery` is not supported by the types, but it will\n // return any truthy value that is passed in as an override so we cast the result\n (unwrapped[\"observable\"] as any)\n : undefined\n ) as ApolloClient | ObservableQuery<TData>;\n\n return wrapHook(\n \"useReadQuery\",\n // eslint-disable-next-line react-compiler/react-compiler\n useReadQuery_,\n clientOrObsQuery\n )(queryRef);\n}\n\nfunction useReadQuery_<TData, TStates extends DataState<TData>[\"dataState\"]>(\n queryRef: QueryRef<TData, any, TStates>\n): useReadQuery.Result<TData, TStates> {\n assertWrappedQueryRef(queryRef);\n const internalQueryRef = React.useMemo(\n () => unwrapQueryRef(queryRef),\n [queryRef]\n );\n\n const getPromise = React.useCallback(\n () => getWrappedPromise(queryRef),\n [queryRef]\n );\n\n if (internalQueryRef.disposed) {\n internalQueryRef.reinitialize();\n updateWrappedQueryRef(queryRef, internalQueryRef.promise);\n }\n\n React.useEffect(() => internalQueryRef.retain(), [internalQueryRef]);\n\n const promise = useSyncExternalStore(\n React.useCallback(\n (forceUpdate) => {\n return internalQueryRef.listen((promise) => {\n updateWrappedQueryRef(queryRef, promise);\n forceUpdate();\n });\n },\n [internalQueryRef, queryRef]\n ),\n getPromise,\n getPromise\n );\n\n const result = __use(promise);\n\n return React.useMemo(() => {\n return {\n data: result.data,\n dataState: result.dataState,\n networkStatus: result.networkStatus,\n error: result.error,\n } as useReadQuery.Result<TData, TStates>;\n }, [result]);\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { ApolloClient, DefaultContext, DocumentNode, ErrorPolicy, OperationVariables, RefetchWritePolicy, TypedDocumentNode, WatchQueryFetchPolicy } from "@apollo/client";
2
2
  import type { SubscribeToMoreFunction } from "@apollo/client";
3
- import type { FetchMoreFunction, QueryRef, RefetchFunction } from "@apollo/client/react/internal";
3
+ import type { QueryRef } from "@apollo/client/react";
4
+ import type { FetchMoreFunction, RefetchFunction } from "@apollo/client/react/internal";
4
5
  import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
5
6
  import type { SkipToken } from "./constants.js";
6
7
  export declare namespace useBackgroundQuery {