@apollo/client 3.8.7 → 3.8.8

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 (609) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +14 -0
  3. package/CHANGELOG.md +3357 -0
  4. package/apollo-client.cjs +314 -316
  5. package/apollo-client.cjs.map +1 -1
  6. package/apollo-client.min.cjs +1 -1
  7. package/cache/cache.cjs +133 -152
  8. package/cache/cache.cjs.map +1 -1
  9. package/cache/cache.cjs.native.js +133 -152
  10. package/cache/core/cache.d.ts +10 -0
  11. package/cache/core/cache.js +17 -5
  12. package/cache/core/cache.js.map +1 -1
  13. package/cache/core/types/Cache.d.ts +1 -1
  14. package/cache/core/types/Cache.js.map +1 -1
  15. package/cache/core/types/DataProxy.d.ts +92 -0
  16. package/cache/core/types/common.js +4 -1
  17. package/cache/core/types/common.js.map +1 -1
  18. package/cache/inmemory/entityStore.d.ts +1 -1
  19. package/cache/inmemory/entityStore.js +190 -29
  20. package/cache/inmemory/entityStore.js.map +1 -1
  21. package/cache/inmemory/fixPolyfills.js +9 -0
  22. package/cache/inmemory/fixPolyfills.js.map +1 -1
  23. package/cache/inmemory/fixPolyfills.native.js +12 -0
  24. package/cache/inmemory/fixPolyfills.native.js.map +1 -1
  25. package/cache/inmemory/fragmentRegistry.js +23 -12
  26. package/cache/inmemory/fragmentRegistry.js.map +1 -1
  27. package/cache/inmemory/helpers.js +20 -11
  28. package/cache/inmemory/helpers.js.map +1 -1
  29. package/cache/inmemory/inMemoryCache.js +161 -8
  30. package/cache/inmemory/inMemoryCache.js.map +1 -1
  31. package/cache/inmemory/key-extractor.js +72 -4
  32. package/cache/inmemory/key-extractor.js.map +1 -1
  33. package/cache/inmemory/object-canon.js +91 -3
  34. package/cache/inmemory/object-canon.js.map +1 -1
  35. package/cache/inmemory/policies.js +193 -43
  36. package/cache/inmemory/policies.js.map +1 -1
  37. package/cache/inmemory/reactiveVars.js +20 -2
  38. package/cache/inmemory/reactiveVars.js.map +1 -1
  39. package/cache/inmemory/readFromStore.d.ts +4 -0
  40. package/cache/inmemory/readFromStore.js +54 -9
  41. package/cache/inmemory/readFromStore.js.map +1 -1
  42. package/cache/inmemory/types.d.ts +28 -0
  43. package/cache/inmemory/types.js.map +1 -1
  44. package/cache/inmemory/writeToStore.js +152 -25
  45. package/cache/inmemory/writeToStore.js.map +1 -1
  46. package/config/jest/setup.js +2 -0
  47. package/config/jest/setup.js.map +1 -1
  48. package/core/ApolloClient.d.ts +264 -3
  49. package/core/ApolloClient.js +235 -7
  50. package/core/ApolloClient.js.map +1 -1
  51. package/core/LocalState.d.ts +4 -6
  52. package/core/LocalState.js +56 -18
  53. package/core/LocalState.js.map +1 -1
  54. package/core/ObservableQuery.d.ts +25 -0
  55. package/core/ObservableQuery.js +239 -30
  56. package/core/ObservableQuery.js.map +1 -1
  57. package/core/QueryInfo.d.ts +3 -3
  58. package/core/QueryInfo.js +116 -13
  59. package/core/QueryInfo.js.map +1 -1
  60. package/core/QueryManager.d.ts +4 -0
  61. package/core/QueryManager.js +229 -33
  62. package/core/QueryManager.js.map +1 -1
  63. package/core/core.cjs +112 -103
  64. package/core/core.cjs.map +1 -1
  65. package/core/core.cjs.native.js +112 -103
  66. package/core/equalByQuery.js +20 -1
  67. package/core/equalByQuery.js.map +1 -1
  68. package/core/index.d.ts +1 -1
  69. package/core/index.js +19 -0
  70. package/core/index.js.map +1 -1
  71. package/core/networkStatus.d.ts +39 -0
  72. package/core/networkStatus.js +39 -0
  73. package/core/networkStatus.js.map +1 -1
  74. package/core/types.d.ts +9 -0
  75. package/core/types.js.map +1 -1
  76. package/core/watchQueryOptions.d.ts +225 -1
  77. package/core/watchQueryOptions.js.map +1 -1
  78. package/dev/dev.cjs +5 -111
  79. package/dev/dev.cjs.map +1 -1
  80. package/dev/dev.cjs.native.js +5 -111
  81. package/dev/loadErrorMessageHandler.js.map +1 -1
  82. package/errors/errors.cjs +1 -1
  83. package/errors/errors.cjs.map +1 -1
  84. package/errors/errors.cjs.native.js +1 -1
  85. package/errors/index.js +14 -1
  86. package/errors/index.js.map +1 -1
  87. package/invariantErrorCodes.js +1 -0
  88. package/link/batch/batch.cjs +2 -2
  89. package/link/batch/batch.cjs.map +1 -1
  90. package/link/batch/batch.cjs.native.js +2 -2
  91. package/link/batch/batchLink.d.ts +21 -0
  92. package/link/batch/batchLink.js +2 -1
  93. package/link/batch/batchLink.js.map +1 -1
  94. package/link/batch/batching.js +24 -1
  95. package/link/batch/batching.js.map +1 -1
  96. package/link/batch-http/batch-http.cjs +3 -2
  97. package/link/batch-http/batch-http.cjs.map +1 -1
  98. package/link/batch-http/batch-http.cjs.native.js +3 -2
  99. package/link/batch-http/batchHttpLink.d.ts +4 -0
  100. package/link/batch-http/batchHttpLink.js +53 -2
  101. package/link/batch-http/batchHttpLink.js.map +1 -1
  102. package/link/context/context.cjs.map +1 -1
  103. package/link/context/index.js +1 -0
  104. package/link/context/index.js.map +1 -1
  105. package/link/core/ApolloLink.js +12 -5
  106. package/link/core/ApolloLink.js.map +1 -1
  107. package/link/core/core.cjs +5 -5
  108. package/link/core/core.cjs.map +1 -1
  109. package/link/core/core.cjs.native.js +5 -5
  110. package/link/error/error.cjs +1 -1
  111. package/link/error/error.cjs.map +1 -1
  112. package/link/error/error.cjs.native.js +1 -1
  113. package/link/error/index.d.ts +3 -0
  114. package/link/error/index.js +4 -1
  115. package/link/error/index.js.map +1 -1
  116. package/link/http/HttpLink.d.ts +0 -2
  117. package/link/http/HttpLink.js +1 -1
  118. package/link/http/HttpLink.js.map +1 -1
  119. package/link/http/checkFetcher.js.map +1 -1
  120. package/link/http/createHttpLink.js +23 -1
  121. package/link/http/createHttpLink.js.map +1 -1
  122. package/link/http/createSignalIfSupported.d.ts +5 -0
  123. package/link/http/createSignalIfSupported.js +5 -0
  124. package/link/http/createSignalIfSupported.js.map +1 -1
  125. package/link/http/http.cjs +14 -12
  126. package/link/http/http.cjs.map +1 -1
  127. package/link/http/http.cjs.native.js +14 -12
  128. package/link/http/index.js +2 -1
  129. package/link/http/index.js.map +1 -1
  130. package/link/http/iterators/async.d.ts +4 -0
  131. package/link/http/iterators/async.js +4 -0
  132. package/link/http/iterators/async.js.map +1 -1
  133. package/link/http/iterators/nodeStream.d.ts +4 -0
  134. package/link/http/iterators/nodeStream.js +4 -0
  135. package/link/http/iterators/nodeStream.js.map +1 -1
  136. package/link/http/iterators/promise.d.ts +4 -0
  137. package/link/http/iterators/promise.js +4 -0
  138. package/link/http/iterators/promise.js.map +1 -1
  139. package/link/http/iterators/reader.d.ts +4 -0
  140. package/link/http/iterators/reader.js +4 -0
  141. package/link/http/iterators/reader.js.map +1 -1
  142. package/link/http/parseAndCheckHttpResponse.js +51 -10
  143. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  144. package/link/http/responseIterator.d.ts +4 -0
  145. package/link/http/responseIterator.js +6 -0
  146. package/link/http/responseIterator.js.map +1 -1
  147. package/link/http/rewriteURIForGET.d.ts +1 -1
  148. package/link/http/rewriteURIForGET.js +10 -0
  149. package/link/http/rewriteURIForGET.js.map +1 -1
  150. package/link/http/selectHttpOptionsAndBody.d.ts +45 -0
  151. package/link/http/selectHttpOptionsAndBody.js +23 -0
  152. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  153. package/link/http/selectURI.js.map +1 -1
  154. package/link/http/serializeFetchParameter.js.map +1 -1
  155. package/link/persisted-queries/index.js +34 -4
  156. package/link/persisted-queries/index.js.map +1 -1
  157. package/link/persisted-queries/persisted-queries.cjs +4 -4
  158. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  159. package/link/persisted-queries/persisted-queries.cjs.native.js +4 -4
  160. package/link/remove-typename/remove-typename.cjs +12 -9
  161. package/link/remove-typename/remove-typename.cjs.map +1 -1
  162. package/link/remove-typename/remove-typename.cjs.native.js +12 -9
  163. package/link/remove-typename/removeTypenameFromVariables.js +12 -9
  164. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  165. package/link/retry/delayFunction.d.ts +29 -0
  166. package/link/retry/delayFunction.js +6 -0
  167. package/link/retry/delayFunction.js.map +1 -1
  168. package/link/retry/retry.cjs +5 -5
  169. package/link/retry/retry.cjs.map +1 -1
  170. package/link/retry/retry.cjs.native.js +5 -5
  171. package/link/retry/retryFunction.d.ts +20 -0
  172. package/link/retry/retryLink.d.ts +6 -0
  173. package/link/retry/retryLink.js +31 -6
  174. package/link/retry/retryLink.js.map +1 -1
  175. package/link/schema/index.d.ts +13 -0
  176. package/link/schema/index.js +3 -3
  177. package/link/schema/index.js.map +1 -1
  178. package/link/schema/schema.cjs +3 -3
  179. package/link/schema/schema.cjs.map +1 -1
  180. package/link/schema/schema.cjs.native.js +3 -3
  181. package/link/subscriptions/index.js +35 -2
  182. package/link/subscriptions/index.js.map +1 -1
  183. package/link/subscriptions/subscriptions.cjs +3 -2
  184. package/link/subscriptions/subscriptions.cjs.map +1 -1
  185. package/link/subscriptions/subscriptions.cjs.native.js +3 -2
  186. package/link/utils/createOperation.js.map +1 -1
  187. package/link/utils/filterOperationVariables.js +4 -0
  188. package/link/utils/filterOperationVariables.js.map +1 -1
  189. package/link/utils/toPromise.js.map +1 -1
  190. package/link/utils/transformOperation.js +3 -2
  191. package/link/utils/transformOperation.js.map +1 -1
  192. package/link/utils/utils.cjs +2 -2
  193. package/link/utils/utils.cjs.map +1 -1
  194. package/link/utils/utils.cjs.native.js +2 -2
  195. package/link/utils/validateOperation.js.map +1 -1
  196. package/link/ws/index.d.ts +12 -0
  197. package/link/ws/index.js +1 -1
  198. package/link/ws/index.js.map +1 -1
  199. package/link/ws/ws.cjs +1 -1
  200. package/link/ws/ws.cjs.map +1 -1
  201. package/link/ws/ws.cjs.native.js +1 -1
  202. package/package.json +49 -38
  203. package/react/cache/QueryReference.d.ts +6 -1
  204. package/react/cache/QueryReference.js +26 -1
  205. package/react/cache/QueryReference.js.map +1 -1
  206. package/react/cache/SuspenseCache.d.ts +10 -0
  207. package/react/cache/SuspenseCache.js +1 -1
  208. package/react/cache/SuspenseCache.js.map +1 -1
  209. package/react/cache/getSuspenseCache.js.map +1 -1
  210. package/react/context/ApolloContext.d.ts +5 -0
  211. package/react/context/ApolloContext.js +10 -3
  212. package/react/context/ApolloContext.js.map +1 -1
  213. package/react/context/context.cjs +1 -3
  214. package/react/context/context.cjs.map +1 -1
  215. package/react/context/context.cjs.native.js +1 -3
  216. package/react/hoc/graphql.js.map +1 -1
  217. package/react/hoc/hoc-utils.js +3 -1
  218. package/react/hoc/hoc-utils.js.map +1 -1
  219. package/react/hoc/hoc.cjs +9 -17
  220. package/react/hoc/hoc.cjs.map +1 -1
  221. package/react/hoc/hoc.cjs.native.js +9 -17
  222. package/react/hoc/mutation-hoc.js +9 -4
  223. package/react/hoc/mutation-hoc.js.map +1 -1
  224. package/react/hoc/query-hoc.js +10 -4
  225. package/react/hoc/query-hoc.js.map +1 -1
  226. package/react/hoc/subscription-hoc.js +10 -4
  227. package/react/hoc/subscription-hoc.js.map +1 -1
  228. package/react/hoc/withApollo.js +3 -4
  229. package/react/hoc/withApollo.js.map +1 -1
  230. package/react/hooks/hooks.cjs +30 -22
  231. package/react/hooks/hooks.cjs.map +1 -1
  232. package/react/hooks/hooks.cjs.native.js +30 -22
  233. package/react/hooks/internal/__use.js +5 -0
  234. package/react/hooks/internal/__use.js.map +1 -1
  235. package/react/hooks/internal/index.js +1 -0
  236. package/react/hooks/internal/index.js.map +1 -1
  237. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  238. package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -3
  239. package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
  240. package/react/hooks/useBackgroundQuery.js +6 -0
  241. package/react/hooks/useBackgroundQuery.js.map +1 -1
  242. package/react/hooks/useFragment.js +4 -3
  243. package/react/hooks/useFragment.js.map +1 -1
  244. package/react/hooks/useLazyQuery.js +13 -4
  245. package/react/hooks/useLazyQuery.js.map +1 -1
  246. package/react/hooks/useMutation.js +8 -3
  247. package/react/hooks/useMutation.js.map +1 -1
  248. package/react/hooks/useQuery.d.ts +11 -0
  249. package/react/hooks/useQuery.js +137 -5
  250. package/react/hooks/useQuery.js.map +1 -1
  251. package/react/hooks/useReactiveVar.js +5 -0
  252. package/react/hooks/useReactiveVar.js.map +1 -1
  253. package/react/hooks/useReadQuery.d.ts +19 -0
  254. package/react/hooks/useReadQuery.js.map +1 -1
  255. package/react/hooks/useSubscription.js +5 -0
  256. package/react/hooks/useSubscription.js.map +1 -1
  257. package/react/hooks/useSuspenseQuery.js +11 -5
  258. package/react/hooks/useSuspenseQuery.js.map +1 -1
  259. package/react/hooks/useSyncExternalStore.js +53 -1
  260. package/react/hooks/useSyncExternalStore.js.map +1 -1
  261. package/react/parser/index.js +4 -5
  262. package/react/parser/index.js.map +1 -1
  263. package/react/parser/parser.cjs +2 -4
  264. package/react/parser/parser.cjs.map +1 -1
  265. package/react/parser/parser.cjs.native.js +2 -4
  266. package/react/ssr/RenderPromises.js +21 -1
  267. package/react/ssr/RenderPromises.js.map +1 -1
  268. package/react/ssr/getDataFromTree.js +18 -3
  269. package/react/ssr/getDataFromTree.js.map +1 -1
  270. package/react/ssr/ssr.cjs +6 -4
  271. package/react/ssr/ssr.cjs.map +1 -1
  272. package/react/ssr/ssr.cjs.native.js +6 -4
  273. package/react/types/types.d.ts +66 -0
  274. package/testing/core/core.cjs +14 -11
  275. package/testing/core/core.cjs.map +1 -1
  276. package/testing/core/core.cjs.native.js +14 -11
  277. package/testing/core/itAsync.d.ts +1 -1
  278. package/testing/core/itAsync.js.map +1 -1
  279. package/testing/core/mocking/mockFetch.d.ts +2 -2
  280. package/testing/core/mocking/mockFetch.js +8 -4
  281. package/testing/core/mocking/mockFetch.js.map +1 -1
  282. package/testing/core/mocking/mockLink.js +17 -7
  283. package/testing/core/mocking/mockLink.js.map +1 -1
  284. package/testing/core/mocking/mockQueryManager.js +2 -0
  285. package/testing/core/mocking/mockQueryManager.js.map +1 -1
  286. package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
  287. package/testing/core/mocking/mockSubscriptionLink.js +1 -1
  288. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  289. package/testing/core/mocking/mockWatchQuery.js +1 -1
  290. package/testing/core/mocking/mockWatchQuery.js.map +1 -1
  291. package/testing/core/observableToPromise.d.ts +17 -3
  292. package/testing/core/observableToPromise.js +5 -0
  293. package/testing/core/observableToPromise.js.map +1 -1
  294. package/testing/core/subscribeAndCount.js +3 -0
  295. package/testing/core/subscribeAndCount.js.map +1 -1
  296. package/testing/core/wait.js +2 -2
  297. package/testing/core/wait.js.map +1 -1
  298. package/testing/core/withConsoleSpy.d.ts +3 -0
  299. package/testing/core/withConsoleSpy.js +7 -1
  300. package/testing/core/withConsoleSpy.js.map +1 -1
  301. package/testing/core/wrap.js +2 -0
  302. package/testing/core/wrap.js.map +1 -1
  303. package/testing/internal/ObservableStream.js +14 -14
  304. package/testing/internal/ObservableStream.js.map +1 -1
  305. package/testing/internal/disposables/spyOnConsole.d.ts +1 -0
  306. package/testing/internal/disposables/spyOnConsole.js +2 -0
  307. package/testing/internal/disposables/spyOnConsole.js.map +1 -1
  308. package/testing/internal/disposables/withCleanup.d.ts +1 -0
  309. package/testing/internal/disposables/withCleanup.js +3 -0
  310. package/testing/internal/disposables/withCleanup.js.map +1 -1
  311. package/testing/internal/profile/Render.d.ts +28 -0
  312. package/testing/internal/profile/Render.js +12 -1
  313. package/testing/internal/profile/Render.js.map +1 -1
  314. package/testing/internal/profile/profile.d.ts +44 -7
  315. package/testing/internal/profile/profile.js +63 -51
  316. package/testing/internal/profile/profile.js.map +1 -1
  317. package/testing/internal/profile/traces.d.ts +4 -0
  318. package/testing/internal/profile/traces.js +9 -5
  319. package/testing/internal/profile/traces.js.map +1 -1
  320. package/testing/matchers/ProfiledComponent.js +27 -22
  321. package/testing/matchers/ProfiledComponent.js.map +1 -1
  322. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
  323. package/testing/matchers/toMatchDocument.js.map +1 -1
  324. package/testing/react/MockedProvider.d.ts +4 -0
  325. package/testing/react/MockedProvider.js +6 -2
  326. package/testing/react/MockedProvider.js.map +1 -1
  327. package/testing/testing.cjs +4 -2
  328. package/testing/testing.cjs.map +1 -1
  329. package/testing/testing.cjs.native.js +4 -2
  330. package/utilities/common/arrays.js +1 -0
  331. package/utilities/common/arrays.js.map +1 -1
  332. package/utilities/common/canUse.js +16 -1
  333. package/utilities/common/canUse.js.map +1 -1
  334. package/utilities/common/cloneDeep.d.ts +3 -0
  335. package/utilities/common/cloneDeep.js +5 -0
  336. package/utilities/common/cloneDeep.js.map +1 -1
  337. package/utilities/common/compact.d.ts +4 -0
  338. package/utilities/common/compact.js +4 -0
  339. package/utilities/common/compact.js.map +1 -1
  340. package/utilities/common/errorHandling.js +1 -3
  341. package/utilities/common/errorHandling.js.map +1 -1
  342. package/utilities/common/incrementalResult.js +3 -0
  343. package/utilities/common/incrementalResult.js.map +1 -1
  344. package/utilities/common/makeUniqueId.js +2 -0
  345. package/utilities/common/makeUniqueId.js.map +1 -1
  346. package/utilities/common/maybeDeepFreeze.js +3 -0
  347. package/utilities/common/maybeDeepFreeze.js.map +1 -1
  348. package/utilities/common/mergeDeep.js +12 -1
  349. package/utilities/common/mergeDeep.js.map +1 -1
  350. package/utilities/common/mergeOptions.d.ts +1 -1
  351. package/utilities/common/mergeOptions.js.map +1 -1
  352. package/utilities/common/omitDeep.js.map +1 -1
  353. package/utilities/globals/global.js +7 -1
  354. package/utilities/globals/global.js.map +1 -1
  355. package/utilities/globals/globals.cjs +4 -5
  356. package/utilities/globals/globals.cjs.map +1 -1
  357. package/utilities/globals/globals.cjs.native.js +4 -5
  358. package/utilities/globals/index.d.ts +4 -0
  359. package/utilities/globals/index.js +7 -0
  360. package/utilities/globals/index.js.map +1 -1
  361. package/utilities/globals/invariantWrappers.d.ts +40 -0
  362. package/utilities/globals/invariantWrappers.js +11 -3
  363. package/utilities/globals/invariantWrappers.js.map +1 -1
  364. package/utilities/globals/maybe.js.map +1 -1
  365. package/utilities/graphql/DocumentTransform.js +19 -6
  366. package/utilities/graphql/DocumentTransform.js.map +1 -1
  367. package/utilities/graphql/directives.js +3 -0
  368. package/utilities/graphql/directives.js.map +1 -1
  369. package/utilities/graphql/fragments.d.ts +25 -0
  370. package/utilities/graphql/fragments.js +36 -0
  371. package/utilities/graphql/fragments.js.map +1 -1
  372. package/utilities/graphql/getFromAST.d.ts +5 -0
  373. package/utilities/graphql/getFromAST.js +9 -0
  374. package/utilities/graphql/getFromAST.js.map +1 -1
  375. package/utilities/graphql/print.js.map +1 -1
  376. package/utilities/graphql/storeUtils.d.ts +14 -0
  377. package/utilities/graphql/storeUtils.js +7 -2
  378. package/utilities/graphql/storeUtils.js.map +1 -1
  379. package/utilities/graphql/transform.js +106 -7
  380. package/utilities/graphql/transform.js.map +1 -1
  381. package/utilities/observables/Concast.d.ts +1 -1
  382. package/utilities/observables/Concast.js +84 -1
  383. package/utilities/observables/Concast.js.map +1 -1
  384. package/utilities/observables/Observable.js +6 -0
  385. package/utilities/observables/Observable.js.map +1 -1
  386. package/utilities/observables/asyncMap.js +12 -3
  387. package/utilities/observables/asyncMap.js.map +1 -1
  388. package/utilities/observables/iteration.js +3 -0
  389. package/utilities/observables/iteration.js.map +1 -1
  390. package/utilities/observables/subclassing.js +14 -0
  391. package/utilities/observables/subclassing.js.map +1 -1
  392. package/utilities/policies/pagination.js +47 -3
  393. package/utilities/policies/pagination.js.map +1 -1
  394. package/utilities/promises/decoration.js +1 -0
  395. package/utilities/promises/decoration.js.map +1 -1
  396. package/utilities/types/DeepOmit.js.map +1 -1
  397. package/utilities/types/DeepPartial.d.ts +1 -1
  398. package/utilities/types/DeepPartial.js +4 -0
  399. package/utilities/types/DeepPartial.js.map +1 -1
  400. package/utilities/types/IsStrictlyAny.js.map +1 -1
  401. package/utilities/types/TODO.d.ts +3 -0
  402. package/utilities/types/TODO.js +2 -0
  403. package/utilities/types/TODO.js.map +1 -0
  404. package/utilities/utilities.cjs +31 -27
  405. package/utilities/utilities.cjs.map +1 -1
  406. package/utilities/utilities.cjs.native.js +31 -27
  407. package/version.js +1 -1
  408. package/cache/core/cache.d.ts.map +0 -1
  409. package/cache/core/types/Cache.d.ts.map +0 -1
  410. package/cache/core/types/DataProxy.d.ts.map +0 -1
  411. package/cache/core/types/common.d.ts.map +0 -1
  412. package/cache/index.d.ts.map +0 -1
  413. package/cache/inmemory/entityStore.d.ts.map +0 -1
  414. package/cache/inmemory/fixPolyfills.d.ts.map +0 -1
  415. package/cache/inmemory/fixPolyfills.native.d.ts.map +0 -1
  416. package/cache/inmemory/fragmentRegistry.d.ts.map +0 -1
  417. package/cache/inmemory/helpers.d.ts.map +0 -1
  418. package/cache/inmemory/inMemoryCache.d.ts.map +0 -1
  419. package/cache/inmemory/key-extractor.d.ts.map +0 -1
  420. package/cache/inmemory/object-canon.d.ts.map +0 -1
  421. package/cache/inmemory/policies.d.ts.map +0 -1
  422. package/cache/inmemory/reactiveVars.d.ts.map +0 -1
  423. package/cache/inmemory/readFromStore.d.ts.map +0 -1
  424. package/cache/inmemory/types.d.ts.map +0 -1
  425. package/cache/inmemory/writeToStore.d.ts.map +0 -1
  426. package/config/jest/setup.d.ts.map +0 -1
  427. package/core/ApolloClient.d.ts.map +0 -1
  428. package/core/LocalState.d.ts.map +0 -1
  429. package/core/ObservableQuery.d.ts.map +0 -1
  430. package/core/QueryInfo.d.ts.map +0 -1
  431. package/core/QueryManager.d.ts.map +0 -1
  432. package/core/equalByQuery.d.ts.map +0 -1
  433. package/core/index.d.ts.map +0 -1
  434. package/core/networkStatus.d.ts.map +0 -1
  435. package/core/types.d.ts.map +0 -1
  436. package/core/watchQueryOptions.d.ts.map +0 -1
  437. package/dev/index.d.ts.map +0 -1
  438. package/dev/loadDevMessages.d.ts.map +0 -1
  439. package/dev/loadErrorMessageHandler.d.ts.map +0 -1
  440. package/dev/loadErrorMessages.d.ts.map +0 -1
  441. package/errors/index.d.ts.map +0 -1
  442. package/index.d.ts.map +0 -1
  443. package/invariantErrorCodes.d.ts.map +0 -1
  444. package/link/batch/batchLink.d.ts.map +0 -1
  445. package/link/batch/batching.d.ts.map +0 -1
  446. package/link/batch/index.d.ts.map +0 -1
  447. package/link/batch-http/batchHttpLink.d.ts.map +0 -1
  448. package/link/batch-http/index.d.ts.map +0 -1
  449. package/link/context/index.d.ts.map +0 -1
  450. package/link/core/ApolloLink.d.ts.map +0 -1
  451. package/link/core/concat.d.ts.map +0 -1
  452. package/link/core/empty.d.ts.map +0 -1
  453. package/link/core/execute.d.ts.map +0 -1
  454. package/link/core/from.d.ts.map +0 -1
  455. package/link/core/index.d.ts.map +0 -1
  456. package/link/core/split.d.ts.map +0 -1
  457. package/link/core/types.d.ts.map +0 -1
  458. package/link/error/index.d.ts.map +0 -1
  459. package/link/http/HttpLink.d.ts.map +0 -1
  460. package/link/http/checkFetcher.d.ts.map +0 -1
  461. package/link/http/createHttpLink.d.ts.map +0 -1
  462. package/link/http/createSignalIfSupported.d.ts.map +0 -1
  463. package/link/http/index.d.ts.map +0 -1
  464. package/link/http/iterators/async.d.ts.map +0 -1
  465. package/link/http/iterators/nodeStream.d.ts.map +0 -1
  466. package/link/http/iterators/promise.d.ts.map +0 -1
  467. package/link/http/iterators/reader.d.ts.map +0 -1
  468. package/link/http/parseAndCheckHttpResponse.d.ts.map +0 -1
  469. package/link/http/responseIterator.d.ts.map +0 -1
  470. package/link/http/rewriteURIForGET.d.ts.map +0 -1
  471. package/link/http/selectHttpOptionsAndBody.d.ts.map +0 -1
  472. package/link/http/selectURI.d.ts.map +0 -1
  473. package/link/http/serializeFetchParameter.d.ts.map +0 -1
  474. package/link/persisted-queries/index.d.ts.map +0 -1
  475. package/link/remove-typename/index.d.ts.map +0 -1
  476. package/link/remove-typename/removeTypenameFromVariables.d.ts.map +0 -1
  477. package/link/retry/delayFunction.d.ts.map +0 -1
  478. package/link/retry/index.d.ts.map +0 -1
  479. package/link/retry/retryFunction.d.ts.map +0 -1
  480. package/link/retry/retryLink.d.ts.map +0 -1
  481. package/link/schema/index.d.ts.map +0 -1
  482. package/link/subscriptions/index.d.ts.map +0 -1
  483. package/link/utils/createOperation.d.ts.map +0 -1
  484. package/link/utils/filterOperationVariables.d.ts.map +0 -1
  485. package/link/utils/fromError.d.ts.map +0 -1
  486. package/link/utils/fromPromise.d.ts.map +0 -1
  487. package/link/utils/index.d.ts.map +0 -1
  488. package/link/utils/throwServerError.d.ts.map +0 -1
  489. package/link/utils/toPromise.d.ts.map +0 -1
  490. package/link/utils/transformOperation.d.ts.map +0 -1
  491. package/link/utils/validateOperation.d.ts.map +0 -1
  492. package/link/ws/index.d.ts.map +0 -1
  493. package/react/cache/QueryReference.d.ts.map +0 -1
  494. package/react/cache/SuspenseCache.d.ts.map +0 -1
  495. package/react/cache/getSuspenseCache.d.ts.map +0 -1
  496. package/react/cache/index.d.ts.map +0 -1
  497. package/react/cache/types.d.ts.map +0 -1
  498. package/react/components/Mutation.d.ts.map +0 -1
  499. package/react/components/Query.d.ts.map +0 -1
  500. package/react/components/Subscription.d.ts.map +0 -1
  501. package/react/components/index.d.ts.map +0 -1
  502. package/react/components/types.d.ts.map +0 -1
  503. package/react/context/ApolloConsumer.d.ts.map +0 -1
  504. package/react/context/ApolloContext.d.ts.map +0 -1
  505. package/react/context/ApolloProvider.d.ts.map +0 -1
  506. package/react/context/index.d.ts.map +0 -1
  507. package/react/hoc/graphql.d.ts.map +0 -1
  508. package/react/hoc/hoc-utils.d.ts.map +0 -1
  509. package/react/hoc/index.d.ts.map +0 -1
  510. package/react/hoc/mutation-hoc.d.ts.map +0 -1
  511. package/react/hoc/query-hoc.d.ts.map +0 -1
  512. package/react/hoc/subscription-hoc.d.ts.map +0 -1
  513. package/react/hoc/types.d.ts.map +0 -1
  514. package/react/hoc/withApollo.d.ts.map +0 -1
  515. package/react/hooks/constants.d.ts.map +0 -1
  516. package/react/hooks/index.d.ts.map +0 -1
  517. package/react/hooks/internal/__use.d.ts.map +0 -1
  518. package/react/hooks/internal/index.d.ts.map +0 -1
  519. package/react/hooks/internal/useDeepMemo.d.ts.map +0 -1
  520. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +0 -1
  521. package/react/hooks/useApolloClient.d.ts.map +0 -1
  522. package/react/hooks/useBackgroundQuery.d.ts.map +0 -1
  523. package/react/hooks/useFragment.d.ts.map +0 -1
  524. package/react/hooks/useLazyQuery.d.ts.map +0 -1
  525. package/react/hooks/useMutation.d.ts.map +0 -1
  526. package/react/hooks/useQuery.d.ts.map +0 -1
  527. package/react/hooks/useReactiveVar.d.ts.map +0 -1
  528. package/react/hooks/useReadQuery.d.ts.map +0 -1
  529. package/react/hooks/useSubscription.d.ts.map +0 -1
  530. package/react/hooks/useSuspenseQuery.d.ts.map +0 -1
  531. package/react/hooks/useSyncExternalStore.d.ts.map +0 -1
  532. package/react/index.d.ts.map +0 -1
  533. package/react/parser/index.d.ts.map +0 -1
  534. package/react/ssr/RenderPromises.d.ts.map +0 -1
  535. package/react/ssr/getDataFromTree.d.ts.map +0 -1
  536. package/react/ssr/index.d.ts.map +0 -1
  537. package/react/ssr/renderToStringWithData.d.ts.map +0 -1
  538. package/react/types/types.d.ts.map +0 -1
  539. package/testing/core/index.d.ts.map +0 -1
  540. package/testing/core/itAsync.d.ts.map +0 -1
  541. package/testing/core/mocking/mockClient.d.ts.map +0 -1
  542. package/testing/core/mocking/mockFetch.d.ts.map +0 -1
  543. package/testing/core/mocking/mockLink.d.ts.map +0 -1
  544. package/testing/core/mocking/mockQueryManager.d.ts.map +0 -1
  545. package/testing/core/mocking/mockSubscriptionLink.d.ts.map +0 -1
  546. package/testing/core/mocking/mockWatchQuery.d.ts.map +0 -1
  547. package/testing/core/observableToPromise.d.ts.map +0 -1
  548. package/testing/core/subscribeAndCount.d.ts.map +0 -1
  549. package/testing/core/wait.d.ts.map +0 -1
  550. package/testing/core/withConsoleSpy.d.ts.map +0 -1
  551. package/testing/core/wrap.d.ts.map +0 -1
  552. package/testing/index.d.ts.map +0 -1
  553. package/testing/internal/ObservableStream.d.ts.map +0 -1
  554. package/testing/internal/disposables/index.d.ts.map +0 -1
  555. package/testing/internal/disposables/spyOnConsole.d.ts.map +0 -1
  556. package/testing/internal/disposables/withCleanup.d.ts.map +0 -1
  557. package/testing/internal/index.d.ts.map +0 -1
  558. package/testing/internal/profile/Render.d.ts.map +0 -1
  559. package/testing/internal/profile/index.d.ts.map +0 -1
  560. package/testing/internal/profile/profile.d.ts.map +0 -1
  561. package/testing/internal/profile/traces.d.ts.map +0 -1
  562. package/testing/matchers/ProfiledComponent.d.ts.map +0 -1
  563. package/testing/matchers/index.d.ts.map +0 -1
  564. package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts.map +0 -1
  565. package/testing/matchers/toMatchDocument.d.ts.map +0 -1
  566. package/testing/react/MockedProvider.d.ts.map +0 -1
  567. package/utilities/common/arrays.d.ts.map +0 -1
  568. package/utilities/common/canUse.d.ts.map +0 -1
  569. package/utilities/common/cloneDeep.d.ts.map +0 -1
  570. package/utilities/common/compact.d.ts.map +0 -1
  571. package/utilities/common/errorHandling.d.ts.map +0 -1
  572. package/utilities/common/filterInPlace.d.ts +0 -2
  573. package/utilities/common/filterInPlace.d.ts.map +0 -1
  574. package/utilities/common/filterInPlace.js +0 -11
  575. package/utilities/common/filterInPlace.js.map +0 -1
  576. package/utilities/common/incrementalResult.d.ts.map +0 -1
  577. package/utilities/common/makeUniqueId.d.ts.map +0 -1
  578. package/utilities/common/maybeDeepFreeze.d.ts.map +0 -1
  579. package/utilities/common/mergeDeep.d.ts.map +0 -1
  580. package/utilities/common/mergeOptions.d.ts.map +0 -1
  581. package/utilities/common/objects.d.ts.map +0 -1
  582. package/utilities/common/omitDeep.d.ts.map +0 -1
  583. package/utilities/common/stringifyForDisplay.d.ts.map +0 -1
  584. package/utilities/common/stripTypename.d.ts.map +0 -1
  585. package/utilities/globals/global.d.ts.map +0 -1
  586. package/utilities/globals/index.d.ts.map +0 -1
  587. package/utilities/globals/invariantWrappers.d.ts.map +0 -1
  588. package/utilities/globals/maybe.d.ts.map +0 -1
  589. package/utilities/graphql/DocumentTransform.d.ts.map +0 -1
  590. package/utilities/graphql/directives.d.ts.map +0 -1
  591. package/utilities/graphql/fragments.d.ts.map +0 -1
  592. package/utilities/graphql/getFromAST.d.ts.map +0 -1
  593. package/utilities/graphql/operations.d.ts.map +0 -1
  594. package/utilities/graphql/print.d.ts.map +0 -1
  595. package/utilities/graphql/storeUtils.d.ts.map +0 -1
  596. package/utilities/graphql/transform.d.ts.map +0 -1
  597. package/utilities/index.d.ts.map +0 -1
  598. package/utilities/observables/Concast.d.ts.map +0 -1
  599. package/utilities/observables/Observable.d.ts.map +0 -1
  600. package/utilities/observables/asyncMap.d.ts.map +0 -1
  601. package/utilities/observables/iteration.d.ts.map +0 -1
  602. package/utilities/observables/subclassing.d.ts.map +0 -1
  603. package/utilities/policies/pagination.d.ts.map +0 -1
  604. package/utilities/promises/decoration.d.ts.map +0 -1
  605. package/utilities/types/DeepOmit.d.ts.map +0 -1
  606. package/utilities/types/DeepPartial.d.ts.map +0 -1
  607. package/utilities/types/IsStrictlyAny.d.ts.map +0 -1
  608. package/utilities/types/Primitive.d.ts.map +0 -1
  609. package/version.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"readFromStore.js","sourceRoot":"","sources":["../../../src/cache/inmemory/readFromStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGhF,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAQhC,OAAO,EACL,OAAO,EACP,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,UAAU,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AC,CAAC,KAAK;YACjE,OAAO,SAAA;SACR,CAAC;IACJ,CAAC;IACH,kBAAC;AAAD,CAAC,AA/ZD,IA+ZC;;AAED,SAAS,YAAY,CAAC,IAAiB;IACrC,IAAI;QACF,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,UAAC,CAAC,EAAE,KAAK;YAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ;gBAAE,MAAM,KAAK,CAAC;YAC3C,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;KACJ;IAAC,OAAO,MAAM,EAAE;QACf,OAAO,MAAM,CAAC;KACf;AACH,CAAC;AAED,SAAS,4BAA4B,CACnC,KAAsB,EACtB,KAAgB,EAChB,UAAe;IAEf,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;QACvB,IAAM,SAAO,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QACtC,SAAO,CAAC,OAAO,CAAC,UAAC,KAAK;YACpB,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;gBAC1B,SAAS,CACP,CAAC,WAAW,CAAC,KAAK,CAAC,EACnB,yEAAyE,EACzE,0BAA0B,CAAC,KAAK,EAAE,KAAK,CAAC,EACxC,KAAK,CAAC,IAAI,CAAC,KAAK,CACjB,CAAC;gBACF,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,SAAO,CAAC,GAAG,EAAE,SAAO,CAAC,CAAC;aACpD;QACH,CAAC,CAAC,CAAC;KACJ;AACH,CAAC","sourcesContent":["import { invariant, newInvariantError } from \"../../utilities/globals/index.js\";\n\nimport type { DocumentNode, FieldNode, SelectionSetNode } from \"graphql\";\nimport { Kind } from \"graphql\";\nimport type { OptimisticWrapperFunction } from \"optimism\";\nimport { wrap } from \"optimism\";\n\nimport type {\n Reference,\n StoreObject,\n FragmentMap,\n FragmentMapFunction,\n} from \"../../utilities/index.js\";\nimport {\n isField,\n resultKeyNameFromField,\n isReference,\n makeReference,\n shouldInclude,\n addTypenameToDocument,\n getDefaultValues,\n getMainDefinition,\n getQueryDefinition,\n getFragmentFromSelection,\n maybeDeepFreeze,\n mergeDeepArray,\n DeepMerger,\n isNonNullObject,\n canUseWeakMap,\n compact,\n} from \"../../utilities/index.js\";\nimport type { Cache } from \"../core/types/Cache.js\";\nimport type {\n DiffQueryAgainstStoreOptions,\n InMemoryCacheConfig,\n NormalizedCache,\n ReadMergeModifyContext,\n} from \"./types.js\";\nimport {\n maybeDependOnExistenceOfEntity,\n supportsResultCaching,\n} from \"./entityStore.js\";\nimport {\n isArray,\n extractFragmentContext,\n getTypenameFromStoreObject,\n shouldCanonizeResults,\n} from \"./helpers.js\";\nimport type { Policies } from \"./policies.js\";\nimport type { InMemoryCache } from \"./inMemoryCache.js\";\nimport type { MissingTree } from \"../core/types/common.js\";\nimport { MissingFieldError } from \"../core/types/common.js\";\nimport { canonicalStringify, ObjectCanon } from \"./object-canon.js\";\n\nexport type VariableMap = { [name: string]: any };\n\ninterface ReadContext extends ReadMergeModifyContext {\n query: DocumentNode;\n policies: Policies;\n canonizeResults: boolean;\n fragmentMap: FragmentMap;\n lookupFragment: FragmentMapFunction;\n}\n\nexport type ExecResult<R = any> = {\n result: R;\n missing?: MissingTree;\n};\n\ntype ExecSelectionSetOptions = {\n selectionSet: SelectionSetNode;\n objectOrReference: StoreObject | Reference;\n enclosingRef: Reference;\n context: ReadContext;\n};\n\ntype ExecSubSelectedArrayOptions = {\n field: FieldNode;\n array: readonly any[];\n enclosingRef: Reference;\n context: ReadContext;\n};\n\nexport interface StoreReaderConfig {\n cache: InMemoryCache;\n addTypename?: boolean;\n resultCacheMaxSize?: number;\n canonizeResults?: boolean;\n canon?: ObjectCanon;\n fragments?: InMemoryCacheConfig[\"fragments\"];\n}\n\n// Arguments type after keyArgs translation.\ntype ExecSelectionSetKeyArgs = [\n SelectionSetNode,\n StoreObject | Reference,\n ReadMergeModifyContext,\n boolean,\n];\n\nfunction execSelectionSetKeyArgs(\n options: ExecSelectionSetOptions\n): ExecSelectionSetKeyArgs {\n return [\n options.selectionSet,\n options.objectOrReference,\n options.context,\n // We split out this property so we can pass different values\n // independently without modifying options.context itself.\n options.context.canonizeResults,\n ];\n}\n\nexport class StoreReader {\n // cached version of executeSelectionSet\n private executeSelectionSet: OptimisticWrapperFunction<\n [ExecSelectionSetOptions], // Actual arguments tuple type.\n ExecResult, // Actual return type.\n ExecSelectionSetKeyArgs\n >;\n\n // cached version of executeSubSelectedArray\n private executeSubSelectedArray: OptimisticWrapperFunction<\n [ExecSubSelectedArrayOptions],\n ExecResult<any>,\n [ExecSubSelectedArrayOptions]\n >;\n\n private config: {\n cache: InMemoryCache;\n addTypename: boolean;\n resultCacheMaxSize?: number;\n canonizeResults: boolean;\n fragments?: InMemoryCacheConfig[\"fragments\"];\n };\n\n private knownResults = new (canUseWeakMap ? WeakMap : Map)<\n Record<string, any>,\n SelectionSetNode\n >();\n\n public canon: ObjectCanon;\n public resetCanon() {\n this.canon = new ObjectCanon();\n }\n\n constructor(config: StoreReaderConfig) {\n this.config = compact(config, {\n addTypename: config.addTypename !== false,\n canonizeResults: shouldCanonizeResults(config),\n });\n\n this.canon = config.canon || new ObjectCanon();\n\n this.executeSelectionSet = wrap(\n (options) => {\n const { canonizeResults } = options.context;\n\n const peekArgs = execSelectionSetKeyArgs(options);\n\n // Negate this boolean option so we can find out if we've already read\n // this result using the other boolean value.\n peekArgs[3] = !canonizeResults;\n\n const other = this.executeSelectionSet.peek(...peekArgs);\n\n if (other) {\n if (canonizeResults) {\n return {\n ...other,\n // If we previously read this result without canonizing it, we can\n // reuse that result simply by canonizing it now.\n result: this.canon.admit(other.result),\n };\n }\n // If we previously read this result with canonization enabled, we can\n // return that canonized result as-is.\n return other;\n }\n\n maybeDependOnExistenceOfEntity(\n options.context.store,\n options.enclosingRef.__ref\n );\n\n // Finally, if we didn't find any useful previous results, run the real\n // execSelectionSetImpl method with the given options.\n return this.execSelectionSetImpl(options);\n },\n {\n max: this.config.resultCacheMaxSize,\n keyArgs: execSelectionSetKeyArgs,\n // Note that the parameters of makeCacheKey are determined by the\n // array returned by keyArgs.\n makeCacheKey(selectionSet, parent, context, canonizeResults) {\n if (supportsResultCaching(context.store)) {\n return context.store.makeCacheKey(\n selectionSet,\n isReference(parent) ? parent.__ref : parent,\n context.varString,\n canonizeResults\n );\n }\n },\n }\n );\n\n this.executeSubSelectedArray = wrap(\n (options: ExecSubSelectedArrayOptions) => {\n maybeDependOnExistenceOfEntity(\n options.context.store,\n options.enclosingRef.__ref\n );\n return this.execSubSelectedArrayImpl(options);\n },\n {\n max: this.config.resultCacheMaxSize,\n makeCacheKey({ field, array, context }) {\n if (supportsResultCaching(context.store)) {\n return context.store.makeCacheKey(field, array, context.varString);\n }\n },\n }\n );\n }\n\n /**\n * Given a store and a query, return as much of the result as possible and\n * identify if any data was missing from the store.\n * @param {DocumentNode} query A parsed GraphQL query document\n * @param {Store} store The Apollo Client store object\n * @return {result: Object, complete: [boolean]}\n */\n public diffQueryAgainstStore<T>({\n store,\n query,\n rootId = \"ROOT_QUERY\",\n variables,\n returnPartialData = true,\n canonizeResults = this.config.canonizeResults,\n }: DiffQueryAgainstStoreOptions): Cache.DiffResult<T> {\n const policies = this.config.cache.policies;\n\n variables = {\n ...getDefaultValues(getQueryDefinition(query)),\n ...variables!,\n };\n\n const rootRef = makeReference(rootId);\n const execResult = this.executeSelectionSet({\n selectionSet: getMainDefinition(query).selectionSet,\n objectOrReference: rootRef,\n enclosingRef: rootRef,\n context: {\n store,\n query,\n policies,\n variables,\n varString: canonicalStringify(variables),\n canonizeResults,\n ...extractFragmentContext(query, this.config.fragments),\n },\n });\n\n let missing: MissingFieldError[] | undefined;\n if (execResult.missing) {\n // For backwards compatibility we still report an array of\n // MissingFieldError objects, even though there will only ever be at most\n // one of them, now that all missing field error messages are grouped\n // together in the execResult.missing tree.\n missing = [\n new MissingFieldError(\n firstMissing(execResult.missing)!,\n execResult.missing,\n query,\n variables\n ),\n ];\n if (!returnPartialData) {\n throw missing[0];\n }\n }\n\n return {\n result: execResult.result,\n complete: !missing,\n missing,\n };\n }\n\n public isFresh(\n result: Record<string, any>,\n parent: StoreObject | Reference,\n selectionSet: SelectionSetNode,\n context: ReadMergeModifyContext\n ): boolean {\n if (\n supportsResultCaching(context.store) &&\n this.knownResults.get(result) === selectionSet\n ) {\n const latest = this.executeSelectionSet.peek(\n selectionSet,\n parent,\n context,\n // If result is canonical, then it could only have been previously\n // cached by the canonizing version of executeSelectionSet, so we can\n // avoid checking both possibilities here.\n this.canon.isKnown(result)\n );\n if (latest && result === latest.result) {\n return true;\n }\n }\n return false;\n }\n\n // Uncached version of executeSelectionSet.\n private execSelectionSetImpl({\n selectionSet,\n objectOrReference,\n enclosingRef,\n context,\n }: ExecSelectionSetOptions): ExecResult {\n if (\n isReference(objectOrReference) &&\n !context.policies.rootTypenamesById[objectOrReference.__ref] &&\n !context.store.has(objectOrReference.__ref)\n ) {\n return {\n result: this.canon.empty,\n missing: `Dangling reference to missing ${objectOrReference.__ref} object`,\n };\n }\n\n const { variables, policies, store } = context;\n const typename = store.getFieldValue<string>(\n objectOrReference,\n \"__typename\"\n );\n\n const objectsToMerge: Record<string, any>[] = [];\n let missing: MissingTree | undefined;\n const missingMerger = new DeepMerger();\n\n if (\n this.config.addTypename &&\n typeof typename === \"string\" &&\n !policies.rootIdsByTypename[typename]\n ) {\n // Ensure we always include a default value for the __typename\n // field, if we have one, and this.config.addTypename is true. Note\n // that this field can be overridden by other merged objects.\n objectsToMerge.push({ __typename: typename });\n }\n\n function handleMissing<T>(result: ExecResult<T>, resultName: string): T {\n if (result.missing) {\n missing = missingMerger.merge(missing, {\n [resultName]: result.missing,\n });\n }\n return result.result;\n }\n\n const workSet = new Set(selectionSet.selections);\n\n workSet.forEach((selection) => {\n // Omit fields with directives @skip(if: <truthy value>) or\n // @include(if: <falsy value>).\n if (!shouldInclude(selection, variables)) return;\n\n if (isField(selection)) {\n let fieldValue = policies.readField(\n {\n fieldName: selection.name.value,\n field: selection,\n variables: context.variables,\n from: objectOrReference,\n },\n context\n );\n\n const resultName = resultKeyNameFromField(selection);\n\n if (fieldValue === void 0) {\n if (!addTypenameToDocument.added(selection)) {\n missing = missingMerger.merge(missing, {\n [resultName]: `Can't find field '${selection.name.value}' on ${\n isReference(objectOrReference)\n ? objectOrReference.__ref + \" object\"\n : \"object \" + JSON.stringify(objectOrReference, null, 2)\n }`,\n });\n }\n } else if (isArray(fieldValue)) {\n fieldValue = handleMissing(\n this.executeSubSelectedArray({\n field: selection,\n array: fieldValue,\n enclosingRef,\n context,\n }),\n resultName\n );\n } else if (!selection.selectionSet) {\n // If the field does not have a selection set, then we handle it\n // as a scalar value. To keep this.canon from canonicalizing\n // this value, we use this.canon.pass to wrap fieldValue in a\n // Pass object that this.canon.admit will later unwrap as-is.\n if (context.canonizeResults) {\n fieldValue = this.canon.pass(fieldValue);\n }\n } else if (fieldValue != null) {\n // In this case, because we know the field has a selection set,\n // it must be trying to query a GraphQLObjectType, which is why\n // fieldValue must be != null.\n fieldValue = handleMissing(\n this.executeSelectionSet({\n selectionSet: selection.selectionSet,\n objectOrReference: fieldValue as StoreObject | Reference,\n enclosingRef: isReference(fieldValue) ? fieldValue : enclosingRef,\n context,\n }),\n resultName\n );\n }\n\n if (fieldValue !== void 0) {\n objectsToMerge.push({ [resultName]: fieldValue });\n }\n } else {\n const fragment = getFragmentFromSelection(\n selection,\n context.lookupFragment\n );\n\n if (!fragment && selection.kind === Kind.FRAGMENT_SPREAD) {\n throw newInvariantError(`No fragment named %s`, selection.name.value);\n }\n\n if (fragment && policies.fragmentMatches(fragment, typename)) {\n fragment.selectionSet.selections.forEach(workSet.add, workSet);\n }\n }\n });\n\n const result = mergeDeepArray(objectsToMerge);\n const finalResult: ExecResult = { result, missing };\n const frozen = context.canonizeResults\n ? this.canon.admit(finalResult)\n : // Since this.canon is normally responsible for freezing results (only in\n // development), freeze them manually if canonization is disabled.\n maybeDeepFreeze(finalResult);\n\n // Store this result with its selection set so that we can quickly\n // recognize it again in the StoreReader#isFresh method.\n if (frozen.result) {\n this.knownResults.set(frozen.result, selectionSet);\n }\n\n return frozen;\n }\n\n // Uncached version of executeSubSelectedArray.\n private execSubSelectedArrayImpl({\n field,\n array,\n enclosingRef,\n context,\n }: ExecSubSelectedArrayOptions): ExecResult {\n let missing: MissingTree | undefined;\n let missingMerger = new DeepMerger<MissingTree[]>();\n\n function handleMissing<T>(childResult: ExecResult<T>, i: number): T {\n if (childResult.missing) {\n missing = missingMerger.merge(missing, { [i]: childResult.missing });\n }\n return childResult.result;\n }\n\n if (field.selectionSet) {\n array = array.filter(context.store.canRead);\n }\n\n array = array.map((item, i) => {\n // null value in array\n if (item === null) {\n return null;\n }\n\n // This is a nested array, recurse\n if (isArray(item)) {\n return handleMissing(\n this.executeSubSelectedArray({\n field,\n array: item,\n enclosingRef,\n context,\n }),\n i\n );\n }\n\n // This is an object, run the selection set on it\n if (field.selectionSet) {\n return handleMissing(\n this.executeSelectionSet({\n selectionSet: field.selectionSet,\n objectOrReference: item,\n enclosingRef: isReference(item) ? item : enclosingRef,\n context,\n }),\n i\n );\n }\n\n if (__DEV__) {\n assertSelectionSetForIdValue(context.store, field, item);\n }\n\n return item;\n });\n\n return {\n result: context.canonizeResults ? this.canon.admit(array) : array,\n missing,\n };\n }\n}\n\nfunction firstMissing(tree: MissingTree): string | undefined {\n try {\n JSON.stringify(tree, (_, value) => {\n if (typeof value === \"string\") throw value;\n return value;\n });\n } catch (result) {\n return result;\n }\n}\n\nfunction assertSelectionSetForIdValue(\n store: NormalizedCache,\n field: FieldNode,\n fieldValue: any\n) {\n if (!field.selectionSet) {\n const workSet = new Set([fieldValue]);\n workSet.forEach((value) => {\n if (isNonNullObject(value)) {\n invariant(\n !isReference(value),\n `Missing selection set for object of type %s returned for query field %s`,\n getTypenameFromStoreObject(store, value),\n field.name.value\n );\n Object.values(value).forEach(workSet.add, workSet);\n }\n });\n }\n}\n"]}
