@apollo/client 4.1.0-alpha.3 → 4.1.0-alpha.5

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 (215) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/__cjs/cache/core/types/common.cjs.map +1 -1
  3. package/__cjs/cache/core/types/common.d.cts +1 -1
  4. package/__cjs/cache/inmemory/entityStore.cjs +3 -1
  5. package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
  6. package/__cjs/cache/inmemory/fragmentRegistry.cjs +1 -1
  7. package/__cjs/cache/inmemory/fragmentRegistry.cjs.map +1 -1
  8. package/__cjs/cache/inmemory/helpers.d.cts +1 -1
  9. package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
  10. package/__cjs/core/ApolloClient.d.cts +7 -3
  11. package/__cjs/core/ObservableQuery.cjs +19 -35
  12. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  13. package/__cjs/core/ObservableQuery.d.cts +2 -2
  14. package/__cjs/core/QueryManager.cjs +1 -1
  15. package/__cjs/core/QueryManager.cjs.map +1 -1
  16. package/__cjs/dev/setErrorMessageHandler.cjs.map +1 -1
  17. package/__cjs/dev/setErrorMessageHandler.d.cts +1 -1
  18. package/__cjs/incremental/handlers/defer20220824.cjs +33 -23
  19. package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
  20. package/__cjs/incremental/handlers/defer20220824.d.cts +1 -0
  21. package/__cjs/incremental/handlers/graphql17Alpha9.cjs +24 -23
  22. package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
  23. package/__cjs/link/schema/index.cjs +1 -1
  24. package/__cjs/link/schema/index.cjs.map +1 -1
  25. package/__cjs/link/schema/index.d.cts +1 -1
  26. package/__cjs/link/subscriptions/index.cjs +2 -1
  27. package/__cjs/link/subscriptions/index.cjs.map +1 -1
  28. package/__cjs/masking/maskDefinition.cjs +1 -1
  29. package/__cjs/masking/maskDefinition.cjs.map +1 -1
  30. package/__cjs/masking/types.d.cts +2 -1
  31. package/__cjs/react/hooks/internal/index.cjs +3 -1
  32. package/__cjs/react/hooks/internal/index.cjs.map +1 -1
  33. package/__cjs/react/hooks/internal/index.d.cts +1 -0
  34. package/__cjs/react/hooks/internal/useDeepMemo.cjs +2 -0
  35. package/__cjs/react/hooks/internal/useDeepMemo.cjs.map +1 -1
  36. package/__cjs/react/hooks/internal/useRenderGuard.cjs +1 -1
  37. package/__cjs/react/hooks/internal/useRenderGuard.cjs.map +1 -1
  38. package/__cjs/react/hooks/internal/useSuspenseHookCacheKey.cjs +28 -0
  39. package/__cjs/react/hooks/internal/useSuspenseHookCacheKey.cjs.map +1 -0
  40. package/__cjs/react/hooks/internal/useSuspenseHookCacheKey.d.cts +11 -0
  41. package/__cjs/react/hooks/useBackgroundQuery.cjs +3 -11
  42. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  43. package/__cjs/react/hooks/useFragment.cjs +1 -3
  44. package/__cjs/react/hooks/useFragment.cjs.map +1 -1
  45. package/__cjs/react/hooks/useLazyQuery.cjs +2 -0
  46. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  47. package/__cjs/react/hooks/useLazyQuery.d.cts +1 -1
  48. package/__cjs/react/hooks/useMutation.d.cts +3 -1
  49. package/__cjs/react/hooks/useQuery.cjs +1 -4
  50. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  51. package/__cjs/react/hooks/useQuery.d.cts +1 -1
  52. package/__cjs/react/hooks/useQueryRefHandlers.cjs +1 -3
  53. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  54. package/__cjs/react/hooks/useReactiveVar.cjs +2 -1
  55. package/__cjs/react/hooks/useReactiveVar.cjs.map +1 -1
  56. package/__cjs/react/hooks/useReactiveVar.d.cts +2 -1
  57. package/__cjs/react/hooks/useReadQuery.cjs +1 -3
  58. package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
  59. package/__cjs/react/hooks/useReadQuery.d.cts +1 -1
  60. package/__cjs/react/hooks/useSubscription.cjs +1 -1
  61. package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
  62. package/__cjs/react/hooks/useSuspenseFragment.cjs +3 -4
  63. package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
  64. package/__cjs/react/hooks/useSuspenseQuery.cjs +6 -12
  65. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  66. package/__cjs/react/hooks/useSuspenseQuery.d.cts +1 -1
  67. package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
  68. package/__cjs/react/hooks/useSyncExternalStore.cjs.map +1 -1
  69. package/__cjs/react/internal/cache/QueryReference.cjs +1 -1
  70. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  71. package/__cjs/react/internal/cache/QueryReference.d.cts +4 -0
  72. package/__cjs/react/ssr/useSSRQuery.cjs +1 -0
  73. package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
  74. package/__cjs/react/types/types.documentation.d.cts +4 -16
  75. package/__cjs/testing/core/mocking/mockLink.cjs +2 -2
  76. package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
  77. package/__cjs/testing/core/mocking/mockLink.d.cts +3 -1
  78. package/__cjs/utilities/internal/DeepMerger.cjs +28 -5
  79. package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -1
  80. package/__cjs/utilities/internal/DeepMerger.d.cts +9 -5
  81. package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
  82. package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +1 -1
  83. package/__cjs/version.cjs +1 -1
  84. package/cache/core/types/common.d.ts +1 -1
  85. package/cache/core/types/common.js.map +1 -1
  86. package/cache/inmemory/entityStore.js +3 -1
  87. package/cache/inmemory/entityStore.js.map +1 -1
  88. package/cache/inmemory/fragmentRegistry.js +1 -1
  89. package/cache/inmemory/fragmentRegistry.js.map +1 -1
  90. package/cache/inmemory/helpers.d.ts +1 -1
  91. package/cache/inmemory/readFromStore.js.map +1 -1
  92. package/core/ApolloClient.d.ts +7 -3
  93. package/core/ObservableQuery.d.ts +2 -2
  94. package/core/ObservableQuery.js +19 -35
  95. package/core/ObservableQuery.js.map +1 -1
  96. package/core/QueryManager.js +1 -1
  97. package/core/QueryManager.js.map +1 -1
  98. package/dev/setErrorMessageHandler.d.ts +1 -1
  99. package/dev/setErrorMessageHandler.js.map +1 -1
  100. package/incremental/handlers/defer20220824.d.ts +1 -0
  101. package/incremental/handlers/defer20220824.js +33 -23
  102. package/incremental/handlers/defer20220824.js.map +1 -1
  103. package/incremental/handlers/graphql17Alpha9.js +24 -23
  104. package/incremental/handlers/graphql17Alpha9.js.map +1 -1
  105. package/link/schema/index.d.ts +1 -1
  106. package/link/schema/index.js +1 -1
  107. package/link/schema/index.js.map +1 -1
  108. package/link/subscriptions/index.js +2 -1
  109. package/link/subscriptions/index.js.map +1 -1
  110. package/masking/internal/types.js.map +1 -1
  111. package/masking/maskDefinition.js +1 -1
  112. package/masking/maskDefinition.js.map +1 -1
  113. package/masking/types.d.ts +2 -1
  114. package/masking/types.js.map +1 -1
  115. package/package.json +1 -1
  116. package/react/hooks/internal/index.d.ts +1 -0
  117. package/react/hooks/internal/index.js +1 -0
  118. package/react/hooks/internal/index.js.map +1 -1
  119. package/react/hooks/internal/useDeepMemo.js +2 -0
  120. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  121. package/react/hooks/internal/useRenderGuard.js +1 -1
  122. package/react/hooks/internal/useRenderGuard.js.map +1 -1
  123. package/react/hooks/internal/useSuspenseHookCacheKey.d.ts +11 -0
  124. package/react/hooks/internal/useSuspenseHookCacheKey.js +24 -0
  125. package/react/hooks/internal/useSuspenseHookCacheKey.js.map +1 -0
  126. package/react/hooks/useBackgroundQuery.js +4 -12
  127. package/react/hooks/useBackgroundQuery.js.map +1 -1
  128. package/react/hooks/useFragment.js +1 -3
  129. package/react/hooks/useFragment.js.map +1 -1
  130. package/react/hooks/useLazyQuery.d.ts +1 -1
  131. package/react/hooks/useLazyQuery.js +2 -0
  132. package/react/hooks/useLazyQuery.js.map +1 -1
  133. package/react/hooks/useMutation.d.ts +3 -1
  134. package/react/hooks/useQuery.d.ts +1 -1
  135. package/react/hooks/useQuery.js +1 -4
  136. package/react/hooks/useQuery.js.map +1 -1
  137. package/react/hooks/useQueryRefHandlers.js +1 -3
  138. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  139. package/react/hooks/useReactiveVar.d.ts +2 -1
  140. package/react/hooks/useReactiveVar.js +2 -1
  141. package/react/hooks/useReactiveVar.js.map +1 -1
  142. package/react/hooks/useReadQuery.d.ts +1 -1
  143. package/react/hooks/useReadQuery.js +1 -3
  144. package/react/hooks/useReadQuery.js.map +1 -1
  145. package/react/hooks/useSubscription.js +1 -1
  146. package/react/hooks/useSubscription.js.map +1 -1
  147. package/react/hooks/useSuspenseFragment.js +3 -4
  148. package/react/hooks/useSuspenseFragment.js.map +1 -1
  149. package/react/hooks/useSuspenseQuery.d.ts +1 -1
  150. package/react/hooks/useSuspenseQuery.js +7 -13
  151. package/react/hooks/useSuspenseQuery.js.map +1 -1
  152. package/react/hooks/useSyncExternalStore.js +1 -1
  153. package/react/hooks/useSyncExternalStore.js.map +1 -1
  154. package/react/hooks-compiled/internal/index.d.ts +1 -0
  155. package/react/hooks-compiled/internal/index.js +1 -0
  156. package/react/hooks-compiled/internal/index.js.map +1 -1
  157. package/react/hooks-compiled/internal/useDeepMemo.js +2 -0
  158. package/react/hooks-compiled/internal/useDeepMemo.js.map +1 -1
  159. package/react/hooks-compiled/internal/useRenderGuard.js +1 -1
  160. package/react/hooks-compiled/internal/useRenderGuard.js.map +1 -1
  161. package/react/hooks-compiled/internal/useSuspenseHookCacheKey.d.ts +11 -0
  162. package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js +71 -0
  163. package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js.map +1 -0
  164. package/react/hooks-compiled/useBackgroundQuery.js +6 -14
  165. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  166. package/react/hooks-compiled/useFragment.js +14 -18
  167. package/react/hooks-compiled/useFragment.js.map +1 -1
  168. package/react/hooks-compiled/useLazyQuery.d.ts +1 -1
  169. package/react/hooks-compiled/useLazyQuery.js +2 -0
  170. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  171. package/react/hooks-compiled/useLoadableQuery.js +69 -75
  172. package/react/hooks-compiled/useMutation.d.ts +3 -1
  173. package/react/hooks-compiled/useMutation.js +0 -12
  174. package/react/hooks-compiled/useMutation.js.map +1 -1
  175. package/react/hooks-compiled/useQuery.d.ts +1 -1
  176. package/react/hooks-compiled/useQuery.js +44 -56
  177. package/react/hooks-compiled/useQuery.js.map +1 -1
  178. package/react/hooks-compiled/useQueryRefHandlers.js +1 -5
  179. package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
  180. package/react/hooks-compiled/useReactiveVar.d.ts +2 -1
  181. package/react/hooks-compiled/useReactiveVar.js +2 -1
  182. package/react/hooks-compiled/useReactiveVar.js.map +1 -1
  183. package/react/hooks-compiled/useReadQuery.d.ts +1 -1
  184. package/react/hooks-compiled/useReadQuery.js +77 -14
  185. package/react/hooks-compiled/useReadQuery.js.map +1 -1
  186. package/react/hooks-compiled/useSubscription.js +237 -93
  187. package/react/hooks-compiled/useSubscription.js.map +1 -1
  188. package/react/hooks-compiled/useSuspenseFragment.js +3 -4
  189. package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
  190. package/react/hooks-compiled/useSuspenseQuery.d.ts +1 -1
  191. package/react/hooks-compiled/useSuspenseQuery.js +9 -19
  192. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  193. package/react/hooks-compiled/useSyncExternalStore.js +1 -1
  194. package/react/hooks-compiled/useSyncExternalStore.js.map +1 -1
  195. package/react/index.compiled.d.ts +1 -1
  196. package/react/index.compiled.js +1 -1
  197. package/react/index.compiled.js.map +1 -1
  198. package/react/internal/cache/QueryReference.d.ts +4 -0
  199. package/react/internal/cache/QueryReference.js +1 -1
  200. package/react/internal/cache/QueryReference.js.map +1 -1
  201. package/react/ssr/useSSRQuery.js +1 -0
  202. package/react/ssr/useSSRQuery.js.map +1 -1
  203. package/react/types/types.documentation.d.ts +4 -16
  204. package/react/types/types.documentation.js.map +1 -1
  205. package/testing/core/mocking/mockLink.d.ts +3 -1
  206. package/testing/core/mocking/mockLink.js +2 -2
  207. package/testing/core/mocking/mockLink.js.map +1 -1
  208. package/utilities/internal/DeepMerger.d.ts +9 -5
  209. package/utilities/internal/DeepMerger.js +28 -5
  210. package/utilities/internal/DeepMerger.js.map +1 -1
  211. package/utilities/internal/getMemoryInternals.js.map +1 -1
  212. package/utilities/internal/globals/global.js +2 -2
  213. package/utilities/internal/globals/global.js.map +1 -1
  214. package/utilities/internal/types/DocumentationTypes.d.ts +1 -1
  215. package/version.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 4.1.0-alpha.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#13010](https://github.com/apollographql/apollo-client/pull/13010) [`7627000`](https://github.com/apollographql/apollo-client/commit/76270002254b0c6acb18872a39ab180f9f1e4067) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where errors parsed from incremental chunks in `ErrorLink` might throw when using the `GraphQL17Alpha9Handler`.
8
+
9
+ - [#13010](https://github.com/apollographql/apollo-client/pull/13010) [`7627000`](https://github.com/apollographql/apollo-client/commit/76270002254b0c6acb18872a39ab180f9f1e4067) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Handle `@stream` payloads that send multiple items in the same chunk when using the `Defer20220824Handler`.
10
+
11
+ - [#13010](https://github.com/apollographql/apollo-client/pull/13010) [`7627000`](https://github.com/apollographql/apollo-client/commit/76270002254b0c6acb18872a39ab180f9f1e4067) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Handle an edge case with the `Defer20220824Handler` where an error for a `@stream` item that bubbles to the `@stream` boundary (such as an item returning `null` for a non-null array item) would write items from future chunks to the wrong array index. In these cases, the `@stream` field is no longer processed and future updates to the field are ignored. This prevents runtime errors that TypeScript would otherwise not be able to catch.
12
+
13
+ ## 4.1.0-alpha.4
14
+
15
+ ### Patch Changes
16
+
17
+ - [#13009](https://github.com/apollographql/apollo-client/pull/13009) [`259ae9b`](https://github.com/apollographql/apollo-client/commit/259ae9bafaa8122996b0a52dd99828b2261087e5) Thanks [@phryneas](https://github.com/phryneas)! - Allow `FragmentType` not only to be called as `FragmentType<TData>`, but also as `FragmentType<TypedDocumentNode>`.
18
+
19
+ - [#13012](https://github.com/apollographql/apollo-client/pull/13012) [`44706a2`](https://github.com/apollographql/apollo-client/commit/44706a2e7ae2c977fa917214a1ff5e5fe4a9b3a7) Thanks [@phryneas](https://github.com/phryneas)! - Add helper type `QueryRef.ForQuery<TypedDocumentNode>`
20
+
3
21
  ## 4.1.0-alpha.3
4
22
 
5
23
  ### Minor Changes
@@ -134,6 +152,36 @@
134
152
 
135
153
  - [#12923](https://github.com/apollographql/apollo-client/pull/12923) [`01cace0`](https://github.com/apollographql/apollo-client/commit/01cace0a6d4faf79e8a4188b93c7d13c4b26d6d4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Improve the cache data loss warning message when `existing` or `incoming` is an array.
136
154
 
155
+ ## 4.0.9
156
+
157
+ ### Patch Changes
158
+
159
+ - [#12993](https://github.com/apollographql/apollo-client/pull/12993) [`8f3bc9b`](https://github.com/apollographql/apollo-client/commit/8f3bc9b7253a737062dc0d652cd4f8b354f68ccc) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where switching from options with `variables` to `skipToken` with `useSuspenseQuery` and `useBackgroundQuery` would create a new `ObservableQuery`. This could cause unintended refetches where `variables` were absent in the request when the query was referenced with `refetchQueries`.
160
+
161
+ ## 4.0.8
162
+
163
+ ### Patch Changes
164
+
165
+ - [#12983](https://github.com/apollographql/apollo-client/pull/12983) [`f6d0efa`](https://github.com/apollographql/apollo-client/commit/f6d0efac4d99375c67255aee6d9b2981753b6f55) Thanks [@CarsonF](https://github.com/CarsonF)! - Fix cache.modify() mapping readonly arrays to singular reference
166
+
167
+ ## 4.0.7
168
+
169
+ ### Patch Changes
170
+
171
+ - [#12950](https://github.com/apollographql/apollo-client/pull/12950) [`5b4f36a`](https://github.com/apollographql/apollo-client/commit/5b4f36a2b249d15e2e8165bd32d9b2fca7e70217) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Don't send `operationType` in the payload sent by `GraphQLWsLink`.
172
+
173
+ ## 4.0.6
174
+
175
+ ### Patch Changes
176
+
177
+ - [#12937](https://github.com/apollographql/apollo-client/pull/12937) [`3b0d89b`](https://github.com/apollographql/apollo-client/commit/3b0d89bc9dde3eaee9ddf0aec387da43fe71abc0) Thanks [@phryneas](https://github.com/phryneas)! - Fix a problem with `fetchMore` where the loading state wouldn't reset if the result wouldn't result in a data update.
178
+
179
+ ## 4.0.5
180
+
181
+ ### Patch Changes
182
+
183
+ - [#12920](https://github.com/apollographql/apollo-client/pull/12920) [`e2fc385`](https://github.com/apollographql/apollo-client/commit/e2fc3850ddb2aa756fc44420390ae357daf31948) Thanks [@phryneas](https://github.com/phryneas)! - Fix an invariance type error in the `MockedResponse` type.
184
+
137
185
  ## 4.0.4
138
186
 
139
187
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"common.cjs","sources":["../../../../../src/cache/core/types/common.ts"],"sourcesContent":["import type { DocumentNode, FieldNode } from \"graphql\";\n\nimport type {\n AsStoreObject,\n DeepPartial,\n isReference,\n Reference,\n StoreObject,\n StoreValue,\n} from \"@apollo/client/utilities\";\n\nimport type { StorageType } from \"../../inmemory/policies.js\";\n\n// The Readonly<T> type only really works for object types, since it marks\n// all of the object's properties as readonly, but there are many cases when\n// a generic type parameter like TExisting might be a string or some other\n// primitive type, in which case we need to avoid wrapping it with Readonly.\n// SafeReadonly<string> collapses to just string, which makes string\n// assignable to SafeReadonly<any>, whereas string is not assignable to\n// Readonly<any>, somewhat surprisingly.\nexport type SafeReadonly<T> = T extends object ? Readonly<T> : T;\n\nexport type MissingTree =\n | string\n | {\n readonly [key: string]: MissingTree;\n };\n\nexport class MissingFieldError extends Error {\n constructor(\n public readonly message: string,\n public readonly path: MissingTree | Array<string | number>,\n public readonly query: DocumentNode,\n public readonly variables?: Record<string, any>\n ) {\n // 'Error' breaks prototype chain here\n super(message);\n this.name = \"MissingFieldError\";\n\n if (Array.isArray(this.path)) {\n this.missing = this.message;\n for (let i = this.path.length - 1; i >= 0; --i) {\n this.missing = { [this.path[i]]: this.missing };\n }\n } else {\n this.missing = this.path;\n }\n\n // We're not using `Object.setPrototypeOf` here as it isn't fully supported\n // on Android (see issue #3236).\n (this as any).__proto__ = MissingFieldError.prototype;\n }\n\n public readonly missing: MissingTree;\n}\n\nexport interface FieldSpecifier {\n typename?: string;\n fieldName: string;\n field?: FieldNode;\n args?: Record<string, any>;\n variables?: Record<string, any>;\n}\n\nexport interface ReadFieldOptions extends FieldSpecifier {\n from?: StoreObject | Reference;\n}\n\nexport interface ReadFieldFunction {\n <V = StoreValue>(options: ReadFieldOptions): SafeReadonly<V> | undefined;\n <V = StoreValue>(\n fieldName: string,\n from?: StoreObject | Reference\n ): SafeReadonly<V> | undefined;\n}\n\nexport type ToReferenceFunction = (\n objOrIdOrRef: StoreObject | string | Reference,\n mergeIntoStore?: boolean\n) => Reference | undefined;\n\nexport type CanReadFunction = (value: StoreValue) => boolean;\n\ndeclare const _deleteModifier: unique symbol;\nexport interface DeleteModifier {\n [_deleteModifier]: true;\n}\ndeclare const _invalidateModifier: unique symbol;\nexport interface InvalidateModifier {\n [_invalidateModifier]: true;\n}\ndeclare const _ignoreModifier: unique symbol;\nexport interface IgnoreModifier {\n [_ignoreModifier]: true;\n}\n\nexport type ModifierDetails = {\n DELETE: DeleteModifier;\n INVALIDATE: InvalidateModifier;\n fieldName: string;\n storeFieldName: string;\n readField: ReadFieldFunction;\n canRead: CanReadFunction;\n isReference: typeof isReference;\n toReference: ToReferenceFunction;\n storage: StorageType;\n};\n\nexport type Modifier<T> = (\n value: T,\n details: ModifierDetails\n) => DeepPartial<T> | DeleteModifier | InvalidateModifier | undefined;\n\ntype StoreObjectValueMaybeReference<StoreVal> =\n StoreVal extends Array<Record<string, any>> ?\n StoreVal extends Array<infer Item> ?\n [Item] extends [Record<string, any>] ?\n ReadonlyArray<AsStoreObject<Item> | Reference>\n : never\n : never\n : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference\n : StoreVal;\n\nexport type AllFieldsModifier<Entity extends Record<string, any>> = Modifier<\n Entity[keyof Entity] extends infer Value ?\n StoreObjectValueMaybeReference<Exclude<Value, undefined>>\n : never\n>;\n\nexport type Modifiers<T extends Record<string, any> = Record<string, unknown>> =\n Partial<{\n [FieldName in keyof T]: Modifier<\n StoreObjectValueMaybeReference<Exclude<T[FieldName], undefined>>\n >;\n }>;\n"],"names":[],"mappings":";;;AA4BA,CAAA,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAuC,CAAvC,CAAA,CAAA,CAAA,EAAA;IAEoB,CAApB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;IACoB,CAApB,CAAA,CAAA,CAAA;IACoB,CAApB,CAAA,CAAA,CAAA,CAAA;IACoB,CAApB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;IAJE,CAAF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACoB,CADpB,CAAA,CAAA,CAAA,CAAA,CAAA,CACmC,EACf,CAFpB,CAAA,CAAA,CAE8D,EAC1C,CAHpB,CAAA,CAAA,CAAA,CAGuC,EACnB,CAJpB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAImD,EAJnD;QAMI,CAAJ,EAAA,CAAA,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EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;QACK,CAAL,CAAA,CAAA,CAAiB,CAAC,CAAlB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAA8B,CAA9B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA+C,CAAC,CAAhD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyD;IACvD;IAEgB,CAAlB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyB;AACzB;AA1BA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"common.cjs","sources":["../../../../../src/cache/core/types/common.ts"],"sourcesContent":["import type { DocumentNode, FieldNode } from \"graphql\";\n\nimport type {\n AsStoreObject,\n DeepPartial,\n isReference,\n Reference,\n StoreObject,\n StoreValue,\n} from \"@apollo/client/utilities\";\n\nimport type { StorageType } from \"../../inmemory/policies.js\";\n\n// The Readonly<T> type only really works for object types, since it marks\n// all of the object's properties as readonly, but there are many cases when\n// a generic type parameter like TExisting might be a string or some other\n// primitive type, in which case we need to avoid wrapping it with Readonly.\n// SafeReadonly<string> collapses to just string, which makes string\n// assignable to SafeReadonly<any>, whereas string is not assignable to\n// Readonly<any>, somewhat surprisingly.\nexport type SafeReadonly<T> = T extends object ? Readonly<T> : T;\n\nexport type MissingTree =\n | string\n | {\n readonly [key: string]: MissingTree;\n };\n\nexport class MissingFieldError extends Error {\n constructor(\n public readonly message: string,\n public readonly path: MissingTree | Array<string | number>,\n public readonly query: DocumentNode,\n public readonly variables?: Record<string, any>\n ) {\n // 'Error' breaks prototype chain here\n super(message);\n this.name = \"MissingFieldError\";\n\n if (Array.isArray(this.path)) {\n this.missing = this.message;\n for (let i = this.path.length - 1; i >= 0; --i) {\n this.missing = { [this.path[i]]: this.missing };\n }\n } else {\n this.missing = this.path;\n }\n\n // We're not using `Object.setPrototypeOf` here as it isn't fully supported\n // on Android (see issue #3236).\n (this as any).__proto__ = MissingFieldError.prototype;\n }\n\n public readonly missing: MissingTree;\n}\n\nexport interface FieldSpecifier {\n typename?: string;\n fieldName: string;\n field?: FieldNode;\n args?: Record<string, any>;\n variables?: Record<string, any>;\n}\n\nexport interface ReadFieldOptions extends FieldSpecifier {\n from?: StoreObject | Reference;\n}\n\nexport interface ReadFieldFunction {\n <V = StoreValue>(options: ReadFieldOptions): SafeReadonly<V> | undefined;\n <V = StoreValue>(\n fieldName: string,\n from?: StoreObject | Reference\n ): SafeReadonly<V> | undefined;\n}\n\nexport type ToReferenceFunction = (\n objOrIdOrRef: StoreObject | string | Reference,\n mergeIntoStore?: boolean\n) => Reference | undefined;\n\nexport type CanReadFunction = (value: StoreValue) => boolean;\n\ndeclare const _deleteModifier: unique symbol;\nexport interface DeleteModifier {\n [_deleteModifier]: true;\n}\ndeclare const _invalidateModifier: unique symbol;\nexport interface InvalidateModifier {\n [_invalidateModifier]: true;\n}\ndeclare const _ignoreModifier: unique symbol;\nexport interface IgnoreModifier {\n [_ignoreModifier]: true;\n}\n\nexport type ModifierDetails = {\n DELETE: DeleteModifier;\n INVALIDATE: InvalidateModifier;\n fieldName: string;\n storeFieldName: string;\n readField: ReadFieldFunction;\n canRead: CanReadFunction;\n isReference: typeof isReference;\n toReference: ToReferenceFunction;\n storage: StorageType;\n};\n\nexport type Modifier<T> = (\n value: T,\n details: ModifierDetails\n) => DeepPartial<T> | DeleteModifier | InvalidateModifier | undefined;\n\ntype StoreObjectValueMaybeReference<StoreVal> =\n StoreVal extends ReadonlyArray<Record<string, any>> ?\n StoreVal extends ReadonlyArray<infer Item> ?\n [Item] extends [Record<string, any>] ?\n ReadonlyArray<AsStoreObject<Item> | Reference>\n : never\n : never\n : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference\n : StoreVal;\n\nexport type AllFieldsModifier<Entity extends Record<string, any>> = Modifier<\n Entity[keyof Entity] extends infer Value ?\n StoreObjectValueMaybeReference<Exclude<Value, undefined>>\n : never\n>;\n\nexport type Modifiers<T extends Record<string, any> = Record<string, unknown>> =\n Partial<{\n [FieldName in keyof T]: Modifier<\n StoreObjectValueMaybeReference<Exclude<T[FieldName], undefined>>\n >;\n }>;\n"],"names":[],"mappings":";;;AA4BA,CAAA,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAuC,CAAvC,CAAA,CAAA,CAAA,EAAA;IAEoB,CAApB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;IACoB,CAApB,CAAA,CAAA,CAAA;IACoB,CAApB,CAAA,CAAA,CAAA,CAAA;IACoB,CAApB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;IAJE,CAAF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACoB,CADpB,CAAA,CAAA,CAAA,CAAA,CAAA,CACmC,EACf,CAFpB,CAAA,CAAA,CAE8D,EAC1C,CAHpB,CAAA,CAAA,CAAA,CAGuC,EACnB,CAJpB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAImD,EAJnD;QAMI,CAAJ,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,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,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAA8B,CAA9B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA+C,CAAC,CAAhD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyD;IACvD;IAEgB,CAAlB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyB;AACzB;AA1BA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;"}
@@ -53,7 +53,7 @@ export type ModifierDetails = {
53
53
  storage: StorageType;
54
54
  };
55
55
  export type Modifier<T> = (value: T, details: ModifierDetails) => DeepPartial<T> | DeleteModifier | InvalidateModifier | undefined;
56
- type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends Array<Record<string, any>> ? StoreVal extends Array<infer Item> ? [
56
+ type StoreObjectValueMaybeReference<StoreVal> = StoreVal extends ReadonlyArray<Record<string, any>> ? StoreVal extends ReadonlyArray<infer Item> ? [
57
57
  Item
58
58
  ] extends [Record<string, any>] ? ReadonlyArray<AsStoreObject<Item> | Reference> : never : never : StoreVal extends Record<string, any> ? AsStoreObject<StoreVal> | Reference : StoreVal;
59
59
  export type AllFieldsModifier<Entity extends Record<string, any>> = Modifier<Entity[keyof Entity] extends infer Value ? StoreObjectValueMaybeReference<Exclude<Value, undefined>> : never>;
@@ -83,7 +83,9 @@ class EntityStore {
83
83
  if (!incoming)
84
84
  return;
85
85
  (0, invariant_1.invariant)(typeof dataId === "string", 98);
86
- const merged = new internal_1.DeepMerger(storeObjectReconciler).merge(existing, incoming);
86
+ const merged = new internal_1.DeepMerger({
87
+ reconciler: storeObjectReconciler,
88
+ }).merge(existing, incoming);
87
89
  // Even if merged === existing, existing may have come from a lower
88
90
  // layer, so we always need to set this.data[dataId] on this level.
89
91
  this.data[dataId] = merged;