1
+ {"version":3,"file":"readFromStore.js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CAAC;QAEH,OAAO;YACL,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;YACjE,OAAO,SAAA;SACR,CAAC;IACJ,CAAC;IACH,kBAAC;AAAD,CAAC,AA7ZD,IA6ZC;;AAED,SAAS,YAAY,CAAC,IAAiB;IACrC,IAAI,CAAC;QACH,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,UAAC,CAAC,EAAE,KAAK;YAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ;gBAAE,MAAM,KAAK,CAAC;YAC3C,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,OAAO,MAAgB,CAAC;IAC1B,CAAC;AACH,CAAC;AAED,SAAS,4BAA4B,CACnC,KAAsB,EACtB,KAAgB,EAChB,UAAe;IAEf,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QACxB,IAAM,SAAO,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QACtC,SAAO,CAAC,OAAO,CAAC,UAAC,KAAK;YACpB,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3B,SAAS,CACP,CAAC,WAAW,CAAC,KAAK,CAAC,EACnB,yEAAyE,EACzE,0BAA0B,CAAC,KAAK,EAAE,KAAK,CAAC,EACxC,KAAK,CAAC,IAAI,CAAC,KAAK,CACjB,CAAC;gBACF,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,SAAO,CAAC,GAAG,EAAE,SAAO,CAAC,CAAC;YACrD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import { invariant, newInvariantError } from \"../../utilities/globals/index.js\";\n\nimport type { DocumentNode, FieldNode, SelectionSetNode } from \"graphql\";\nimport { Kind } from \"graphql\";\nimport type { OptimisticWrapperFunction } from \"optimism\";\nimport { wrap } from \"optimism\";\n\nimport type {\n Reference,\n StoreObject,\n FragmentMap,\n FragmentMapFunction,\n} from \"../../utilities/index.js\";\nimport {\n isField,\n resultKeyNameFromField,\n isReference,\n makeReference,\n shouldInclude,\n addTypenameToDocument,\n getDefaultValues,\n getMainDefinition,\n getQueryDefinition,\n getFragmentFromSelection,\n maybeDeepFreeze,\n mergeDeepArray,\n DeepMerger,\n isNonNullObject,\n canUseWeakMap,\n compact,\n} from \"../../utilities/index.js\";\nimport type { Cache } from \"../core/types/Cache.js\";\nimport type {\n DiffQueryAgainstStoreOptions,\n InMemoryCacheConfig,\n NormalizedCache,\n ReadMergeModifyContext,\n} from \"./types.js\";\nimport {\n maybeDependOnExistenceOfEntity,\n supportsResultCaching,\n} from \"./entityStore.js\";\nimport {\n isArray,\n extractFragmentContext,\n getTypenameFromStoreObject,\n shouldCanonizeResults,\n} from \"./helpers.js\";\nimport type { Policies } from \"./policies.js\";\nimport type { InMemoryCache } from \"./inMemoryCache.js\";\nimport type { MissingTree } from \"../core/types/common.js\";\nimport { MissingFieldError } from \"../core/types/common.js\";\nimport { canonicalStringify, ObjectCanon } from \"./object-canon.js\";\n\nexport type VariableMap = { [name: string]: any };\n\ninterface ReadContext extends ReadMergeModifyContext {\n query: DocumentNode;\n policies: Policies;\n canonizeResults: boolean;\n fragmentMap: FragmentMap;\n lookupFragment: FragmentMapFunction;\n}\n\nexport type ExecResult<R = any> = {\n result: R;\n missing?: MissingTree;\n};\n\ntype ExecSelectionSetOptions = {\n selectionSet: SelectionSetNode;\n objectOrReference: StoreObject | Reference;\n enclosingRef: Reference;\n context: ReadContext;\n};\n\ntype ExecSubSelectedArrayOptions = {\n field: FieldNode;\n array: readonly any[];\n enclosingRef: Reference;\n context: ReadContext;\n};\n\nexport interface StoreReaderConfig {\n cache: InMemoryCache;\n addTypename?: boolean;\n resultCacheMaxSize?: number;\n canonizeResults?: boolean;\n canon?: ObjectCanon;\n fragments?: InMemoryCacheConfig[\"fragments\"];\n}\n\n// Arguments type after keyArgs translation.\ntype ExecSelectionSetKeyArgs = [\n SelectionSetNode,\n StoreObject | Reference,\n ReadMergeModifyContext,\n boolean,\n];\n\nfunction execSelectionSetKeyArgs(\n options: ExecSelectionSetOptions\n): ExecSelectionSetKeyArgs {\n return [\n options.selectionSet,\n options.objectOrReference,\n options.context,\n // We split out this property so we can pass different values\n // independently without modifying options.context itself.\n options.context.canonizeResults,\n ];\n}\n\nexport class StoreReader {\n // cached version of executeSelectionSet\n private executeSelectionSet: OptimisticWrapperFunction<\n [ExecSelectionSetOptions], // Actual arguments tuple type.\n ExecResult, // Actual return type.\n ExecSelectionSetKeyArgs\n >;\n\n // cached version of executeSubSelectedArray\n private executeSubSelectedArray: OptimisticWrapperFunction<\n [ExecSubSelectedArrayOptions],\n ExecResult<any>,\n [ExecSubSelectedArrayOptions]\n >;\n\n private config: {\n cache: InMemoryCache;\n addTypename: boolean;\n resultCacheMaxSize?: number;\n canonizeResults: boolean;\n fragments?: InMemoryCacheConfig[\"fragments\"];\n };\n\n private knownResults = new (canUseWeakMap ? WeakMap : Map)<\n Record<string, any>,\n SelectionSetNode\n >();\n\n public canon: ObjectCanon;\n public resetCanon() {\n this.canon = new ObjectCanon();\n }\n\n constructor(config: StoreReaderConfig) {\n this.config = compact(config, {\n addTypename: config.addTypename !== false,\n canonizeResults: shouldCanonizeResults(config),\n });\n\n this.canon = config.canon || new ObjectCanon();\n\n this.executeSelectionSet = wrap(\n (options) => {\n const { canonizeResults } = options.context;\n\n const peekArgs = execSelectionSetKeyArgs(options);\n\n // Negate this boolean option so we can find out if we've already read\n // this result using the other boolean value.\n peekArgs[3] = !canonizeResults;\n\n const other = this.executeSelectionSet.peek(...peekArgs);\n\n if (other) {\n if (canonizeResults) {\n return {\n ...other,\n // If we previously read this result without canonizing it, we can\n // reuse that result simply by canonizing it now.\n result: this.canon.admit(other.result),\n };\n }\n // If we previously read this result with canonization enabled, we can\n // return that canonized result as-is.\n return other;\n }\n\n maybeDependOnExistenceOfEntity(\n options.context.store,\n options.enclosingRef.__ref\n );\n\n // Finally, if we didn't find any useful previous results, run the real\n // execSelectionSetImpl method with the given options.\n return this.execSelectionSetImpl(options);\n },\n {\n max: this.config.resultCacheMaxSize,\n keyArgs: execSelectionSetKeyArgs,\n // Note that the parameters of makeCacheKey are determined by the\n // array returned by keyArgs.\n makeCacheKey(selectionSet, parent, context, canonizeResults) {\n if (supportsResultCaching(context.store)) {\n return context.store.makeCacheKey(\n selectionSet,\n isReference(parent) ? parent.__ref : parent,\n context.varString,\n canonizeResults\n );\n }\n },\n }\n );\n\n this.executeSubSelectedArray = wrap(\n (options: ExecSubSelectedArrayOptions) => {\n maybeDependOnExistenceOfEntity(\n options.context.store,\n options.enclosingRef.__ref\n );\n return this.execSubSelectedArrayImpl(options);\n },\n {\n max: this.config.resultCacheMaxSize,\n makeCacheKey({ field, array, context }) {\n if (supportsResultCaching(context.store)) {\n return context.store.makeCacheKey(field, array, context.varString);\n }\n },\n }\n );\n }\n\n /**\n * Given a store and a query, return as much of the result as possible and\n * identify if any data was missing from the store.\n */\n public diffQueryAgainstStore<T>({\n store,\n query,\n rootId = \"ROOT_QUERY\",\n variables,\n returnPartialData = true,\n canonizeResults = this.config.canonizeResults,\n }: DiffQueryAgainstStoreOptions): Cache.DiffResult<T> {\n const policies = this.config.cache.policies;\n\n variables = {\n ...getDefaultValues(getQueryDefinition(query)),\n ...variables!,\n };\n\n const rootRef = makeReference(rootId);\n const execResult = this.executeSelectionSet({\n selectionSet: getMainDefinition(query).selectionSet,\n objectOrReference: rootRef,\n enclosingRef: rootRef,\n context: {\n store,\n query,\n policies,\n variables,\n varString: canonicalStringify(variables),\n canonizeResults,\n ...extractFragmentContext(query, this.config.fragments),\n },\n });\n\n let missing: MissingFieldError[] | undefined;\n if (execResult.missing) {\n // For backwards compatibility we still report an array of\n // MissingFieldError objects, even though there will only ever be at most\n // one of them, now that all missing field error messages are grouped\n // together in the execResult.missing tree.\n missing = [\n new MissingFieldError(\n firstMissing(execResult.missing)!,\n execResult.missing,\n query,\n variables\n ),\n ];\n if (!returnPartialData) {\n throw missing[0];\n }\n }\n\n return {\n result: execResult.result,\n complete: !missing,\n missing,\n };\n }\n\n public isFresh(\n result: Record<string, any>,\n parent: StoreObject | Reference,\n selectionSet: SelectionSetNode,\n context: ReadMergeModifyContext\n ): boolean {\n if (\n supportsResultCaching(context.store) &&\n this.knownResults.get(result) === selectionSet\n ) {\n const latest = this.executeSelectionSet.peek(\n selectionSet,\n parent,\n context,\n // If result is canonical, then it could only have been previously\n // cached by the canonizing version of executeSelectionSet, so we can\n // avoid checking both possibilities here.\n this.canon.isKnown(result)\n );\n if (latest && result === latest.result) {\n return true;\n }\n }\n return false;\n }\n\n // Uncached version of executeSelectionSet.\n private execSelectionSetImpl({\n selectionSet,\n objectOrReference,\n enclosingRef,\n context,\n }: ExecSelectionSetOptions): ExecResult {\n if (\n isReference(objectOrReference) &&\n !context.policies.rootTypenamesById[objectOrReference.__ref] &&\n !context.store.has(objectOrReference.__ref)\n ) {\n return {\n result: this.canon.empty,\n missing: `Dangling reference to missing ${objectOrReference.__ref} object`,\n };\n }\n\n const { variables, policies, store } = context;\n const typename = store.getFieldValue<string>(\n objectOrReference,\n \"__typename\"\n );\n\n const objectsToMerge: Record<string, any>[] = [];\n let missing: MissingTree | undefined;\n const missingMerger = new DeepMerger();\n\n if (\n this.config.addTypename &&\n typeof typename === \"string\" &&\n !policies.rootIdsByTypename[typename]\n ) {\n // Ensure we always include a default value for the __typename\n // field, if we have one, and this.config.addTypename is true. Note\n // that this field can be overridden by other merged objects.\n objectsToMerge.push({ __typename: typename });\n }\n\n function handleMissing<T>(result: ExecResult<T>, resultName: string): T {\n if (result.missing) {\n missing = missingMerger.merge(missing, {\n [resultName]: result.missing,\n });\n }\n return result.result;\n }\n\n const workSet = new Set(selectionSet.selections);\n\n workSet.forEach((selection) => {\n // Omit fields with directives @skip(if: <truthy value>) or\n // @include(if: <falsy value>).\n if (!shouldInclude(selection, variables)) return;\n\n if (isField(selection)) {\n let fieldValue = policies.readField(\n {\n fieldName: selection.name.value,\n field: selection,\n variables: context.variables,\n from: objectOrReference,\n },\n context\n );\n\n const resultName = resultKeyNameFromField(selection);\n\n if (fieldValue === void 0) {\n if (!addTypenameToDocument.added(selection)) {\n missing = missingMerger.merge(missing, {\n [resultName]: `Can't find field '${selection.name.value}' on ${\n isReference(objectOrReference) ?\n objectOrReference.__ref + \" object\"\n : \"object \" + JSON.stringify(objectOrReference, null, 2)\n }`,\n });\n }\n } else if (isArray(fieldValue)) {\n fieldValue = handleMissing(\n this.executeSubSelectedArray({\n field: selection,\n array: fieldValue,\n enclosingRef,\n context,\n }),\n resultName\n );\n } else if (!selection.selectionSet) {\n // If the field does not have a selection set, then we handle it\n // as a scalar value. To keep this.canon from canonicalizing\n // this value, we use this.canon.pass to wrap fieldValue in a\n // Pass object that this.canon.admit will later unwrap as-is.\n if (context.canonizeResults) {\n fieldValue = this.canon.pass(fieldValue);\n }\n } else if (fieldValue != null) {\n // In this case, because we know the field has a selection set,\n // it must be trying to query a GraphQLObjectType, which is why\n // fieldValue must be != null.\n fieldValue = handleMissing(\n this.executeSelectionSet({\n selectionSet: selection.selectionSet,\n objectOrReference: fieldValue as StoreObject | Reference,\n enclosingRef: isReference(fieldValue) ? fieldValue : enclosingRef,\n context,\n }),\n resultName\n );\n }\n\n if (fieldValue !== void 0) {\n objectsToMerge.push({ [resultName]: fieldValue });\n }\n } else {\n const fragment = getFragmentFromSelection(\n selection,\n context.lookupFragment\n );\n\n if (!fragment && selection.kind === Kind.FRAGMENT_SPREAD) {\n throw newInvariantError(`No fragment named %s`, selection.name.value);\n }\n\n if (fragment && policies.fragmentMatches(fragment, typename)) {\n fragment.selectionSet.selections.forEach(workSet.add, workSet);\n }\n }\n });\n\n const result = mergeDeepArray(objectsToMerge);\n const finalResult: ExecResult = { result, missing };\n const frozen =\n context.canonizeResults ?\n this.canon.admit(finalResult)\n // Since this.canon is normally responsible for freezing results (only in\n // development), freeze them manually if canonization is disabled.\n : maybeDeepFreeze(finalResult);\n\n // Store this result with its selection set so that we can quickly\n // recognize it again in the StoreReader#isFresh method.\n if (frozen.result) {\n this.knownResults.set(frozen.result, selectionSet);\n }\n\n return frozen;\n }\n\n // Uncached version of executeSubSelectedArray.\n private execSubSelectedArrayImpl({\n field,\n array,\n enclosingRef,\n context,\n }: ExecSubSelectedArrayOptions): ExecResult {\n let missing: MissingTree | undefined;\n let missingMerger = new DeepMerger<MissingTree[]>();\n\n function handleMissing<T>(childResult: ExecResult<T>, i: number): T {\n if (childResult.missing) {\n missing = missingMerger.merge(missing, { [i]: childResult.missing });\n }\n return childResult.result;\n }\n\n if (field.selectionSet) {\n array = array.filter(context.store.canRead);\n }\n\n array = array.map((item, i) => {\n // null value in array\n if (item === null) {\n return null;\n }\n\n // This is a nested array, recurse\n if (isArray(item)) {\n return handleMissing(\n this.executeSubSelectedArray({\n field,\n array: item,\n enclosingRef,\n context,\n }),\n i\n );\n }\n\n // This is an object, run the selection set on it\n if (field.selectionSet) {\n return handleMissing(\n this.executeSelectionSet({\n selectionSet: field.selectionSet,\n objectOrReference: item,\n enclosingRef: isReference(item) ? item : enclosingRef,\n context,\n }),\n i\n );\n }\n\n if (__DEV__) {\n assertSelectionSetForIdValue(context.store, field, item);\n }\n\n return item;\n });\n\n return {\n result: context.canonizeResults ? this.canon.admit(array) : array,\n missing,\n };\n }\n}\n\nfunction firstMissing(tree: MissingTree): string | undefined {\n try {\n JSON.stringify(tree, (_, value) => {\n if (typeof value === \"string\") throw value;\n return value;\n });\n } catch (result) {\n return result as string;\n }\n}\n\nfunction assertSelectionSetForIdValue(\n store: NormalizedCache,\n field: FieldNode,\n fieldValue: any\n) {\n if (!field.selectionSet) {\n const workSet = new Set([fieldValue]);\n workSet.forEach((value) => {\n if (isNonNullObject(value)) {\n invariant(\n !isReference(value),\n `Missing selection set for object of type %s returned for query field %s`,\n getTypenameFromStoreObject(store, value),\n field.name.value\n );\n Object.values(value).forEach(workSet.add, workSet);\n }\n });\n }\n}\n"]}
@@ -12,6 +12,10 @@ export interface IdGetterObj extends Object {
12
12
  _id?: string;
13
13
  }
14
14
  export declare type IdGetter = (value: IdGetterObj) => string | undefined;
15
+ /**
16
+ * This is an interface used to access, set and remove
17
+ * StoreObjects from the cache
18
+ */
15
19
  export interface NormalizedCache {
16
20
  has(dataId: string): boolean;
17
21
  get(dataId: string, fieldName: string): StoreValue;
@@ -20,8 +24,22 @@ export interface NormalizedCache {
20
24
  modify<Entity extends Record<string, any>>(dataId: string, fields: Modifiers<Entity> | AllFieldsModifier<Entity>): boolean;
21
25
  delete(dataId: string, fieldName?: string): boolean;
22
26
  clear(): void;
27
+ /**
28
+ * returns an Object with key-value pairs matching the contents of the store
29
+ */
23
30
  toObject(): NormalizedCacheObject;
31
+ /**
32
+ * replace the state of the store
33
+ */
24
34
  replace(newData: NormalizedCacheObject): void;
35
+ /**
36
+ * Retain (or release) a given root ID to protect (or expose) it and its
37
+ * transitive child entities from (or to) garbage collection. The current
38
+ * retainment count is returned by both methods. Note that releasing a root
39
+ * ID does not cause that entity to be garbage collected, but merely removes
40
+ * it from the set of root IDs that will be considered during the next
41
+ * mark-and-sweep collection.
42
+ */
25
43
  retain(rootId: string): number;
26
44
  release(rootId: string): number;
27
45
  getFieldValue: FieldValueGetter;
@@ -29,6 +47,10 @@ export interface NormalizedCache {
29
47
  canRead: CanReadFunction;
30
48
  getStorage(idOrObj: string | StoreObject, ...storeFieldNames: (string | number)[]): StorageType;
31
49
  }
50
+ /**
51
+ * This is a normalized representation of the Apollo query result cache. It consists of
52
+ * a flattened representation of query result trees.
53
+ */
32
54
  export interface NormalizedCacheObject {
33
55
  __META?: {
34
56
  extraRootIds: string[];
@@ -41,7 +63,13 @@ export type OptimisticStoreItem = {
41
63
  transaction: Transaction<NormalizedCacheObject>;
42
64
  };
43
65
  export type ReadQueryOptions = {
66
+ /**
67
+ * The Apollo Client store object.
68
+ */
44
69
  store: NormalizedCache;
70
+ /**
71
+ * A parsed GraphQL query document.
72
+ */
45
73
  query: DocumentNode;
46
74
  variables?: Object;
47
75
  previousResult?: any;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/cache/inmemory/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DocumentNode, FieldNode } from \"graphql\";\n\nimport type { Transaction } from \"../core/cache.js\";\nimport type {\n StoreObject,\n StoreValue,\n Reference,\n} from \"../../utilities/index.js\";\nimport type { FieldValueGetter } from \"./entityStore.js\";\nimport type {\n TypePolicies,\n PossibleTypesMap,\n KeyFieldsFunction,\n StorageType,\n FieldMergeFunction,\n} from \"./policies.js\";\nimport type {\n Modifiers,\n ToReferenceFunction,\n CanReadFunction,\n AllFieldsModifier,\n} from \"../core/types/common.js\";\n\nimport type { FragmentRegistryAPI } from \"./fragmentRegistry.js\";\n\nexport type { StoreObject, StoreValue, Reference };\n\nexport interface IdGetterObj extends Object {\n __typename?: string;\n id?: string;\n _id?: string;\n}\n\nexport declare type IdGetter = (value: IdGetterObj) => string | undefined;\n\n/**\n * This is an interface used to access, set and remove\n * StoreObjects from the cache\n */\nexport interface NormalizedCache {\n has(dataId: string): boolean;\n get(dataId: string, fieldName: string): StoreValue;\n\n // The store.merge method allows either argument to be a string ID, but\n // the other argument has to be a StoreObject. Either way, newer fields\n // always take precedence over older fields.\n merge(olderId: string, newerObject: StoreObject): void;\n merge(olderObject: StoreObject, newerId: string): void;\n\n modify<Entity extends Record<string, any>>(\n dataId: string,\n fields: Modifiers<Entity> | AllFieldsModifier<Entity>\n ): boolean;\n delete(dataId: string, fieldName?: string): boolean;\n clear(): void;\n\n // non-Map elements:\n /**\n * returns an Object with key-value pairs matching the contents of the store\n */\n toObject(): NormalizedCacheObject;\n /**\n * replace the state of the store\n */\n replace(newData: NormalizedCacheObject): void;\n\n /**\n * Retain (or release) a given root ID to protect (or expose) it and its\n * transitive child entities from (or to) garbage collection. The current\n * retainment count is returned by both methods. Note that releasing a root\n * ID does not cause that entity to be garbage collected, but merely removes\n * it from the set of root IDs that will be considered during the next\n * mark-and-sweep collection.\n */\n retain(rootId: string): number;\n release(rootId: string): number;\n\n getFieldValue: FieldValueGetter;\n toReference: ToReferenceFunction;\n canRead: CanReadFunction;\n\n getStorage(\n idOrObj: string | StoreObject,\n ...storeFieldNames: (string | number)[]\n ): StorageType;\n}\n\n/**\n * This is a normalized representation of the Apollo query result cache. It consists of\n * a flattened representation of query result trees.\n */\nexport interface NormalizedCacheObject {\n __META?: {\n // Well-known singleton IDs like ROOT_QUERY and ROOT_MUTATION are\n // always considered to be root IDs during cache.gc garbage\n // collection, but other IDs can become roots if they are written\n // directly with cache.writeFragment or retained explicitly with\n // cache.retain. When such IDs exist, we include them in the __META\n // section so that they can survive cache.{extract,restore}.\n extraRootIds: string[];\n };\n [dataId: string]: StoreObject | undefined;\n}\n\nexport type OptimisticStoreItem = {\n id: string;\n data: NormalizedCacheObject;\n transaction: Transaction<NormalizedCacheObject>;\n};\n\nexport type ReadQueryOptions = {\n store: NormalizedCache;\n query: DocumentNode;\n variables?: Object;\n previousResult?: any;\n canonizeResults?: boolean;\n rootId?: string;\n config?: ApolloReducerConfig;\n};\n\nexport type DiffQueryAgainstStoreOptions = ReadQueryOptions & {\n returnPartialData?: boolean;\n};\n\nexport type ApolloReducerConfig = {\n dataIdFromObject?: KeyFieldsFunction;\n addTypename?: boolean;\n};\n\nexport interface InMemoryCacheConfig extends ApolloReducerConfig {\n resultCaching?: boolean;\n possibleTypes?: PossibleTypesMap;\n typePolicies?: TypePolicies;\n resultCacheMaxSize?: number;\n canonizeResults?: boolean;\n fragments?: FragmentRegistryAPI;\n}\n\nexport interface MergeInfo {\n field: FieldNode;\n typename: string | undefined;\n merge: FieldMergeFunction;\n}\n\nexport interface MergeTree {\n info?: MergeInfo;\n map: Map<string | number, MergeTree>;\n}\n\nexport interface ReadMergeModifyContext {\n store: NormalizedCache;\n variables?: Record<string, any>;\n // A JSON.stringify-serialized version of context.variables.\n varString?: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/cache/inmemory/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DocumentNode, FieldNode } from \"graphql\";\n\nimport type { Transaction } from \"../core/cache.js\";\nimport type {\n StoreObject,\n StoreValue,\n Reference,\n} from \"../../utilities/index.js\";\nimport type { FieldValueGetter } from \"./entityStore.js\";\nimport type {\n TypePolicies,\n PossibleTypesMap,\n KeyFieldsFunction,\n StorageType,\n FieldMergeFunction,\n} from \"./policies.js\";\nimport type {\n Modifiers,\n ToReferenceFunction,\n CanReadFunction,\n AllFieldsModifier,\n} from \"../core/types/common.js\";\n\nimport type { FragmentRegistryAPI } from \"./fragmentRegistry.js\";\n\nexport type { StoreObject, StoreValue, Reference };\n\nexport interface IdGetterObj extends Object {\n __typename?: string;\n id?: string;\n _id?: string;\n}\n\nexport declare type IdGetter = (value: IdGetterObj) => string | undefined;\n\n/**\n * This is an interface used to access, set and remove\n * StoreObjects from the cache\n */\nexport interface NormalizedCache {\n has(dataId: string): boolean;\n get(dataId: string, fieldName: string): StoreValue;\n\n // The store.merge method allows either argument to be a string ID, but\n // the other argument has to be a StoreObject. Either way, newer fields\n // always take precedence over older fields.\n merge(olderId: string, newerObject: StoreObject): void;\n merge(olderObject: StoreObject, newerId: string): void;\n\n modify<Entity extends Record<string, any>>(\n dataId: string,\n fields: Modifiers<Entity> | AllFieldsModifier<Entity>\n ): boolean;\n delete(dataId: string, fieldName?: string): boolean;\n clear(): void;\n\n // non-Map elements:\n /**\n * returns an Object with key-value pairs matching the contents of the store\n */\n toObject(): NormalizedCacheObject;\n /**\n * replace the state of the store\n */\n replace(newData: NormalizedCacheObject): void;\n\n /**\n * Retain (or release) a given root ID to protect (or expose) it and its\n * transitive child entities from (or to) garbage collection. The current\n * retainment count is returned by both methods. Note that releasing a root\n * ID does not cause that entity to be garbage collected, but merely removes\n * it from the set of root IDs that will be considered during the next\n * mark-and-sweep collection.\n */\n retain(rootId: string): number;\n release(rootId: string): number;\n\n getFieldValue: FieldValueGetter;\n toReference: ToReferenceFunction;\n canRead: CanReadFunction;\n\n getStorage(\n idOrObj: string | StoreObject,\n ...storeFieldNames: (string | number)[]\n ): StorageType;\n}\n\n/**\n * This is a normalized representation of the Apollo query result cache. It consists of\n * a flattened representation of query result trees.\n */\nexport interface NormalizedCacheObject {\n __META?: {\n // Well-known singleton IDs like ROOT_QUERY and ROOT_MUTATION are\n // always considered to be root IDs during cache.gc garbage\n // collection, but other IDs can become roots if they are written\n // directly with cache.writeFragment or retained explicitly with\n // cache.retain. When such IDs exist, we include them in the __META\n // section so that they can survive cache.{extract,restore}.\n extraRootIds: string[];\n };\n [dataId: string]: StoreObject | undefined;\n}\n\nexport type OptimisticStoreItem = {\n id: string;\n data: NormalizedCacheObject;\n transaction: Transaction<NormalizedCacheObject>;\n};\n\nexport type ReadQueryOptions = {\n /**\n * The Apollo Client store object.\n */\n store: NormalizedCache;\n /**\n * A parsed GraphQL query document.\n */\n query: DocumentNode;\n variables?: Object;\n previousResult?: any;\n canonizeResults?: boolean;\n rootId?: string;\n config?: ApolloReducerConfig;\n};\n\nexport type DiffQueryAgainstStoreOptions = ReadQueryOptions & {\n returnPartialData?: boolean;\n};\n\nexport type ApolloReducerConfig = {\n dataIdFromObject?: KeyFieldsFunction;\n addTypename?: boolean;\n};\n\nexport interface InMemoryCacheConfig extends ApolloReducerConfig {\n resultCaching?: boolean;\n possibleTypes?: PossibleTypesMap;\n typePolicies?: TypePolicies;\n resultCacheMaxSize?: number;\n canonizeResults?: boolean;\n fragments?: FragmentRegistryAPI;\n}\n\nexport interface MergeInfo {\n field: FieldNode;\n typename: string | undefined;\n merge: FieldMergeFunction;\n}\n\nexport interface MergeTree {\n info?: MergeInfo;\n map: Map<string | number, MergeTree>;\n}\n\nexport interface ReadMergeModifyContext {\n store: NormalizedCache;\n variables?: Record<string, any>;\n // A JSON.stringify-serialized version of context.variables.\n varString?: string;\n}\n"]}
@@ -7,18 +7,23 @@ import { getFragmentFromSelection, getDefaultValues, getOperationDefinition, get
7
7
  import { isArray, makeProcessedFieldsMerger, fieldNameFromStoreName, storeValueIsStoreObject, extractFragmentContext, } from "./helpers.js";
8
8
  import { canonicalStringify } from "./object-canon.js";
9
9
  import { normalizeReadFieldOptions } from "./policies.js";
10
+ // Since there are only four possible combinations of context.clientOnly and
11
+ // context.deferred values, we should need at most four "flavors" of any given
12
+ // WriteContext. To avoid creating multiple copies of the same context, we cache
13
+ // the contexts in the context.flavors Map (shared by all flavors) according to
14
+ // their clientOnly and deferred values (always in that order).
10
15
  function getContextFlavor(context, clientOnly, deferred) {
11
16
  var key = "".concat(clientOnly).concat(deferred);
12
17
  var flavored = context.flavors.get(key);
13
18
  if (!flavored) {
14
19
  context.flavors.set(key, (flavored =
15
- context.clientOnly === clientOnly && context.deferred === deferred
16
- ? context
20
+ context.clientOnly === clientOnly && context.deferred === deferred ?
21
+ context
17
22
  : __assign(__assign({}, context), { clientOnly: clientOnly, deferred: deferred })));
18
23
  }
19
24
  return flavored;
20
25
  }
21
- var StoreWriter = (function () {
26
+ var StoreWriter = /** @class */ (function () {
22
27
  function StoreWriter(cache, reader, fragments) {
23
28
  this.cache = cache;
24
29
  this.reader = reader;
@@ -43,14 +48,21 @@ var StoreWriter = (function () {
43
48
  if (!isReference(ref)) {
44
49
  throw newInvariantError(11, result);
45
50
  }
51
+ // So far, the store has not been modified, so now it's time to process
52
+ // context.incomingById and merge those incoming fields into context.store.
46
53
  context.incomingById.forEach(function (_a, dataId) {
47
54
  var storeObject = _a.storeObject, mergeTree = _a.mergeTree, fieldNodeSet = _a.fieldNodeSet;
48
55
  var entityRef = makeReference(dataId);
49
56
  if (mergeTree && mergeTree.map.size) {
50
57
  var applied = _this.applyMerges(mergeTree, entityRef, storeObject, context);
51
58
  if (isReference(applied)) {
59
+ // Assume References returned by applyMerges have already been merged
60
+ // into the store. See makeMergeObjectsFunction in policies.ts for an
61
+ // example of how this can happen.
52
62
  return;
53
63
  }
64
+ // Otherwise, applyMerges returned a StoreObject, whose fields we should
65
+ // merge into the store (see store.merge statement below).
54
66
  storeObject = applied;
55
67
  }
56
68
  if (globalThis.__DEV__ !== false && !context.overwrite) {
@@ -69,6 +81,10 @@ var StoreWriter = (function () {
69
81
  return Boolean(childTree && childTree.info && childTree.info.merge);
70
82
  };
71
83
  Object.keys(storeObject).forEach(function (storeFieldName) {
84
+ // If a merge function was defined for this field, trust that it
85
+ // did the right thing about (not) clobbering data. If the field
86
+ // has no selection set, it's a scalar field, so it doesn't need
87
+ // a merge function (even if it's an object, like JSON data).
72
88
  if (hasSelectionSet_1(storeFieldName) &&
73
89
  !hasMergeFunction_1(storeFieldName)) {
74
90
  warnAboutDataLoss(entityRef, storeObject, storeFieldName, context.store);
@@ -77,20 +93,41 @@ var StoreWriter = (function () {
77
93
  }
78
94
  store.merge(dataId, storeObject);
79
95
  });
96
+ // Any IDs written explicitly to the cache will be retained as
97
+ // reachable root IDs for garbage collection purposes. Although this
98
+ // logic includes root IDs like ROOT_QUERY and ROOT_MUTATION, their
99
+ // retainment counts are effectively ignored because cache.gc() always
100
+ // includes them in its root ID set.
80
101
  store.retain(ref.__ref);
81
102
  return ref;
82
103
  };
83
104
  StoreWriter.prototype.processSelectionSet = function (_a) {
84
105
  var _this = this;
85
- var dataId = _a.dataId, result = _a.result, selectionSet = _a.selectionSet, context = _a.context, mergeTree = _a.mergeTree;
106
+ var dataId = _a.dataId, result = _a.result, selectionSet = _a.selectionSet, context = _a.context,
107
+ // This object allows processSelectionSet to report useful information
108
+ // to its callers without explicitly returning that information.
109
+ mergeTree = _a.mergeTree;
86
110
  var policies = this.cache.policies;
111
+ // This variable will be repeatedly updated using context.merge to
112
+ // accumulate all fields that need to be written into the store.
87
113
  var incoming = Object.create(null);
114
+ // If typename was not passed in, infer it. Note that typename is
115
+ // always passed in for tricky-to-infer cases such as "Query" for
116
+ // ROOT_QUERY.
88
117
  var typename = (dataId && policies.rootTypenamesById[dataId]) ||
89
118
  getTypenameFromResult(result, selectionSet, context.fragmentMap) ||
90
119
  (dataId && context.store.get(dataId, "__typename"));
91
120
  if ("string" === typeof typename) {
92
121
  incoming.__typename = typename;
93
122
  }
123
+ // This readField function will be passed as context.readField in the
124
+ // KeyFieldsContext object created within policies.identify (called below).
125
+ // In addition to reading from the existing context.store (thanks to the
126
+ // policies.readField(options, context) line at the very bottom), this
127
+ // version of readField can read from Reference objects that are currently
128
+ // pending in context.incomingById, which is important whenever keyFields
129
+ // need to be extracted from a child object that processSelectionSet has
130
+ // turned into a Reference.
94
131
  var readField = function () {
95
132
  var options = normalizeReadFieldOptions(arguments, incoming, context.variables);
96
133
  if (isReference(options.from)) {
@@ -105,7 +142,11 @@ var StoreWriter = (function () {
105
142
  return policies.readField(options, context);
106
143
  };
107
144
  var fieldNodeSet = new Set();
108
- this.flattenFields(selectionSet, result, context, typename).forEach(function (context, field) {
145
+ this.flattenFields(selectionSet, result,
146
+ // This WriteContext will be the default context value for fields returned
147
+ // by the flattenFields method, but some fields may be assigned a modified
148
+ // context, depending on the presence of @client and other directives.
149
+ context, typename).forEach(function (context, field) {
109
150
  var _a;
110
151
  var resultFieldKey = resultKeyNameFromField(field);
111
152
  var value = result[resultFieldKey];
@@ -118,10 +159,18 @@ var StoreWriter = (function () {
118
159
  variables: context.variables,
119
160
  });
120
161
  var childTree = getChildMergeTree(mergeTree, storeFieldName);
121
- var incomingValue = _this.processFieldValue(value, field, field.selectionSet
122
- ? getContextFlavor(context, false, false)
162
+ var incomingValue = _this.processFieldValue(value, field,
163
+ // Reset context.clientOnly and context.deferred to their default
164
+ // values before processing nested selection sets.
165
+ field.selectionSet ?
166
+ getContextFlavor(context, false, false)
123
167
  : context, childTree);
168
+ // To determine if this field holds a child object with a merge function
169
+ // defined in its type policy (see PR #7070), we need to figure out the
170
+ // child object's __typename.
124
171
  var childTypename = void 0;
172
+ // The field's value can be an object that has a __typename only if the
173
+ // field has a selection set. Otherwise incomingValue is scalar.
125
174
  if (field.selectionSet &&
126
175
  (isReference(incomingValue) || storeValueIsStoreObject(incomingValue))) {
127
176
  childTypename = readField("__typename", incomingValue);
@@ -129,6 +178,7 @@ var StoreWriter = (function () {
129
178
  var merge = policies.getMergeFunction(typename, field.name.value, childTypename);
130
179
  if (merge) {
131
180
  childTree.info = {
181
+ // TODO Check compatibility against any existing childTree.field?
132
182
  field: field,
133
183
  typename: typename,
134
184
  merge: merge,
@@ -145,10 +195,15 @@ var StoreWriter = (function () {
145
195
  !context.clientOnly &&
146
196
  !context.deferred &&
147
197
  !addTypenameToDocument.added(field) &&
198
+ // If the field has a read function, it may be a synthetic field or
199
+ // provide a default value, so its absence from the written data should
200
+ // not be cause for alarm.
148
201
  !policies.getReadFunction(typename, field.name.value)) {
149
202
  globalThis.__DEV__ !== false && invariant.error(12, resultKeyNameFromField(field), result);
150
203
  }
151
204
  });
205
+ // Identify the result object, even if dataId was already provided,
206
+ // since we always need keyObject below.
152
207
  try {
153
208
  var _b = policies.identify(result, {
154
209
  typename: typename,
@@ -157,21 +212,37 @@ var StoreWriter = (function () {
157
212
  storeObject: incoming,
158
213
  readField: readField,
159
214
  }), id = _b[0], keyObject = _b[1];
215
+ // If dataId was not provided, fall back to the id just generated by
216
+ // policies.identify.
160
217
  dataId = dataId || id;
218
+ // Write any key fields that were used during identification, even if
219
+ // they were not mentioned in the original query.
161
220
  if (keyObject) {
221
+ // TODO Reverse the order of the arguments?
162
222
  incoming = context.merge(incoming, keyObject);
163
223
  }
164
224
  }
165
225
  catch (e) {
226
+ // If dataId was provided, tolerate failure of policies.identify.
166
227
  if (!dataId)
167
228
  throw e;
168
229
  }
169
230
  if ("string" === typeof dataId) {
170
231
  var dataRef = makeReference(dataId);
232
+ // Avoid processing the same entity object using the same selection
233
+ // set more than once. We use an array instead of a Set since most
234
+ // entity IDs will be written using only one selection set, so the
235
+ // size of this array is likely to be very small, meaning indexOf is
236
+ // likely to be faster than Set.prototype.has.
171
237
  var sets = context.written[dataId] || (context.written[dataId] = []);
172
238
  if (sets.indexOf(selectionSet) >= 0)
173
239
  return dataRef;
174
240
  sets.push(selectionSet);
241
+ // If we're about to write a result object into the store, but we
242
+ // happen to know that the exact same (===) result object would be
243
+ // returned if we were to reread the result with the same inputs,
244
+ // then we can skip the rest of the processSelectionSet work for
245
+ // this object, and immediately return a Reference to it.
175
246
  if (this.reader &&
176
247
  this.reader.isFresh(result, dataRef, selectionSet, context)) {
177
248
  return dataRef;
@@ -185,6 +256,9 @@ var StoreWriter = (function () {
185
256
  else {
186
257
  context.incomingById.set(dataId, {
187
258
  storeObject: incoming,
259
+ // Save a reference to mergeTree only if it is not empty, because
260
+ // empty MergeTrees may be recycled by maybeRecycleChildMergeTree and
261
+ // reused for entirely different parts of the result tree.
188
262
  mergeTree: mergeTreeIsEmpty(mergeTree) ? void 0 : mergeTree,
189
263
  fieldNodeSet: fieldNodeSet,
190
264
  });
@@ -196,6 +270,9 @@ var StoreWriter = (function () {
196
270
  StoreWriter.prototype.processFieldValue = function (value, field, context, mergeTree) {
197
271
  var _this = this;
198
272
  if (!field.selectionSet || value === null) {
273
+ // In development, we need to clone scalar values so that they can be
274
+ // safely frozen with maybeDeepFreeze in readFromStore.ts. In production,
275
+ // it's cheaper to store the scalar values directly in the cache.
199
276
  return globalThis.__DEV__ !== false ? cloneDeep(value) : value;
200
277
  }
201
278
  if (isArray(value)) {
@@ -212,13 +289,20 @@ var StoreWriter = (function () {
212
289
  mergeTree: mergeTree,
213
290
  });
214
291
  };
292
+ // Implements https://spec.graphql.org/draft/#sec-Field-Collection, but with
293
+ // some additions for tracking @client and @defer directives.
215
294
  StoreWriter.prototype.flattenFields = function (selectionSet, result, context, typename) {
216
295
  if (typename === void 0) { typename = getTypenameFromResult(result, selectionSet, context.fragmentMap); }
217
296
  var fieldMap = new Map();
218
297
  var policies = this.cache.policies;
219
- var limitingTrie = new Trie(false);
298
+ var limitingTrie = new Trie(false); // No need for WeakMap, since limitingTrie does not escape.
220
299
  (function flatten(selectionSet, inheritedContext) {
221
- var visitedNode = limitingTrie.lookup(selectionSet, inheritedContext.clientOnly, inheritedContext.deferred);
300
+ var visitedNode = limitingTrie.lookup(selectionSet,
301
+ // Because we take inheritedClientOnly and inheritedDeferred into
302
+ // consideration here (in addition to selectionSet), it's possible for
303
+ // the same selection set to be flattened more than once, if it appears
304
+ // in the query with different @client and/or @directive configurations.
305
+ inheritedContext.clientOnly, inheritedContext.deferred);
222
306
  if (visitedNode.visited)
223
307
  return;
224
308
  visitedNode.visited = true;
@@ -226,7 +310,11 @@ var StoreWriter = (function () {
226
310
  if (!shouldInclude(selection, context.variables))
227
311
  return;
228
312
  var clientOnly = inheritedContext.clientOnly, deferred = inheritedContext.deferred;
229
- if (!(clientOnly && deferred) &&
313
+ if (
314
+ // Since the presence of @client or @defer on this field can only
315
+ // cause clientOnly or deferred to become true, we can skip the
316
+ // forEach loop if both clientOnly and deferred are already true.
317
+ !(clientOnly && deferred) &&
230
318
  isNonEmptyArray(selection.directives)) {
231
319
  selection.directives.forEach(function (dir) {
232
320
  var name = dir.name.value;
@@ -234,15 +322,24 @@ var StoreWriter = (function () {
234
322
  clientOnly = true;
235
323
  if (name === "defer") {
236
324
  var args = argumentsObjectFromField(dir, context.variables);
325
+ // The @defer directive takes an optional args.if boolean
326
+ // argument, similar to @include(if: boolean). Note that
327
+ // @defer(if: false) does not make context.deferred false, but
328
+ // instead behaves as if there was no @defer directive.
237
329
  if (!args || args.if !== false) {
238
330
  deferred = true;
239
331
  }
332
+ // TODO In the future, we may want to record args.label using
333
+ // context.deferred, if a label is specified.
240
334
  }
241
335
  });
242
336
  }
243
337
  if (isField(selection)) {
244
338
  var existing = fieldMap.get(selection);
245
339
  if (existing) {
340
+ // If this field has been visited along another recursive path
341
+ // before, the final context should have clientOnly or deferred set
342
+ // to true only if *all* paths have the directive (hence the &&).
246
343
  clientOnly = clientOnly && existing.clientOnly;
247
344
  deferred = deferred && existing.deferred;
248
345
  }
@@ -266,25 +363,45 @@ var StoreWriter = (function () {
266
363
  var _a;
267
364
  var _this = this;
268
365
  if (mergeTree.map.size && !isReference(incoming)) {
269
- var e_1 = !isArray(incoming) &&
270
- (isReference(existing) || storeValueIsStoreObject(existing))
271
- ? existing
366
+ var e_1 =
367
+ // Items in the same position in different arrays are not
368
+ // necessarily related to each other, so when incoming is an array
369
+ // we process its elements as if there was no existing data.
370
+ (!isArray(incoming) &&
371
+ // Likewise, existing must be either a Reference or a StoreObject
372
+ // in order for its fields to be safe to merge with the fields of
373
+ // the incoming object.
374
+ (isReference(existing) || storeValueIsStoreObject(existing))) ?
375
+ existing
272
376
  : void 0;
377
+ // This narrowing is implied by mergeTree.map.size > 0 and
378
+ // !isReference(incoming), though TypeScript understandably cannot
379
+ // hope to infer this type.
273
380
  var i_1 = incoming;
381
+ // The options.storage objects provided to read and merge functions
382
+ // are derived from the identity of the parent object plus a
383
+ // sequence of storeFieldName strings/numbers identifying the nested
384
+ // field name path of each field value to be merged.
274
385
  if (e_1 && !getStorageArgs) {
275
386
  getStorageArgs = [isReference(e_1) ? e_1.__ref : e_1];
276
387
  }
388
+ // It's possible that applying merge functions to this subtree will
389
+ // not change the incoming data, so this variable tracks the fields
390
+ // that did change, so we can create a new incoming object when (and
391
+ // only when) at least one incoming field has changed. We use a Map
392
+ // to preserve the type of numeric keys.
277
393
  var changedFields_1;
278
394
  var getValue_1 = function (from, name) {
279
- return isArray(from)
280
- ? typeof name === "number"
281
- ? from[name]
395
+ return (isArray(from) ?
396
+ typeof name === "number" ?
397
+ from[name]
282
398
  : void 0
283
- : context.store.getFieldValue(from, String(name));
399
+ : context.store.getFieldValue(from, String(name)));
284
400
  };
285
401
  mergeTree.map.forEach(function (childTree, storeFieldName) {
286
402
  var eVal = getValue_1(e_1, storeFieldName);
287
403
  var iVal = getValue_1(i_1, storeFieldName);
404
+ // If we have no incoming data, leave any existing data untouched.
288
405
  if (void 0 === iVal)
289
406
  return;
290
407
  if (getStorageArgs) {
@@ -300,6 +417,7 @@ var StoreWriter = (function () {
300
417
  }
301
418
  });
302
419
  if (changedFields_1) {
420
+ // Shallow clone i so we can add changed fields to it.
303
421
  incoming = (isArray(i_1) ? i_1.slice(0) : __assign({}, i_1));
304
422
  changedFields_1.forEach(function (value, name) {
305
423
  incoming[name] = value;
@@ -327,13 +445,10 @@ function mergeMergeTrees(left, right) {
327
445
  return left;
328
446
  if (!left || mergeTreeIsEmpty(left))
329
447
  return right;
330
- var info = left.info && right.info
331
- ? __assign(__assign({}, left.info), right.info) : left.info || right.info;
448
+ var info = left.info && right.info ? __assign(__assign({}, left.info), right.info) : left.info || right.info;
332
449
  var needToMergeMaps = left.map.size && right.map.size;
333
- var map = needToMergeMaps
334
- ? new Map()
335
- : left.map.size
336
- ? left.map
450
+ var map = needToMergeMaps ? new Map()
451
+ : left.map.size ? left.map
337
452
  : right.map;
338
453
  var merged = { info: info, map: map };
339
454
  if (needToMergeMaps) {
@@ -360,6 +475,8 @@ function maybeRecycleChildMergeTree(_a, name) {
360
475
  }
361
476
  }
362
477
  var warnings = new Set();
478
+ // Note that this function is unused in production, and thus should be
479
+ // pruned by any well-configured minifier.
363
480
  function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
364
481
  var getChild = function (objOrRef) {
365
482
  var child = store.getFieldValue(objOrRef, storeFieldName);
@@ -371,10 +488,17 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
371
488
  var incoming = getChild(incomingObj);
372
489
  if (!incoming)
373
490
  return;
491
+ // It's always safe to replace a reference, since it refers to data
492
+ // safely stored elsewhere.
374
493
  if (isReference(existing))
375
494
  return;
495
+ // If the values are structurally equivalent, we do not need to worry
496
+ // about incoming replacing existing.
376
497
  if (equal(existing, incoming))
377
498
  return;
499
+ // If we're replacing every key of the existing object, then the
500
+ // existing data would be overwritten even if the objects were
501
+ // normalized, so warning would not be helpful here.
378
502
  if (Object.keys(existing).every(function (key) { return store.getFieldValue(incoming, key) !== void 0; })) {
379
503
  return;
380
504
  }
@@ -382,10 +506,13 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
382
506
  store.getFieldValue(incomingObj, "__typename");
383
507
  var fieldName = fieldNameFromStoreName(storeFieldName);
384
508
  var typeDotName = "".concat(parentType, ".").concat(fieldName);
509
+ // Avoid warning more than once for the same type and field name.
385
510
  if (warnings.has(typeDotName))
386
511
  return;
387
512
  warnings.add(typeDotName);
388
513
  var childTypenames = [];
514
+ // Arrays do not have __typename fields, and always need a custom merge
515
+ // function, even if their elements are normalized entities.
389
516
  if (!isArray(existing) && !isArray(incoming)) {
390
517
  [existing, incoming].forEach(function (child) {
391
518
  var typename = store.getFieldValue(child, "__typename");
@@ -394,8 +521,8 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
394
521
  }
395
522
  });
396
523
  }
397
- globalThis.__DEV__ !== false && invariant.warn(14, fieldName, parentType, childTypenames.length
398
- ? "either ensure all objects of type " +
524
+ globalThis.__DEV__ !== false && invariant.warn(14, fieldName, parentType, childTypenames.length ?
525
+ "either ensure all objects of type " +
399
526
  childTypenames.join(" and ") +
400
527
  " have an ID or a custom merge function, or "
401
528
  : "", typeDotName, existing, incoming);