@apollo/client 3.8.0-alpha.9 → 3.8.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (582) hide show
  1. package/apollo-client.cjs +1030 -673
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +35 -31
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/cache.cjs.native.js +35 -31
  7. package/cache/core/cache.d.ts +5 -4
  8. package/cache/core/cache.d.ts.map +1 -1
  9. package/cache/core/cache.js +1 -0
  10. package/cache/core/cache.js.map +1 -1
  11. package/cache/core/types/Cache.d.ts +2 -2
  12. package/cache/core/types/Cache.d.ts.map +1 -1
  13. package/cache/core/types/Cache.js.map +1 -1
  14. package/cache/core/types/DataProxy.d.ts +4 -4
  15. package/cache/core/types/DataProxy.d.ts.map +1 -1
  16. package/cache/core/types/DataProxy.js.map +1 -1
  17. package/cache/core/types/common.d.ts +3 -3
  18. package/cache/core/types/common.d.ts.map +1 -1
  19. package/cache/core/types/common.js.map +1 -1
  20. package/cache/inmemory/entityStore.d.ts +5 -5
  21. package/cache/inmemory/entityStore.d.ts.map +1 -1
  22. package/cache/inmemory/entityStore.js +2 -2
  23. package/cache/inmemory/entityStore.js.map +1 -1
  24. package/cache/inmemory/fragmentRegistry.d.ts +1 -1
  25. package/cache/inmemory/fragmentRegistry.d.ts.map +1 -1
  26. package/cache/inmemory/fragmentRegistry.js.map +1 -1
  27. package/cache/inmemory/helpers.d.ts +6 -5
  28. package/cache/inmemory/helpers.d.ts.map +1 -1
  29. package/cache/inmemory/helpers.js.map +1 -1
  30. package/cache/inmemory/inMemoryCache.d.ts +9 -7
  31. package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
  32. package/cache/inmemory/inMemoryCache.js +14 -15
  33. package/cache/inmemory/inMemoryCache.js.map +1 -1
  34. package/cache/inmemory/key-extractor.d.ts +1 -1
  35. package/cache/inmemory/key-extractor.d.ts.map +1 -1
  36. package/cache/inmemory/key-extractor.js +2 -2
  37. package/cache/inmemory/key-extractor.js.map +1 -1
  38. package/cache/inmemory/policies.d.ts +7 -6
  39. package/cache/inmemory/policies.d.ts.map +1 -1
  40. package/cache/inmemory/policies.js +6 -6
  41. package/cache/inmemory/policies.js.map +1 -1
  42. package/cache/inmemory/reactiveVars.d.ts +1 -1
  43. package/cache/inmemory/reactiveVars.d.ts.map +1 -1
  44. package/cache/inmemory/reactiveVars.js.map +1 -1
  45. package/cache/inmemory/readFromStore.d.ts +6 -6
  46. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  47. package/cache/inmemory/readFromStore.js +10 -5
  48. package/cache/inmemory/readFromStore.js.map +1 -1
  49. package/cache/inmemory/types.d.ts +6 -6
  50. package/cache/inmemory/types.d.ts.map +1 -1
  51. package/cache/inmemory/types.js.map +1 -1
  52. package/cache/inmemory/writeToStore.d.ts +6 -6
  53. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  54. package/cache/inmemory/writeToStore.js +7 -8
  55. package/cache/inmemory/writeToStore.js.map +1 -1
  56. package/config/jest/setup.d.ts +1 -0
  57. package/config/jest/setup.d.ts.map +1 -1
  58. package/config/jest/setup.js +3 -0
  59. package/config/jest/setup.js.map +1 -1
  60. package/core/ApolloClient.d.ts +13 -10
  61. package/core/ApolloClient.d.ts.map +1 -1
  62. package/core/ApolloClient.js +18 -16
  63. package/core/ApolloClient.js.map +1 -1
  64. package/core/DocumentTransform.d.ts +24 -0
  65. package/core/DocumentTransform.d.ts.map +1 -0
  66. package/core/DocumentTransform.js +68 -0
  67. package/core/DocumentTransform.js.map +1 -0
  68. package/core/LocalState.d.ts +7 -9
  69. package/core/LocalState.d.ts.map +1 -1
  70. package/core/LocalState.js +6 -10
  71. package/core/LocalState.js.map +1 -1
  72. package/core/ObservableQuery.d.ts +11 -8
  73. package/core/ObservableQuery.d.ts.map +1 -1
  74. package/core/ObservableQuery.js +48 -28
  75. package/core/ObservableQuery.js.map +1 -1
  76. package/core/QueryInfo.d.ts +9 -9
  77. package/core/QueryInfo.d.ts.map +1 -1
  78. package/core/QueryInfo.js.map +1 -1
  79. package/core/QueryManager.d.ts +15 -11
  80. package/core/QueryManager.d.ts.map +1 -1
  81. package/core/QueryManager.js +115 -108
  82. package/core/QueryManager.js.map +1 -1
  83. package/core/core.cjs +332 -172
  84. package/core/core.cjs.map +1 -1
  85. package/core/core.cjs.native.js +332 -172
  86. package/core/equalByQuery.d.ts +4 -0
  87. package/core/equalByQuery.d.ts.map +1 -0
  88. package/{react/hooks/compareResults.js → core/equalByQuery.js} +14 -10
  89. package/core/equalByQuery.js.map +1 -0
  90. package/core/index.d.ts +2 -1
  91. package/core/index.d.ts.map +1 -1
  92. package/core/index.js +2 -1
  93. package/core/index.js.map +1 -1
  94. package/core/networkStatus.d.ts +1 -0
  95. package/core/networkStatus.d.ts.map +1 -1
  96. package/core/networkStatus.js +3 -0
  97. package/core/networkStatus.js.map +1 -1
  98. package/core/types.d.ts +14 -14
  99. package/core/types.d.ts.map +1 -1
  100. package/core/types.js.map +1 -1
  101. package/core/watchQueryOptions.d.ts +6 -7
  102. package/core/watchQueryOptions.d.ts.map +1 -1
  103. package/core/watchQueryOptions.js.map +1 -1
  104. package/dev/dev.cjs +642 -0
  105. package/dev/dev.cjs.map +1 -0
  106. package/dev/dev.cjs.native.js +642 -0
  107. package/dev/index.d.ts +4 -0
  108. package/dev/index.d.ts.map +1 -0
  109. package/dev/index.js +4 -0
  110. package/dev/index.js.map +1 -0
  111. package/dev/loadDevMessages.d.ts +2 -0
  112. package/dev/loadDevMessages.d.ts.map +1 -0
  113. package/dev/loadDevMessages.js +6 -0
  114. package/dev/loadDevMessages.js.map +1 -0
  115. package/dev/loadErrorMessageHandler.d.ts +3 -0
  116. package/dev/loadErrorMessageHandler.d.ts.map +1 -0
  117. package/dev/loadErrorMessageHandler.js +26 -0
  118. package/dev/loadErrorMessageHandler.js.map +1 -0
  119. package/dev/loadErrorMessages.d.ts +2 -0
  120. package/dev/loadErrorMessages.d.ts.map +1 -0
  121. package/dev/loadErrorMessages.js +6 -0
  122. package/dev/loadErrorMessages.js.map +1 -0
  123. package/dev/package.json +8 -0
  124. package/errors/errors.cjs +17 -17
  125. package/errors/errors.cjs.map +1 -1
  126. package/errors/errors.cjs.native.js +17 -17
  127. package/errors/index.d.ts +26 -10
  128. package/errors/index.d.ts.map +1 -1
  129. package/errors/index.js +17 -19
  130. package/errors/index.js.map +1 -1
  131. package/invariantErrorCodes.d.ts +13 -0
  132. package/invariantErrorCodes.d.ts.map +1 -0
  133. package/invariantErrorCodes.js +331 -144
  134. package/invariantErrorCodes.js.map +1 -0
  135. package/link/batch/batchLink.d.ts +4 -3
  136. package/link/batch/batchLink.d.ts.map +1 -1
  137. package/link/batch/batchLink.js.map +1 -1
  138. package/link/batch/batching.d.ts +1 -1
  139. package/link/batch/batching.d.ts.map +1 -1
  140. package/link/batch/batching.js.map +1 -1
  141. package/link/batch-http/batch-http.cjs +23 -2
  142. package/link/batch-http/batch-http.cjs.map +1 -1
  143. package/link/batch-http/batch-http.cjs.native.js +23 -2
  144. package/link/batch-http/batchHttpLink.d.ts +3 -2
  145. package/link/batch-http/batchHttpLink.d.ts.map +1 -1
  146. package/link/batch-http/batchHttpLink.js +7 -2
  147. package/link/batch-http/batchHttpLink.js.map +1 -1
  148. package/link/context/index.d.ts +3 -2
  149. package/link/context/index.d.ts.map +1 -1
  150. package/link/context/index.js.map +1 -1
  151. package/link/core/ApolloLink.d.ts +3 -2
  152. package/link/core/ApolloLink.d.ts.map +1 -1
  153. package/link/core/ApolloLink.js +3 -13
  154. package/link/core/ApolloLink.js.map +1 -1
  155. package/link/core/core.cjs +2 -12
  156. package/link/core/core.cjs.map +1 -1
  157. package/link/core/core.cjs.native.js +2 -12
  158. package/link/core/types.d.ts +8 -3
  159. package/link/core/types.d.ts.map +1 -1
  160. package/link/core/types.js.map +1 -1
  161. package/link/error/index.d.ts +4 -3
  162. package/link/error/index.d.ts.map +1 -1
  163. package/link/error/index.js.map +1 -1
  164. package/link/http/HttpLink.d.ts +3 -2
  165. package/link/http/HttpLink.d.ts.map +1 -1
  166. package/link/http/HttpLink.js.map +1 -1
  167. package/link/http/checkFetcher.js +2 -2
  168. package/link/http/checkFetcher.js.map +1 -1
  169. package/link/http/createHttpLink.d.ts +1 -1
  170. package/link/http/createHttpLink.d.ts.map +1 -1
  171. package/link/http/createHttpLink.js +21 -20
  172. package/link/http/createHttpLink.js.map +1 -1
  173. package/link/http/http.cjs +73 -43
  174. package/link/http/http.cjs.map +1 -1
  175. package/link/http/http.cjs.native.js +73 -43
  176. package/link/http/iterators/nodeStream.d.ts +1 -1
  177. package/link/http/iterators/nodeStream.d.ts.map +1 -1
  178. package/link/http/iterators/nodeStream.js.map +1 -1
  179. package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
  180. package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
  181. package/link/http/parseAndCheckHttpResponse.js +47 -26
  182. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  183. package/link/http/responseIterator.d.ts +1 -1
  184. package/link/http/responseIterator.d.ts.map +1 -1
  185. package/link/http/responseIterator.js.map +1 -1
  186. package/link/http/rewriteURIForGET.d.ts +1 -1
  187. package/link/http/rewriteURIForGET.d.ts.map +1 -1
  188. package/link/http/rewriteURIForGET.js.map +1 -1
  189. package/link/http/selectHttpOptionsAndBody.d.ts +3 -2
  190. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  191. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  192. package/link/http/selectURI.d.ts +1 -1
  193. package/link/http/selectURI.d.ts.map +1 -1
  194. package/link/http/selectURI.js.map +1 -1
  195. package/link/http/serializeFetchParameter.d.ts +1 -1
  196. package/link/http/serializeFetchParameter.d.ts.map +1 -1
  197. package/link/http/serializeFetchParameter.js +2 -2
  198. package/link/http/serializeFetchParameter.js.map +1 -1
  199. package/link/persisted-queries/index.d.ts +4 -3
  200. package/link/persisted-queries/index.d.ts.map +1 -1
  201. package/link/persisted-queries/index.js +16 -20
  202. package/link/persisted-queries/index.js.map +1 -1
  203. package/link/persisted-queries/persisted-queries.cjs +15 -19
  204. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  205. package/link/persisted-queries/persisted-queries.cjs.native.js +15 -19
  206. package/link/remove-typename/index.d.ts +2 -0
  207. package/link/remove-typename/index.d.ts.map +1 -0
  208. package/link/remove-typename/index.js +2 -0
  209. package/link/remove-typename/index.js.map +1 -0
  210. package/link/remove-typename/package.json +8 -0
  211. package/link/remove-typename/remove-typename.cjs +82 -0
  212. package/link/remove-typename/remove-typename.cjs.map +1 -0
  213. package/link/remove-typename/remove-typename.cjs.native.js +82 -0
  214. package/link/remove-typename/removeTypenameFromVariables.d.ts +11 -0
  215. package/link/remove-typename/removeTypenameFromVariables.d.ts.map +1 -0
  216. package/link/remove-typename/removeTypenameFromVariables.js +74 -0
  217. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -0
  218. package/link/retry/delayFunction.d.ts +1 -1
  219. package/link/retry/delayFunction.d.ts.map +1 -1
  220. package/link/retry/delayFunction.js.map +1 -1
  221. package/link/retry/retryFunction.d.ts +1 -1
  222. package/link/retry/retryFunction.d.ts.map +1 -1
  223. package/link/retry/retryFunction.js.map +1 -1
  224. package/link/retry/retryLink.d.ts +4 -3
  225. package/link/retry/retryLink.d.ts.map +1 -1
  226. package/link/retry/retryLink.js.map +1 -1
  227. package/link/schema/index.d.ts +3 -2
  228. package/link/schema/index.d.ts.map +1 -1
  229. package/link/schema/index.js.map +1 -1
  230. package/link/subscriptions/index.d.ts +2 -1
  231. package/link/subscriptions/index.d.ts.map +1 -1
  232. package/link/subscriptions/index.js +8 -3
  233. package/link/subscriptions/index.js.map +1 -1
  234. package/link/subscriptions/subscriptions.cjs +8 -3
  235. package/link/subscriptions/subscriptions.cjs.map +1 -1
  236. package/link/subscriptions/subscriptions.cjs.native.js +8 -3
  237. package/link/utils/createOperation.d.ts +1 -1
  238. package/link/utils/createOperation.d.ts.map +1 -1
  239. package/link/utils/createOperation.js.map +1 -1
  240. package/link/utils/filterOperationVariables.d.ts +5 -0
  241. package/link/utils/filterOperationVariables.d.ts.map +1 -0
  242. package/link/utils/filterOperationVariables.js +18 -0
  243. package/link/utils/filterOperationVariables.js.map +1 -0
  244. package/link/utils/index.d.ts +1 -0
  245. package/link/utils/index.d.ts.map +1 -1
  246. package/link/utils/index.js +1 -0
  247. package/link/utils/index.js.map +1 -1
  248. package/link/utils/throwServerError.d.ts +1 -1
  249. package/link/utils/throwServerError.d.ts.map +1 -1
  250. package/link/utils/throwServerError.js.map +1 -1
  251. package/link/utils/toPromise.d.ts +1 -1
  252. package/link/utils/toPromise.d.ts.map +1 -1
  253. package/link/utils/toPromise.js +1 -1
  254. package/link/utils/toPromise.js.map +1 -1
  255. package/link/utils/transformOperation.d.ts +1 -1
  256. package/link/utils/transformOperation.d.ts.map +1 -1
  257. package/link/utils/transformOperation.js.map +1 -1
  258. package/link/utils/utils.cjs +20 -2
  259. package/link/utils/utils.cjs.map +1 -1
  260. package/link/utils/utils.cjs.native.js +20 -2
  261. package/link/utils/validateOperation.d.ts +1 -1
  262. package/link/utils/validateOperation.d.ts.map +1 -1
  263. package/link/utils/validateOperation.js +2 -2
  264. package/link/utils/validateOperation.js.map +1 -1
  265. package/link/ws/index.d.ts +5 -3
  266. package/link/ws/index.d.ts.map +1 -1
  267. package/link/ws/index.js.map +1 -1
  268. package/package.json +36 -32
  269. package/react/cache/QueryReference.d.ts +34 -0
  270. package/react/cache/QueryReference.d.ts.map +1 -0
  271. package/react/cache/QueryReference.js +107 -0
  272. package/react/cache/QueryReference.js.map +1 -0
  273. package/react/cache/SuspenseCache.d.ts +10 -13
  274. package/react/cache/SuspenseCache.d.ts.map +1 -1
  275. package/react/cache/SuspenseCache.js +18 -41
  276. package/react/cache/SuspenseCache.js.map +1 -1
  277. package/react/cache/types.d.ts +2 -0
  278. package/react/cache/types.d.ts.map +1 -0
  279. package/react/cache/types.js +2 -0
  280. package/react/cache/types.js.map +1 -0
  281. package/react/components/Mutation.d.ts +2 -2
  282. package/react/components/Mutation.d.ts.map +1 -1
  283. package/react/components/Mutation.js.map +1 -1
  284. package/react/components/Query.d.ts +2 -2
  285. package/react/components/Query.d.ts.map +1 -1
  286. package/react/components/Query.js.map +1 -1
  287. package/react/components/Subscription.d.ts +2 -2
  288. package/react/components/Subscription.d.ts.map +1 -1
  289. package/react/components/Subscription.js.map +1 -1
  290. package/react/components/types.d.ts +4 -4
  291. package/react/components/types.d.ts.map +1 -1
  292. package/react/components/types.js.map +1 -1
  293. package/react/context/ApolloConsumer.d.ts +1 -1
  294. package/react/context/ApolloConsumer.d.ts.map +1 -1
  295. package/react/context/ApolloConsumer.js +2 -3
  296. package/react/context/ApolloConsumer.js.map +1 -1
  297. package/react/context/ApolloContext.d.ts +10 -3
  298. package/react/context/ApolloContext.d.ts.map +1 -1
  299. package/react/context/ApolloContext.js +10 -8
  300. package/react/context/ApolloContext.js.map +1 -1
  301. package/react/context/ApolloProvider.d.ts +2 -2
  302. package/react/context/ApolloProvider.d.ts.map +1 -1
  303. package/react/context/ApolloProvider.js +8 -13
  304. package/react/context/ApolloProvider.js.map +1 -1
  305. package/react/context/context.cjs +18 -22
  306. package/react/context/context.cjs.map +1 -1
  307. package/react/context/context.cjs.native.js +18 -22
  308. package/react/context/index.d.ts +1 -1
  309. package/react/context/index.d.ts.map +1 -1
  310. package/react/context/index.js +1 -1
  311. package/react/context/index.js.map +1 -1
  312. package/react/hoc/graphql.d.ts +3 -3
  313. package/react/hoc/graphql.d.ts.map +1 -1
  314. package/react/hoc/graphql.js.map +1 -1
  315. package/react/hoc/hoc-utils.d.ts +2 -2
  316. package/react/hoc/hoc-utils.d.ts.map +1 -1
  317. package/react/hoc/hoc-utils.js +2 -3
  318. package/react/hoc/hoc-utils.js.map +1 -1
  319. package/react/hoc/hoc.cjs +2 -4
  320. package/react/hoc/hoc.cjs.map +1 -1
  321. package/react/hoc/hoc.cjs.native.js +2 -4
  322. package/react/hoc/mutation-hoc.d.ts +4 -4
  323. package/react/hoc/mutation-hoc.d.ts.map +1 -1
  324. package/react/hoc/mutation-hoc.js.map +1 -1
  325. package/react/hoc/query-hoc.d.ts +2 -2
  326. package/react/hoc/query-hoc.d.ts.map +1 -1
  327. package/react/hoc/query-hoc.js.map +1 -1
  328. package/react/hoc/subscription-hoc.d.ts +2 -2
  329. package/react/hoc/subscription-hoc.d.ts.map +1 -1
  330. package/react/hoc/subscription-hoc.js.map +1 -1
  331. package/react/hoc/types.d.ts +4 -4
  332. package/react/hoc/types.d.ts.map +1 -1
  333. package/react/hoc/types.js.map +1 -1
  334. package/react/hoc/withApollo.d.ts +1 -1
  335. package/react/hoc/withApollo.d.ts.map +1 -1
  336. package/react/hoc/withApollo.js +2 -3
  337. package/react/hoc/withApollo.js.map +1 -1
  338. package/react/hooks/hooks.cjs +223 -219
  339. package/react/hooks/hooks.cjs.map +1 -1
  340. package/react/hooks/hooks.cjs.native.js +223 -219
  341. package/react/hooks/index.d.ts +2 -1
  342. package/react/hooks/index.d.ts.map +1 -1
  343. package/react/hooks/index.js +2 -1
  344. package/react/hooks/index.js.map +1 -1
  345. package/react/hooks/internal/__use.d.ts +4 -0
  346. package/react/hooks/internal/__use.d.ts.map +1 -0
  347. package/react/hooks/internal/__use.js +17 -0
  348. package/react/hooks/internal/__use.js.map +1 -0
  349. package/react/hooks/internal/index.d.ts +2 -0
  350. package/react/hooks/internal/index.d.ts.map +1 -1
  351. package/react/hooks/internal/index.js +2 -0
  352. package/react/hooks/internal/index.js.map +1 -1
  353. package/react/hooks/internal/useDeepMemo.d.ts +1 -1
  354. package/react/hooks/internal/useDeepMemo.d.ts.map +1 -1
  355. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  356. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -1
  357. package/react/hooks/internal/useIsomorphicLayoutEffect.js +2 -2
  358. package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
  359. package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts +2 -0
  360. package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts.map +1 -0
  361. package/react/hooks/internal/useStrictModeSafeCleanupEffect.js +11 -0
  362. package/react/hooks/internal/useStrictModeSafeCleanupEffect.js.map +1 -0
  363. package/react/hooks/useApolloClient.d.ts +1 -1
  364. package/react/hooks/useApolloClient.d.ts.map +1 -1
  365. package/react/hooks/useApolloClient.js +2 -4
  366. package/react/hooks/useApolloClient.js.map +1 -1
  367. package/react/hooks/useBackgroundQuery.d.ts +18 -0
  368. package/react/hooks/useBackgroundQuery.d.ts.map +1 -0
  369. package/react/hooks/useBackgroundQuery.js +69 -0
  370. package/react/hooks/useBackgroundQuery.js.map +1 -0
  371. package/react/hooks/useFragment.d.ts +14 -9
  372. package/react/hooks/useFragment.d.ts.map +1 -1
  373. package/react/hooks/useFragment.js +2 -2
  374. package/react/hooks/useFragment.js.map +1 -1
  375. package/react/hooks/useLazyQuery.d.ts +4 -4
  376. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  377. package/react/hooks/useLazyQuery.js +13 -22
  378. package/react/hooks/useLazyQuery.js.map +1 -1
  379. package/react/hooks/useMutation.d.ts +4 -4
  380. package/react/hooks/useMutation.d.ts.map +1 -1
  381. package/react/hooks/useMutation.js +1 -1
  382. package/react/hooks/useMutation.js.map +1 -1
  383. package/react/hooks/useQuery.d.ts +6 -6
  384. package/react/hooks/useQuery.d.ts.map +1 -1
  385. package/react/hooks/useQuery.js +29 -28
  386. package/react/hooks/useQuery.js.map +1 -1
  387. package/react/hooks/useReactiveVar.d.ts +1 -1
  388. package/react/hooks/useReactiveVar.d.ts.map +1 -1
  389. package/react/hooks/useReactiveVar.js.map +1 -1
  390. package/react/hooks/useSubscription.d.ts +4 -4
  391. package/react/hooks/useSubscription.d.ts.map +1 -1
  392. package/react/hooks/useSubscription.js +27 -19
  393. package/react/hooks/useSubscription.js.map +1 -1
  394. package/react/hooks/useSuspenseCache.d.ts +1 -1
  395. package/react/hooks/useSuspenseCache.d.ts.map +1 -1
  396. package/react/hooks/useSuspenseCache.js +2 -4
  397. package/react/hooks/useSuspenseCache.js.map +1 -1
  398. package/react/hooks/useSuspenseQuery.d.ts +39 -7
  399. package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
  400. package/react/hooks/useSuspenseQuery.js +68 -149
  401. package/react/hooks/useSuspenseQuery.js.map +1 -1
  402. package/react/hooks/useSyncExternalStore.js +1 -1
  403. package/react/index.d.ts +1 -1
  404. package/react/index.d.ts.map +1 -1
  405. package/react/index.js +1 -1
  406. package/react/index.js.map +1 -1
  407. package/react/parser/index.d.ts +1 -1
  408. package/react/parser/index.d.ts.map +1 -1
  409. package/react/parser/index.js +20 -17
  410. package/react/parser/index.js.map +1 -1
  411. package/react/parser/parser.cjs +19 -16
  412. package/react/parser/parser.cjs.map +1 -1
  413. package/react/parser/parser.cjs.native.js +19 -16
  414. package/react/react.cjs +116 -35
  415. package/react/react.cjs.map +1 -1
  416. package/react/react.cjs.native.js +116 -35
  417. package/react/ssr/RenderPromises.d.ts +2 -2
  418. package/react/ssr/RenderPromises.d.ts.map +1 -1
  419. package/react/ssr/RenderPromises.js.map +1 -1
  420. package/react/ssr/renderToStringWithData.d.ts +1 -1
  421. package/react/ssr/renderToStringWithData.d.ts.map +1 -1
  422. package/react/ssr/renderToStringWithData.js.map +1 -1
  423. package/react/types/types.d.ts +10 -13
  424. package/react/types/types.d.ts.map +1 -1
  425. package/react/types/types.js.map +1 -1
  426. package/testing/core/core.cjs +1 -1
  427. package/testing/core/core.cjs.map +1 -1
  428. package/testing/core/core.cjs.native.js +1 -1
  429. package/testing/core/mocking/mockClient.d.ts +2 -2
  430. package/testing/core/mocking/mockClient.d.ts.map +1 -1
  431. package/testing/core/mocking/mockClient.js.map +1 -1
  432. package/testing/core/mocking/mockLink.d.ts +2 -1
  433. package/testing/core/mocking/mockLink.d.ts.map +1 -1
  434. package/testing/core/mocking/mockLink.js +3 -3
  435. package/testing/core/mocking/mockLink.js.map +1 -1
  436. package/testing/core/mocking/mockQueryManager.d.ts +1 -1
  437. package/testing/core/mocking/mockQueryManager.d.ts.map +1 -1
  438. package/testing/core/mocking/mockQueryManager.js.map +1 -1
  439. package/testing/core/mocking/mockSubscriptionLink.d.ts +3 -2
  440. package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -1
  441. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  442. package/testing/core/mocking/mockWatchQuery.d.ts +2 -2
  443. package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -1
  444. package/testing/core/mocking/mockWatchQuery.js.map +1 -1
  445. package/testing/core/observableToPromise.d.ts +2 -2
  446. package/testing/core/observableToPromise.d.ts.map +1 -1
  447. package/testing/core/observableToPromise.js.map +1 -1
  448. package/testing/core/subscribeAndCount.d.ts +1 -1
  449. package/testing/core/subscribeAndCount.d.ts.map +1 -1
  450. package/testing/core/subscribeAndCount.js.map +1 -1
  451. package/testing/matchers/index.d.ts +2 -0
  452. package/testing/matchers/index.d.ts.map +1 -0
  453. package/testing/matchers/index.js +6 -0
  454. package/testing/matchers/index.js.map +1 -0
  455. package/testing/matchers/toMatchDocument.d.ts +4 -0
  456. package/testing/matchers/toMatchDocument.d.ts.map +1 -0
  457. package/testing/matchers/toMatchDocument.js +34 -0
  458. package/testing/matchers/toMatchDocument.js.map +1 -0
  459. package/testing/react/MockedProvider.d.ts +8 -7
  460. package/testing/react/MockedProvider.d.ts.map +1 -1
  461. package/testing/react/MockedProvider.js +7 -6
  462. package/testing/react/MockedProvider.js.map +1 -1
  463. package/testing/testing.cjs +7 -51
  464. package/testing/testing.cjs.map +1 -1
  465. package/testing/testing.cjs.native.js +7 -51
  466. package/utilities/common/compact.d.ts +1 -1
  467. package/utilities/common/compact.d.ts.map +1 -1
  468. package/utilities/common/compact.js.map +1 -1
  469. package/utilities/common/errorHandling.d.ts +1 -1
  470. package/utilities/common/errorHandling.d.ts.map +1 -1
  471. package/utilities/common/errorHandling.js.map +1 -1
  472. package/utilities/common/incrementalResult.d.ts +2 -1
  473. package/utilities/common/incrementalResult.d.ts.map +1 -1
  474. package/utilities/common/incrementalResult.js +4 -0
  475. package/utilities/common/incrementalResult.js.map +1 -1
  476. package/utilities/common/mergeOptions.d.ts +1 -1
  477. package/utilities/common/mergeOptions.d.ts.map +1 -1
  478. package/utilities/common/mergeOptions.js +1 -1
  479. package/utilities/common/mergeOptions.js.map +1 -1
  480. package/utilities/common/objects.d.ts +1 -0
  481. package/utilities/common/objects.d.ts.map +1 -1
  482. package/utilities/common/objects.js +6 -0
  483. package/utilities/common/objects.js.map +1 -1
  484. package/utilities/common/omitDeep.d.ts +3 -0
  485. package/utilities/common/omitDeep.d.ts.map +1 -0
  486. package/utilities/common/omitDeep.js +41 -0
  487. package/utilities/common/omitDeep.js.map +1 -0
  488. package/utilities/common/responseIterator.d.ts +2 -2
  489. package/utilities/common/responseIterator.d.ts.map +1 -1
  490. package/utilities/common/responseIterator.js.map +1 -1
  491. package/utilities/common/stringifyForDisplay.d.ts +1 -1
  492. package/utilities/common/stringifyForDisplay.d.ts.map +1 -1
  493. package/utilities/common/stringifyForDisplay.js +3 -2
  494. package/utilities/common/stringifyForDisplay.js.map +1 -1
  495. package/utilities/common/stripTypename.d.ts +2 -0
  496. package/utilities/common/stripTypename.d.ts.map +1 -0
  497. package/utilities/common/stripTypename.js +5 -0
  498. package/utilities/common/stripTypename.js.map +1 -0
  499. package/utilities/globals/global.d.ts +6 -3
  500. package/utilities/globals/global.d.ts.map +1 -1
  501. package/utilities/globals/global.js.map +1 -1
  502. package/utilities/globals/globals.cjs +67 -1
  503. package/utilities/globals/globals.cjs.map +1 -1
  504. package/utilities/globals/globals.cjs.native.js +67 -1
  505. package/utilities/globals/index.d.ts +2 -2
  506. package/utilities/globals/index.d.ts.map +1 -1
  507. package/utilities/globals/index.js +2 -2
  508. package/utilities/globals/index.js.map +1 -1
  509. package/utilities/globals/invariantWrappers.d.ts +24 -0
  510. package/utilities/globals/invariantWrappers.d.ts.map +1 -0
  511. package/utilities/globals/invariantWrappers.js +53 -0
  512. package/utilities/globals/invariantWrappers.js.map +1 -0
  513. package/utilities/graphql/directives.d.ts +1 -1
  514. package/utilities/graphql/directives.d.ts.map +1 -1
  515. package/utilities/graphql/directives.js +6 -7
  516. package/utilities/graphql/directives.js.map +1 -1
  517. package/utilities/graphql/fragments.d.ts +1 -1
  518. package/utilities/graphql/fragments.d.ts.map +1 -1
  519. package/utilities/graphql/fragments.js +8 -5
  520. package/utilities/graphql/fragments.js.map +1 -1
  521. package/utilities/graphql/getFromAST.d.ts +1 -1
  522. package/utilities/graphql/getFromAST.d.ts.map +1 -1
  523. package/utilities/graphql/getFromAST.js +9 -9
  524. package/utilities/graphql/getFromAST.js.map +1 -1
  525. package/utilities/graphql/operations.d.ts +5 -0
  526. package/utilities/graphql/operations.d.ts.map +1 -0
  527. package/utilities/graphql/operations.js +16 -0
  528. package/utilities/graphql/operations.js.map +1 -0
  529. package/utilities/graphql/storeUtils.d.ts +2 -2
  530. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  531. package/utilities/graphql/storeUtils.js +16 -7
  532. package/utilities/graphql/storeUtils.js.map +1 -1
  533. package/utilities/graphql/transform.d.ts +1 -1
  534. package/utilities/graphql/transform.d.ts.map +1 -1
  535. package/utilities/graphql/transform.js +30 -21
  536. package/utilities/graphql/transform.js.map +1 -1
  537. package/utilities/index.d.ts +6 -0
  538. package/utilities/index.d.ts.map +1 -1
  539. package/utilities/index.js +4 -0
  540. package/utilities/index.js.map +1 -1
  541. package/utilities/observables/Concast.d.ts +2 -1
  542. package/utilities/observables/Concast.d.ts.map +1 -1
  543. package/utilities/observables/Concast.js.map +1 -1
  544. package/utilities/observables/Observable.d.ts +2 -1
  545. package/utilities/observables/Observable.d.ts.map +1 -1
  546. package/utilities/observables/Observable.js +1 -1
  547. package/utilities/observables/Observable.js.map +1 -1
  548. package/utilities/observables/asyncMap.d.ts.map +1 -1
  549. package/utilities/observables/asyncMap.js.map +1 -1
  550. package/utilities/observables/iteration.d.ts +1 -1
  551. package/utilities/observables/iteration.d.ts.map +1 -1
  552. package/utilities/observables/iteration.js.map +1 -1
  553. package/utilities/policies/pagination.d.ts +1 -1
  554. package/utilities/policies/pagination.d.ts.map +1 -1
  555. package/utilities/policies/pagination.js.map +1 -1
  556. package/utilities/promises/decoration.d.ts +17 -0
  557. package/utilities/promises/decoration.d.ts.map +1 -0
  558. package/utilities/promises/decoration.js +37 -0
  559. package/utilities/promises/decoration.js.map +1 -0
  560. package/utilities/types/DeepOmit.d.ts +10 -0
  561. package/utilities/types/DeepOmit.d.ts.map +1 -0
  562. package/utilities/types/DeepOmit.js +2 -0
  563. package/utilities/types/DeepOmit.js.map +1 -0
  564. package/utilities/types/DeepPartial.d.ts +12 -0
  565. package/utilities/types/DeepPartial.d.ts.map +1 -0
  566. package/utilities/types/DeepPartial.js +2 -0
  567. package/utilities/types/DeepPartial.js.map +1 -0
  568. package/utilities/types/Primitive.d.ts +2 -0
  569. package/utilities/types/Primitive.d.ts.map +1 -0
  570. package/utilities/types/Primitive.js +2 -0
  571. package/utilities/types/Primitive.js.map +1 -0
  572. package/utilities/utilities.cjs +181 -45
  573. package/utilities/utilities.cjs.map +1 -1
  574. package/utilities/utilities.cjs.native.js +181 -45
  575. package/version.js +1 -1
  576. package/cache/inmemory/__mocks__/optimism.d.ts +0 -2
  577. package/cache/inmemory/__mocks__/optimism.d.ts.map +0 -1
  578. package/cache/inmemory/__mocks__/optimism.js +0 -14
  579. package/cache/inmemory/__mocks__/optimism.js.map +0 -1
  580. package/react/hooks/compareResults.d.ts +0 -3
  581. package/react/hooks/compareResults.d.ts.map +0 -1
  582. package/react/hooks/compareResults.js.map +0 -1
@@ -10,9 +10,11 @@ var equality = require('@wry/equality');
10
10
  var trie = require('@wry/trie');
11
11
  var graphql = require('graphql');
12
12
  var context = require('@wry/context');
13
+ var core = require('../core');
13
14
 
14
15
  var ApolloCache = (function () {
15
16
  function ApolloCache() {
17
+ this.assumeImmutableResults = false;
16
18
  this.getFragmentDoc = optimism.wrap(utilities.getFragmentQueryDocument);
17
19
  }
18
20
  ApolloCache.prototype.batch = function (options) {
@@ -288,7 +290,7 @@ exports.EntityStore = (function () {
288
290
  : newer;
289
291
  if (!incoming)
290
292
  return;
291
- globals.__DEV__ ? globals.invariant(typeof dataId === "string", "store.merge expects a string ID") : globals.invariant(typeof dataId === "string", 1);
293
+ globals.invariant(typeof dataId === "string", 1);
292
294
  var merged = new utilities.DeepMerger(storeObjectReconciler).merge(existing, incoming);
293
295
  this.data[dataId] = merged;
294
296
  if (merged !== existing) {
@@ -943,7 +945,7 @@ var StoreReader = (function () {
943
945
  else {
944
946
  var fragment = utilities.getFragmentFromSelection(selection, context.lookupFragment);
945
947
  if (!fragment && selection.kind === graphql.Kind.FRAGMENT_SPREAD) {
946
- throw globals.__DEV__ ? new globals.InvariantError("No fragment named ".concat(selection.name.value)) : new globals.InvariantError(5);
948
+ throw globals.newInvariantError(7, selection.name.value);
947
949
  }
948
950
  if (fragment && policies.fragmentMatches(fragment, typename)) {
949
951
  fragment.selectionSet.selections.forEach(workSet.add, workSet);
@@ -1024,7 +1026,12 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
1024
1026
  var workSet_1 = new Set([fieldValue]);
1025
1027
  workSet_1.forEach(function (value) {
1026
1028
  if (utilities.isNonNullObject(value)) {
1027
- globals.__DEV__ ? globals.invariant(!utilities.isReference(value), "Missing selection set for object of type ".concat(getTypenameFromStoreObject(store, value), " returned for query field ").concat(field.name.value)) : globals.invariant(!utilities.isReference(value), 6);
1029
+ globals.invariant(
1030
+ !utilities.isReference(value),
1031
+ 8,
1032
+ getTypenameFromStoreObject(store, value),
1033
+ field.name.value
1034
+ );
1028
1035
  Object.values(value).forEach(workSet_1.add, workSet_1);
1029
1036
  }
1030
1037
  });
@@ -1111,7 +1118,7 @@ function keyFieldsFnFromSpecifier(specifier) {
1111
1118
  hasOwn.call(object, schemaKeyPath[0])) {
1112
1119
  extracted = extractKeyPath(object, schemaKeyPath, extractKey);
1113
1120
  }
1114
- globals.__DEV__ ? globals.invariant(extracted !== void 0, "Missing field '".concat(schemaKeyPath.join('.'), "' while extracting keyFields from ").concat(JSON.stringify(object))) : globals.invariant(extracted !== void 0, 2);
1121
+ globals.invariant(extracted !== void 0, 2, schemaKeyPath.join('.'), object);
1115
1122
  return extracted;
1116
1123
  });
1117
1124
  return "".concat(context.typename, ":").concat(JSON.stringify(keyObject));
@@ -1263,7 +1270,7 @@ var Policies = (function () {
1263
1270
  var policy = typename && this.getTypePolicy(typename);
1264
1271
  var keyFn = policy && policy.keyFn || this.config.dataIdFromObject;
1265
1272
  while (keyFn) {
1266
- var specifierOrId = keyFn(object, context);
1273
+ var specifierOrId = keyFn(tslib.__assign(tslib.__assign({}, object), storeObject), context);
1267
1274
  if (utilities.isArray(specifierOrId)) {
1268
1275
  keyFn = keyFieldsFnFromSpecifier(specifierOrId);
1269
1276
  }
@@ -1340,7 +1347,7 @@ var Policies = (function () {
1340
1347
  var rootId = "ROOT_" + which.toUpperCase();
1341
1348
  var old = this.rootTypenamesById[rootId];
1342
1349
  if (typename !== old) {
1343
- globals.__DEV__ ? globals.invariant(!old || old === which, "Cannot change root ".concat(which, " __typename more than once")) : globals.invariant(!old || old === which, 3);
1350
+ globals.invariant(!old || old === which, 3, which);
1344
1351
  if (old)
1345
1352
  delete this.rootIdsByTypename[old];
1346
1353
  this.rootIdsByTypename[typename] = rootId;
@@ -1435,7 +1442,7 @@ var Policies = (function () {
1435
1442
  if (supertypeSet.has(supertype)) {
1436
1443
  if (!typenameSupertypeSet.has(supertype)) {
1437
1444
  if (checkingFuzzySubtypes) {
1438
- globals.__DEV__ && globals.invariant.warn("Inferring subtype ".concat(typename, " of supertype ").concat(supertype));
1445
+ globals.__DEV__ && globals.invariant.warn(4, typename, supertype);
1439
1446
  }
1440
1447
  typenameSupertypeSet.add(supertype);
1441
1448
  }
@@ -1589,7 +1596,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
1589
1596
  }
1590
1597
  }
1591
1598
  if (globals.__DEV__ && options.from === void 0) {
1592
- globals.__DEV__ && globals.invariant.warn("Undefined 'from' passed to readField with arguments ".concat(utilities.stringifyForDisplay(Array.from(readFieldArgs))));
1599
+ globals.__DEV__ && globals.invariant.warn(5, utilities.stringifyForDisplay(Array.from(readFieldArgs)));
1593
1600
  }
1594
1601
  if (void 0 === options.variables) {
1595
1602
  options.variables = variables;
@@ -1599,7 +1606,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
1599
1606
  function makeMergeObjectsFunction(store) {
1600
1607
  return function mergeObjects(existing, incoming) {
1601
1608
  if (utilities.isArray(existing) || utilities.isArray(incoming)) {
1602
- throw globals.__DEV__ ? new globals.InvariantError("Cannot automatically merge arrays") : new globals.InvariantError(4);
1609
+ throw globals.newInvariantError(6);
1603
1610
  }
1604
1611
  if (utilities.isNonNullObject(existing) &&
1605
1612
  utilities.isNonNullObject(incoming)) {
@@ -1660,7 +1667,7 @@ var StoreWriter = (function () {
1660
1667
  context: context,
1661
1668
  });
1662
1669
  if (!utilities.isReference(ref)) {
1663
- throw globals.__DEV__ ? new globals.InvariantError("Could not identify object ".concat(JSON.stringify(result))) : new globals.InvariantError(7);
1670
+ throw globals.newInvariantError(9, result);
1664
1671
  }
1665
1672
  context.incomingById.forEach(function (_a, dataId) {
1666
1673
  var storeObject = _a.storeObject, mergeTree = _a.mergeTree, fieldNodeSet = _a.fieldNodeSet;
@@ -1765,7 +1772,7 @@ var StoreWriter = (function () {
1765
1772
  !context.deferred &&
1766
1773
  !utilities.addTypenameToDocument.added(field) &&
1767
1774
  !policies.getReadFunction(typename, field.name.value)) {
1768
- globals.__DEV__ && globals.invariant.error("Missing field '".concat(utilities.resultKeyNameFromField(field), "' while writing result ").concat(JSON.stringify(result, null, 2)).substring(0, 1000));
1775
+ globals.__DEV__ && globals.invariant.error(10, utilities.resultKeyNameFromField(field), result);
1769
1776
  }
1770
1777
  });
1771
1778
  try {
@@ -1869,7 +1876,7 @@ var StoreWriter = (function () {
1869
1876
  else {
1870
1877
  var fragment = utilities.getFragmentFromSelection(selection, context.lookupFragment);
1871
1878
  if (!fragment && selection.kind === graphql.Kind.FRAGMENT_SPREAD) {
1872
- throw globals.__DEV__ ? new globals.InvariantError("No fragment named ".concat(selection.name.value)) : new globals.InvariantError(8);
1879
+ throw globals.newInvariantError(11, selection.name.value);
1873
1880
  }
1874
1881
  if (fragment &&
1875
1882
  policies.fragmentMatches(fragment, typename, result, context.variables)) {
@@ -2005,10 +2012,9 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
2005
2012
  }
2006
2013
  });
2007
2014
  }
2008
- globals.__DEV__ && globals.invariant.warn("Cache data may be lost when replacing the ".concat(fieldName, " field of a ").concat(parentType, " object.\n\nTo address this problem (which is not a bug in Apollo Client), ").concat(childTypenames.length
2009
- ? "either ensure all objects of type " +
2010
- childTypenames.join(" and ") + " have an ID or a custom merge function, or "
2011
- : "", "define a custom merge function for the ").concat(typeDotName, " field, so InMemoryCache can safely merge these objects:\n\n existing: ").concat(JSON.stringify(existing).slice(0, 1000), "\n incoming: ").concat(JSON.stringify(incoming).slice(0, 1000), "\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n"));
2015
+ globals.__DEV__ && globals.invariant.warn(12, fieldName, parentType, childTypenames.length
2016
+ ? "either ensure all objects of type " + childTypenames.join(" and ") + " have an ID or a custom merge function, or "
2017
+ : "", typeDotName, existing, incoming);
2012
2018
  }
2013
2019
 
2014
2020
  var InMemoryCache = (function (_super) {
@@ -2017,7 +2023,8 @@ var InMemoryCache = (function (_super) {
2017
2023
  if (config === void 0) { config = {}; }
2018
2024
  var _this = _super.call(this) || this;
2019
2025
  _this.watches = new Set();
2020
- _this.typenameDocumentCache = new Map();
2026
+ _this.addTypenameTransform = new core.DocumentTransform(utilities.addTypenameToDocument);
2027
+ _this.assumeImmutableResults = true;
2021
2028
  _this.makeVar = makeVar;
2022
2029
  _this.txCount = 0;
2023
2030
  _this.config = normalizeConfig(config);
@@ -2268,28 +2275,25 @@ var InMemoryCache = (function (_super) {
2268
2275
  });
2269
2276
  };
2270
2277
  InMemoryCache.prototype.transformDocument = function (document) {
2271
- if (this.addTypename) {
2272
- var result = this.typenameDocumentCache.get(document);
2273
- if (!result) {
2274
- result = utilities.addTypenameToDocument(document);
2275
- this.typenameDocumentCache.set(document, result);
2276
- this.typenameDocumentCache.set(result, result);
2277
- }
2278
- return result;
2278
+ return this.addTypenameToDocument(this.addFragmentsToDocument(document));
2279
+ };
2280
+ InMemoryCache.prototype.broadcastWatches = function (options) {
2281
+ var _this = this;
2282
+ if (!this.txCount) {
2283
+ this.watches.forEach(function (c) { return _this.maybeBroadcastWatch(c, options); });
2279
2284
  }
2280
- return document;
2281
2285
  };
2282
- InMemoryCache.prototype.transformForLink = function (document) {
2286
+ InMemoryCache.prototype.addFragmentsToDocument = function (document) {
2283
2287
  var fragments = this.config.fragments;
2284
2288
  return fragments
2285
2289
  ? fragments.transform(document)
2286
2290
  : document;
2287
2291
  };
2288
- InMemoryCache.prototype.broadcastWatches = function (options) {
2289
- var _this = this;
2290
- if (!this.txCount) {
2291
- this.watches.forEach(function (c) { return _this.maybeBroadcastWatch(c, options); });
2292
+ InMemoryCache.prototype.addTypenameToDocument = function (document) {
2293
+ if (this.addTypename) {
2294
+ return this.addTypenameTransform.transformDocument(document);
2292
2295
  }
2296
+ return document;
2293
2297
  };
2294
2298
  InMemoryCache.prototype.broadcastWatch = function (c, options) {
2295
2299
  var lastDiff = c.lastDiff;
@@ -1,9 +1,10 @@
1
- import { DocumentNode } from 'graphql';
2
- import { StoreObject, Reference } from '../../utilities';
3
- import { DataProxy } from './types/DataProxy';
4
- import { Cache } from './types/Cache';
1
+ import type { DocumentNode } from 'graphql';
2
+ import type { StoreObject, Reference } from '../../utilities';
3
+ import type { DataProxy } from './types/DataProxy';
4
+ import type { Cache } from './types/Cache';
5
5
  export type Transaction<T> = (c: ApolloCache<T>) => void;
6
6
  export declare abstract class ApolloCache<TSerialized> implements DataProxy {
7
+ readonly assumeImmutableResults: boolean;
7
8
  abstract read<TData = any, TVariables = any>(query: Cache.ReadOptions<TVariables, TData>): TData | null;
8
9
  abstract write<TData = any, TVariables = any>(write: Cache.WriteOptions<TData, TVariables>): Reference | undefined;
9
10
  abstract diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/cache/core/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EACL,WAAW,EACX,SAAS,EAEV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAEzD,8BAAsB,WAAW,CAAC,WAAW,CAAE,YAAW,SAAS;aAGjD,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EAChD,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,GAC1C,KAAK,GAAG,IAAI;aACC,KAAK,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EACjD,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,GAC3C,SAAS,GAAG,SAAS;aACR,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,UAAU,CA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OAAO,EACX,EAAE,KAAK,CAAC,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,SAAS,GAAG,SAAS;IAQjE,WAAW,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EAC9C,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,KAAK,EAAE,UAAU,CAAC,EACpD,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG,IAAI,GAAG,IAAI,GAClD,KAAK,GAAG,IAAI;IAYR,cAAc,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EACjD,OAAO,EAAE,KAAK,CAAC,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,EACvD,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG,IAAI,GAAG,IAAI,GAClD,KAAK,GAAG,IAAI;CAWhB"}
@@ -3,6 +3,7 @@ import { wrap } from 'optimism';
3
3
  import { getFragmentQueryDocument, } from "../../utilities/index.js";
4
4
  var ApolloCache = (function () {
5
5
  function ApolloCache() {
6
+ this.assumeImmutableResults = false;
6
7
  this.getFragmentDoc = wrap(getFragmentQueryDocument);
7
8
  }
8
9
  ApolloCache.prototype.batch = function (options) {
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/cache/core/cache.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAGL,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AAMzB;IAAA;QAiIU,mBAAc,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAoE1D,CAAC;IAhJQ,2BAAK,GAAZ,UAAgB,OAAoC;QAApD,iBAUC;QATC,IAAM,YAAY,GAChB,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;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KAAK;gBACV,IAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAoB,OAAO,CAAC,CAAC;gBAC7D,IAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC3B,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,IAAI;oBAAE,OAAO,KAAK,CAAC;gBACnD,KAAK,CAAC,aAAa,uBAAyB,OAAO,KAAE,IAAI,MAAA,IAAG,CAAC;gBAC7D,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IACH,kBAAC;AAAD,CAAC,AArMD,IAqMC","sourcesContent":["import { DocumentNode } from 'graphql';\nimport { wrap } from 'optimism';\n\nimport {\n StoreObject,\n Reference,\n getFragmentQueryDocument,\n} from '../../utilities';\nimport { DataProxy } from './types/DataProxy';\nimport { Cache } from './types/Cache';\n\nexport type Transaction<T> = (c: ApolloCache<T>) => void;\n\nexport abstract class ApolloCache<TSerialized> implements DataProxy {\n // required to implement\n // core API\n public abstract read<TData = any, TVariables = any>(\n query: Cache.ReadOptions<TVariables, TData>,\n ): TData | null;\n public abstract write<TData = any, TVariables = any>(\n write: Cache.WriteOptions<TData, TVariables>,\n ): Reference | undefined;\n public abstract diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;\n public abstract watch<TData = any, TVariables = any>(\n watch: Cache.WatchOptions<TData, TVariables>,\n ): () => void;\n\n // Empty the cache and restart all current watches (unless\n // options.discardWatches is true).\n public abstract reset(options?: Cache.ResetOptions): Promise<void>;\n\n // Remove whole objects from the cache by passing just options.id, or\n // specific fields by passing options.field and/or options.args. If no\n // options.args are provided, all fields matching options.field (even\n // those with arguments) will be removed. Returns true iff any data was\n // removed from the cache.\n public abstract evict(options: Cache.EvictOptions): boolean;\n\n // initializer / offline / ssr API\n /**\n * Replaces existing state in the cache (if any) with the values expressed by\n * `serializedState`.\n *\n * Called when hydrating a cache (server side rendering, or offline storage),\n * and also (potentially) during hot reloads.\n */\n public abstract restore(\n serializedState: TSerialized,\n ): ApolloCache<TSerialized>;\n\n /**\n * Exposes the cache's complete state, in a serializable format for later restoration.\n */\n public abstract extract(optimistic?: boolean): TSerialized;\n\n // Optimistic API\n\n public abstract removeOptimistic(id: string): void;\n\n // Transactional API\n\n // The batch method is intended to replace/subsume both performTransaction\n // and recordOptimisticTransaction, but performTransaction came first, so we\n // provide a default batch implementation that's just another way of calling\n // performTransaction. Subclasses of ApolloCache (such as InMemoryCache) can\n // override the batch method to do more interesting things with its options.\n public batch<U>(options: Cache.BatchOptions<this, U>): U {\n const optimisticId =\n typeof options.optimistic === \"string\" ? options.optimistic :\n options.optimistic === false ? null : void 0;\n let updateResult: U;\n this.performTransaction(\n () => updateResult = options.update(this),\n optimisticId,\n );\n return updateResult!;\n }\n\n public abstract performTransaction(\n transaction: Transaction<TSerialized>,\n // Although subclasses may implement recordOptimisticTransaction\n // however they choose, the default implementation simply calls\n // performTransaction with a string as the second argument, allowing\n // performTransaction to handle both optimistic and non-optimistic\n // (broadcast-batching) transactions. Passing null for optimisticId is\n // also allowed, and indicates that performTransaction should apply\n // the transaction non-optimistically (ignoring optimistic data).\n optimisticId?: string | null,\n ): void;\n\n public recordOptimisticTransaction(\n transaction: Transaction<TSerialized>,\n optimisticId: string,\n ) {\n this.performTransaction(transaction, optimisticId);\n }\n\n // Optional API\n\n // Called once per input document, allowing the cache to make static changes\n // to the query, such as adding __typename fields.\n public transformDocument(document: DocumentNode): DocumentNode {\n return document;\n }\n\n // Called before each ApolloLink request, allowing the cache to make dynamic\n // changes to the query, such as filling in missing fragment definitions.\n public transformForLink(document: DocumentNode): DocumentNode {\n return document;\n }\n\n public identify(object: StoreObject | Reference): string | undefined {\n return;\n }\n\n public gc(): string[] {\n return [];\n }\n\n public modify(options: Cache.ModifyOptions): boolean {\n return false;\n }\n\n // DataProxy API\n /**\n *\n * @param options\n * @param optimistic\n */\n public readQuery<QueryType, TVariables = any>(\n options: Cache.ReadQueryOptions<QueryType, TVariables>,\n optimistic = !!options.optimistic,\n ): QueryType | null {\n return this.read({\n ...options,\n rootId: options.id || 'ROOT_QUERY',\n optimistic,\n });\n }\n\n // Make sure we compute the same (===) fragment query document every\n // time we receive the same fragment in readFragment.\n private getFragmentDoc = wrap(getFragmentQueryDocument);\n\n public readFragment<FragmentType, TVariables = any>(\n options: Cache.ReadFragmentOptions<FragmentType, TVariables>,\n optimistic = !!options.optimistic,\n ): FragmentType | null {\n return this.read({\n ...options,\n query: this.getFragmentDoc(options.fragment, options.fragmentName),\n rootId: options.id,\n optimistic,\n });\n }\n\n public writeQuery<TData = any, TVariables = any>({\n id,\n data,\n ...options\n }: Cache.WriteQueryOptions<TData, TVariables>): Reference | undefined {\n return this.write(Object.assign(options, {\n dataId: id || 'ROOT_QUERY',\n result: data,\n }));\n }\n\n public writeFragment<TData = any, TVariables = any>({\n id,\n data,\n fragment,\n fragmentName,\n ...options\n }: Cache.WriteFragmentOptions<TData, TVariables>): Reference | undefined {\n return this.write(Object.assign(options, {\n query: this.getFragmentDoc(fragment, fragmentName),\n dataId: id,\n result: data,\n }));\n }\n\n public updateQuery<TData = any, TVariables = any>(\n options: Cache.UpdateQueryOptions<TData, TVariables>,\n update: (data: TData | null) => TData | null | void,\n ): TData | null {\n return this.batch({\n update(cache) {\n const value = cache.readQuery<TData, TVariables>(options);\n const data = update(value);\n if (data === void 0 || data === null) return value;\n cache.writeQuery<TData, TVariables>({ ...options, data });\n return data;\n },\n });\n }\n\n public updateFragment<TData = any, TVariables = any>(\n options: Cache.UpdateFragmentOptions<TData, TVariables>,\n update: (data: TData | null) => TData | null | void,\n ): TData | null {\n return this.batch({\n update(cache) {\n const value = cache.readFragment<TData, TVariables>(options);\n const data = update(value);\n if (data === void 0 || data === null) return value;\n cache.writeFragment<TData, TVariables>({ ...options, data });\n return data;\n },\n });\n }\n}\n"]}
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/cache/core/cache.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,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AG,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC3B,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,IAAI;oBAAE,OAAO,KAAK,CAAC;gBACnD,KAAK,CAAC,UAAU,uBAAyB,OAAO,KAAE,IAAI,MAAA,IAAG,CAAC;gBAC1D,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAEM,oCAAc,GAArB,UACE,OAAuD,EACvD,MAAmD;QAEnD,OAAO,IAAI,CAAC,KAAK,CAAC;YAChB,MAAM,YAAC,KAAK;gBACV,IAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAoB,OAAO,CAAC,CAAC;gBAC7D,IAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC3B,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,IAAI;oBAAE,OAAO,KAAK,CAAC;gBACnD,KAAK,CAAC,aAAa,uBAAyB,OAAO,KAAE,IAAI,MAAA,IAAG,CAAC;gBAC7D,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IACH,kBAAC;AAAD,CAAC,AAvMD,IAuMC","sourcesContent":["import type { DocumentNode } from 'graphql';\nimport { wrap } from 'optimism';\n\nimport type {\n StoreObject,\n Reference} from '../../utilities';\nimport {\n getFragmentQueryDocument,\n} from '../../utilities';\nimport type { DataProxy } from './types/DataProxy';\nimport type { Cache } from './types/Cache';\n\nexport type Transaction<T> = (c: ApolloCache<T>) => void;\n\nexport abstract class ApolloCache<TSerialized> implements DataProxy {\n public readonly assumeImmutableResults: boolean = false;\n\n // required to implement\n // core API\n public abstract read<TData = any, TVariables = any>(\n query: Cache.ReadOptions<TVariables, TData>,\n ): TData | null;\n public abstract write<TData = any, TVariables = any>(\n write: Cache.WriteOptions<TData, TVariables>,\n ): Reference | undefined;\n public abstract diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;\n public abstract watch<TData = any, TVariables = any>(\n watch: Cache.WatchOptions<TData, TVariables>,\n ): () => void;\n\n // Empty the cache and restart all current watches (unless\n // options.discardWatches is true).\n public abstract reset(options?: Cache.ResetOptions): Promise<void>;\n\n // Remove whole objects from the cache by passing just options.id, or\n // specific fields by passing options.field and/or options.args. If no\n // options.args are provided, all fields matching options.field (even\n // those with arguments) will be removed. Returns true iff any data was\n // removed from the cache.\n public abstract evict(options: Cache.EvictOptions): boolean;\n\n // initializer / offline / ssr API\n /**\n * Replaces existing state in the cache (if any) with the values expressed by\n * `serializedState`.\n *\n * Called when hydrating a cache (server side rendering, or offline storage),\n * and also (potentially) during hot reloads.\n */\n public abstract restore(\n serializedState: TSerialized,\n ): ApolloCache<TSerialized>;\n\n /**\n * Exposes the cache's complete state, in a serializable format for later restoration.\n */\n public abstract extract(optimistic?: boolean): TSerialized;\n\n // Optimistic API\n\n public abstract removeOptimistic(id: string): void;\n\n // Transactional API\n\n // The batch method is intended to replace/subsume both performTransaction\n // and recordOptimisticTransaction, but performTransaction came first, so we\n // provide a default batch implementation that's just another way of calling\n // performTransaction. Subclasses of ApolloCache (such as InMemoryCache) can\n // override the batch method to do more interesting things with its options.\n public batch<U>(options: Cache.BatchOptions<this, U>): U {\n const optimisticId =\n typeof options.optimistic === \"string\" ? options.optimistic :\n options.optimistic === false ? null : void 0;\n let updateResult: U;\n this.performTransaction(\n () => updateResult = options.update(this),\n optimisticId,\n );\n return updateResult!;\n }\n\n public abstract performTransaction(\n transaction: Transaction<TSerialized>,\n // Although subclasses may implement recordOptimisticTransaction\n // however they choose, the default implementation simply calls\n // performTransaction with a string as the second argument, allowing\n // performTransaction to handle both optimistic and non-optimistic\n // (broadcast-batching) transactions. Passing null for optimisticId is\n // also allowed, and indicates that performTransaction should apply\n // the transaction non-optimistically (ignoring optimistic data).\n optimisticId?: string | null,\n ): void;\n\n public recordOptimisticTransaction(\n transaction: Transaction<TSerialized>,\n optimisticId: string,\n ) {\n this.performTransaction(transaction, optimisticId);\n }\n\n // Optional API\n\n // Called once per input document, allowing the cache to make static changes\n // to the query, such as adding __typename fields.\n public transformDocument(document: DocumentNode): DocumentNode {\n return document;\n }\n\n // Called before each ApolloLink request, allowing the cache to make dynamic\n // changes to the query, such as filling in missing fragment definitions.\n public transformForLink(document: DocumentNode): DocumentNode {\n return document;\n }\n\n public identify(object: StoreObject | Reference): string | undefined {\n return;\n }\n\n public gc(): string[] {\n return [];\n }\n\n public modify(options: Cache.ModifyOptions): boolean {\n return false;\n }\n\n // DataProxy API\n /**\n *\n * @param options\n * @param optimistic\n */\n public readQuery<QueryType, TVariables = any>(\n options: Cache.ReadQueryOptions<QueryType, TVariables>,\n optimistic = !!options.optimistic,\n ): QueryType | null {\n return this.read({\n ...options,\n rootId: options.id || 'ROOT_QUERY',\n optimistic,\n });\n }\n\n // Make sure we compute the same (===) fragment query document every\n // time we receive the same fragment in readFragment.\n private getFragmentDoc = wrap(getFragmentQueryDocument);\n\n public readFragment<FragmentType, TVariables = any>(\n options: Cache.ReadFragmentOptions<FragmentType, TVariables>,\n optimistic = !!options.optimistic,\n ): FragmentType | null {\n return this.read({\n ...options,\n query: this.getFragmentDoc(options.fragment, options.fragmentName),\n rootId: options.id,\n optimistic,\n });\n }\n\n public writeQuery<TData = any, TVariables = any>({\n id,\n data,\n ...options\n }: Cache.WriteQueryOptions<TData, TVariables>): Reference | undefined {\n return this.write(Object.assign(options, {\n dataId: id || 'ROOT_QUERY',\n result: data,\n }));\n }\n\n public writeFragment<TData = any, TVariables = any>({\n id,\n data,\n fragment,\n fragmentName,\n ...options\n }: Cache.WriteFragmentOptions<TData, TVariables>): Reference | undefined {\n return this.write(Object.assign(options, {\n query: this.getFragmentDoc(fragment, fragmentName),\n dataId: id,\n result: data,\n }));\n }\n\n public updateQuery<TData = any, TVariables = any>(\n options: Cache.UpdateQueryOptions<TData, TVariables>,\n update: (data: TData | null) => TData | null | void,\n ): TData | null {\n return this.batch({\n update(cache) {\n const value = cache.readQuery<TData, TVariables>(options);\n const data = update(value);\n if (data === void 0 || data === null) return value;\n cache.writeQuery<TData, TVariables>({ ...options, data });\n return data;\n },\n });\n }\n\n public updateFragment<TData = any, TVariables = any>(\n options: Cache.UpdateFragmentOptions<TData, TVariables>,\n update: (data: TData | null) => TData | null | void,\n ): TData | null {\n return this.batch({\n update(cache) {\n const value = cache.readFragment<TData, TVariables>(options);\n const data = update(value);\n if (data === void 0 || data === null) return value;\n cache.writeFragment<TData, TVariables>({ ...options, data });\n return data;\n },\n });\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { DataProxy } from './DataProxy';
2
- import { Modifier, Modifiers } from './common';
3
- import { ApolloCache } from '../cache';
2
+ import type { Modifier, Modifiers } from './common';
3
+ import type { ApolloCache } from '../cache';
4
4
  export declare namespace Cache {
5
5
  type WatchCallback<TData = any> = (diff: Cache.DiffResult<TData>, lastDiff?: Cache.DiffResult<TData>) => void;
6
6
  interface ReadOptions<TVariables = any, TData = any> extends DataProxy.Query<TVariables, TData> {
@@ -1 +1 @@
1
- {"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../../../src/cache/core/types/Cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,yBAAiB,KAAK,CAAC;IACrB,KAAY,aAAa,CAAC,KAAK,GAAG,GAAG,IAAI,CACvC,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,KAC/B,IAAI,CAAC;IAEV,UAAiB,WAAW,CAAC,UAAU,GAAG,GAAG,EAAE,KAAK,GAAG,GAAG,CACxD,SAAQ,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC;QAC1C,MAAM,CAAC,EAA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G,SAAS,CAAC,mBAAmB,CAAC;IAClE,MAAM,QAAQ,iBAAiB,GAAG,SAAS,CAAC,iBAAiB,CAAC;IAC9D,MAAM,QAAQ,oBAAoB,GAAG,SAAS,CAAC,oBAAoB,CAAC;IACpE,MAAM,QAAQ,kBAAkB,GAAG,SAAS,CAAC,kBAAkB,CAAC;IAChE,MAAM,QAAQ,qBAAqB,GAAG,SAAS,CAAC,qBAAqB,CAAC;IACtE,MAAM,QAAQ,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;CAC7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../../../src/cache/core/types/Cache.ts"],"names":[],"mappings":"AAIA,MAAM,KAAW,KAAK,CA0GrB;AA1GD,WAAiB,KAAK;AA0GtB,CAAC,EA1GgB,KAAK,KAAL,KAAK,QA0GrB","sourcesContent":["import { DataProxy } from './DataProxy';\nimport { Modifier, Modifiers } from './common';\nimport { ApolloCache } from '../cache';\n\nexport namespace Cache {\n export type WatchCallback<TData = any> = (\n diff: Cache.DiffResult<TData>,\n lastDiff?: Cache.DiffResult<TData>,\n ) => void;\n\n export interface ReadOptions<TVariables = any, TData = any>\n extends DataProxy.Query<TVariables, TData> {\n rootId?: string;\n previousResult?: any;\n optimistic: boolean;\n returnPartialData?: boolean;\n canonizeResults?: boolean;\n }\n\n export interface WriteOptions<TResult = any, TVariables = any>\n extends Omit<DataProxy.Query<TVariables, TResult>, \"id\">,\n Omit<DataProxy.WriteOptions<TResult>, \"data\">\n {\n dataId?: string;\n result: TResult;\n }\n\n export interface DiffOptions<\n TData = any,\n TVariables = any,\n > extends Omit<ReadOptions<TVariables, TData>, \"rootId\"> {\n // The DiffOptions interface is currently just an alias for\n // ReadOptions, though DiffOptions used to be responsible for\n // declaring the returnPartialData option.\n }\n\n export interface WatchOptions<\n TData = any,\n TVariables = any,\n > extends DiffOptions<TData, TVariables> {\n watcher?: object;\n immediate?: boolean;\n callback: WatchCallback<TData>;\n lastDiff?: DiffResult<TData>;\n }\n\n export interface EvictOptions {\n id?: string;\n fieldName?: string;\n args?: Record<string, any>;\n broadcast?: boolean;\n }\n\n // Although you can call cache.reset() without options, its behavior can be\n // configured by passing a Cache.ResetOptions object.\n export interface ResetOptions {\n discardWatches?: boolean;\n }\n\n export interface ModifyOptions {\n id?: string;\n fields: Modifiers | Modifier<any>;\n optimistic?: boolean;\n broadcast?: boolean;\n }\n\n export interface BatchOptions<\n TCache extends ApolloCache<any>,\n TUpdateResult = void,\n > {\n // Same as the first parameter of performTransaction, except the cache\n // argument will have the subclass type rather than ApolloCache.\n update(cache: TCache): TUpdateResult;\n\n // Passing a string for this option creates a new optimistic layer, with the\n // given string as its layer.id, just like passing a string for the\n // optimisticId parameter of performTransaction. Passing true is the same as\n // passing undefined to performTransaction (running the batch operation\n // against the current top layer of the cache), and passing false is the\n // same as passing null (running the operation against root/non-optimistic\n // cache data).\n optimistic?: string | boolean;\n\n // If you specify the ID of an optimistic layer using this option, that\n // layer will be removed as part of the batch transaction, triggering at\n // most one broadcast for both the transaction and the removal of the layer.\n // Note: this option is needed because calling cache.removeOptimistic during\n // the transaction function may not be not safe, since any modifications to\n // cache layers may be discarded after the transaction finishes.\n removeOptimistic?: string;\n\n // If you want to find out which watched queries were invalidated during\n // this batch operation, pass this optional callback function. Returning\n // false from the callback will prevent broadcasting this result.\n onWatchUpdated?: (\n this: TCache,\n watch: Cache.WatchOptions,\n diff: Cache.DiffResult<any>,\n lastDiff: Cache.DiffResult<any> | undefined,\n ) => any;\n }\n\n export import DiffResult = DataProxy.DiffResult;\n export import ReadQueryOptions = DataProxy.ReadQueryOptions;\n export import ReadFragmentOptions = DataProxy.ReadFragmentOptions;\n export import WriteQueryOptions = DataProxy.WriteQueryOptions;\n export import WriteFragmentOptions = DataProxy.WriteFragmentOptions;\n export import UpdateQueryOptions = DataProxy.UpdateQueryOptions;\n export import UpdateFragmentOptions = DataProxy.UpdateFragmentOptions;\n export import Fragment = DataProxy.Fragment;\n}\n"]}
1
+ {"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../../../src/cache/core/types/Cache.ts"],"names":[],"mappings":"AAIA,MAAM,KAAW,KAAK,CA0GrB;AA1GD,WAAiB,KAAK;AA0GtB,CAAC,EA1GgB,KAAK,KAAL,KAAK,QA0GrB","sourcesContent":["import { DataProxy } from './DataProxy';\nimport type { Modifier, Modifiers } from './common';\nimport type { ApolloCache } from '../cache';\n\nexport namespace Cache {\n export type WatchCallback<TData = any> = (\n diff: Cache.DiffResult<TData>,\n lastDiff?: Cache.DiffResult<TData>,\n ) => void;\n\n export interface ReadOptions<TVariables = any, TData = any>\n extends DataProxy.Query<TVariables, TData> {\n rootId?: string;\n previousResult?: any;\n optimistic: boolean;\n returnPartialData?: boolean;\n canonizeResults?: boolean;\n }\n\n export interface WriteOptions<TResult = any, TVariables = any>\n extends Omit<DataProxy.Query<TVariables, TResult>, \"id\">,\n Omit<DataProxy.WriteOptions<TResult>, \"data\">\n {\n dataId?: string;\n result: TResult;\n }\n\n export interface DiffOptions<\n TData = any,\n TVariables = any,\n > extends Omit<ReadOptions<TVariables, TData>, \"rootId\"> {\n // The DiffOptions interface is currently just an alias for\n // ReadOptions, though DiffOptions used to be responsible for\n // declaring the returnPartialData option.\n }\n\n export interface WatchOptions<\n TData = any,\n TVariables = any,\n > extends DiffOptions<TData, TVariables> {\n watcher?: object;\n immediate?: boolean;\n callback: WatchCallback<TData>;\n lastDiff?: DiffResult<TData>;\n }\n\n export interface EvictOptions {\n id?: string;\n fieldName?: string;\n args?: Record<string, any>;\n broadcast?: boolean;\n }\n\n // Although you can call cache.reset() without options, its behavior can be\n // configured by passing a Cache.ResetOptions object.\n export interface ResetOptions {\n discardWatches?: boolean;\n }\n\n export interface ModifyOptions {\n id?: string;\n fields: Modifiers | Modifier<any>;\n optimistic?: boolean;\n broadcast?: boolean;\n }\n\n export interface BatchOptions<\n TCache extends ApolloCache<any>,\n TUpdateResult = void,\n > {\n // Same as the first parameter of performTransaction, except the cache\n // argument will have the subclass type rather than ApolloCache.\n update(cache: TCache): TUpdateResult;\n\n // Passing a string for this option creates a new optimistic layer, with the\n // given string as its layer.id, just like passing a string for the\n // optimisticId parameter of performTransaction. Passing true is the same as\n // passing undefined to performTransaction (running the batch operation\n // against the current top layer of the cache), and passing false is the\n // same as passing null (running the operation against root/non-optimistic\n // cache data).\n optimistic?: string | boolean;\n\n // If you specify the ID of an optimistic layer using this option, that\n // layer will be removed as part of the batch transaction, triggering at\n // most one broadcast for both the transaction and the removal of the layer.\n // Note: this option is needed because calling cache.removeOptimistic during\n // the transaction function may not be not safe, since any modifications to\n // cache layers may be discarded after the transaction finishes.\n removeOptimistic?: string;\n\n // If you want to find out which watched queries were invalidated during\n // this batch operation, pass this optional callback function. Returning\n // false from the callback will prevent broadcasting this result.\n onWatchUpdated?: (\n this: TCache,\n watch: Cache.WatchOptions,\n diff: Cache.DiffResult<any>,\n lastDiff: Cache.DiffResult<any> | undefined,\n ) => any;\n }\n\n export import DiffResult = DataProxy.DiffResult;\n export import ReadQueryOptions = DataProxy.ReadQueryOptions;\n export import ReadFragmentOptions = DataProxy.ReadFragmentOptions;\n export import WriteQueryOptions = DataProxy.WriteQueryOptions;\n export import WriteFragmentOptions = DataProxy.WriteFragmentOptions;\n export import UpdateQueryOptions = DataProxy.UpdateQueryOptions;\n export import UpdateFragmentOptions = DataProxy.UpdateFragmentOptions;\n export import Fragment = DataProxy.Fragment;\n}\n"]}
@@ -1,7 +1,7 @@
1
- import { DocumentNode } from 'graphql';
2
- import { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
- import { MissingFieldError } from './common';
4
- import { Reference } from '../../../utilities';
1
+ import type { DocumentNode } from 'graphql';
2
+ import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
+ import type { MissingFieldError } from './common';
4
+ import type { Reference } from '../../../utilities';
5
5
  export declare namespace DataProxy {
6
6
  interface Query<TVariables, TData> {
7
7
  query: DocumentNode | TypedDocumentNode<TData, TVariables>;
@@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C,IAAI;QAC1B,MAAM,CAAC,EAAE,CAAC,CAAC;QACX,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;QAC9B,yBAAyB,CAAC,EAAE,OAAO,CAAC;KACrC,CAAA;CACF;AAQD,MAAM,WAAW,SAAS;IAIxB,SAAS,CAAC,SAAS,EAAE,UAAU,GAAG,GAAG,EACnC,OAAO,EAAE,SAAS,CAAC,gBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC,EAC1D,UAAU,CAAC,EAAE,OAAO,GACnB,SAAS,GAAG,IAAI,CAAC;IAOpB,YAAY,CAAC,YAAY,EAAE,UAAU,GAAG,GAAG,EACzC,OAAO,EAAE,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,UAAU,CAAC,EAChE,UAAU,CAAC,EAAE,OAAO,GACnB,YAAY,GAAG,IAAI,CAAC;IAKvB,UAAU,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EACtC,OAAO,EAAE,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,GACtD,SAAS,GAAG,SAAS,CAAC;IAOzB,aAAa,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,GAAG,EACzC,OAAO,EAAE,SAAS,CAAC,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,GACzD,SAAS,GAAG,SAAS,CAAC;CAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"DataProxy.js","sourceRoot":"","sources":["../../../../src/cache/core/types/DataProxy.ts"],"names":[],"mappings":"","sourcesContent":["import { DocumentNode } from 'graphql'; // eslint-disable-line import/no-extraneous-dependencies, import/no-unresolved\nimport { TypedDocumentNode } from '@graphql-typed-document-node/core';\n\nimport { MissingFieldError } from './common';\nimport { Reference } from '../../../utilities';\n\nexport namespace DataProxy {\n export interface Query<TVariables, TData> {\n /**\n * The GraphQL query shape to be used constructed using the `gql` template\n * string tag from `graphql-tag`. The query will be used to determine the\n * shape of the data to be read.\n */\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * Any variables that the GraphQL query may depend on.\n */\n variables?: TVariables;\n\n /**\n * The root id to be used. Defaults to \"ROOT_QUERY\", which is the ID of the\n * root query object. This property makes writeQuery capable of writing data\n * to any object in the cache.\n */\n id?: string;\n }\n\n export interface Fragment<TVariables, TData> {\n /**\n * The root id to be used. This id should take the same form as the\n * value returned by your `dataIdFromObject` function. If a value with your\n * id does not exist in the store, `null` will be returned.\n */\n id?: string;\n\n /**\n * A GraphQL document created using the `gql` template string tag from\n * `graphql-tag` with one or more fragments which will be used to determine\n * the shape of data to read. If you provide more than one fragment in this\n * document then you must also specify `fragmentName` to select a single.\n */\n fragment: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * The name of the fragment in your GraphQL document to be used. If you do\n * not provide a `fragmentName` and there is only one fragment in your\n * `fragment` document then that fragment will be used.\n */\n fragmentName?: string;\n\n /**\n * Any variables that your GraphQL fragments depend on.\n */\n variables?: TVariables;\n }\n\n export interface ReadQueryOptions<TData, TVariables>\n extends Query<TVariables, TData> {\n /**\n * Whether to return incomplete data rather than null.\n * Defaults to false.\n */\n returnPartialData?: boolean;\n /**\n * Whether to read from optimistic or non-optimistic cache data. If\n * this named option is provided, the optimistic parameter of the\n * readQuery method can be omitted. Defaults to false.\n */\n optimistic?: boolean;\n /**\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n */\n canonizeResults?: boolean;\n }\n\n export interface ReadFragmentOptions<TData, TVariables>\n extends Fragment<TVariables, TData> {\n /**\n * Whether to return incomplete data rather than null.\n * Defaults to false.\n */\n returnPartialData?: boolean;\n /**\n * Whether to read from optimistic or non-optimistic cache data. If\n * this named option is provided, the optimistic parameter of the\n * readQuery method can be omitted. Defaults to false.\n */\n optimistic?: boolean;\n /**\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n */\n canonizeResults?: boolean;\n }\n\n export interface WriteOptions<TData> {\n /**\n * The data you will be writing to the store.\n */\n data: TData;\n /**\n * Whether to notify query watchers (default: true).\n */\n broadcast?: boolean;\n /**\n * When true, ignore existing field data rather than merging it with\n * incoming data (default: false).\n */\n overwrite?: boolean;\n }\n\n export interface WriteQueryOptions<TData, TVariables>\n extends Query<TVariables, TData>, WriteOptions<TData> {}\n\n export interface WriteFragmentOptions<TData, TVariables>\n extends Fragment<TVariables, TData>, WriteOptions<TData> {}\n\n export interface UpdateQueryOptions<TData, TVariables>\n extends Omit<(\n ReadQueryOptions<TData, TVariables> &\n WriteQueryOptions<TData, TVariables>\n ), 'data'> {}\n\n export interface UpdateFragmentOptions<TData, TVariables>\n extends Omit<(\n ReadFragmentOptions<TData, TVariables> &\n WriteFragmentOptions<TData, TVariables>\n ), 'data'> {}\n\n export type DiffResult<T> = {\n result?: T;\n complete?: boolean;\n missing?: MissingFieldError[];\n fromOptimisticTransaction?: boolean;\n }\n}\n\n/**\n * A proxy to the normalized data living in our store. This interface allows a\n * user to read and write denormalized data which feels natural to the user\n * whilst in the background this data is being converted into the normalized\n * store format.\n */\nexport interface DataProxy {\n /**\n * Reads a GraphQL query from the root query id.\n */\n readQuery<QueryType, TVariables = any>(\n options: DataProxy.ReadQueryOptions<QueryType, TVariables>,\n optimistic?: boolean,\n ): QueryType | null;\n\n /**\n * Reads a GraphQL fragment from any arbitrary id. If there is more than\n * one fragment in the provided document then a `fragmentName` must be\n * provided to select the correct fragment.\n */\n readFragment<FragmentType, TVariables = any>(\n options: DataProxy.ReadFragmentOptions<FragmentType, TVariables>,\n optimistic?: boolean,\n ): FragmentType | null;\n\n /**\n * Writes a GraphQL query to the root query id.\n */\n writeQuery<TData = any, TVariables = any>(\n options: DataProxy.WriteQueryOptions<TData, TVariables>,\n ): Reference | undefined;\n\n /**\n * Writes a GraphQL fragment to any arbitrary id. If there is more than\n * one fragment in the provided document then a `fragmentName` must be\n * provided to select the correct fragment.\n */\n writeFragment<TData = any, TVariables = any>(\n options: DataProxy.WriteFragmentOptions<TData, TVariables>,\n ): Reference | undefined;\n}\n"]}
1
+ {"version":3,"file":"DataProxy.js","sourceRoot":"","sources":["../../../../src/cache/core/types/DataProxy.ts"],"names":[],"mappings":"","sourcesContent":["import type { DocumentNode } from 'graphql'; // ignore-comment eslint-disable-line import/no-extraneous-dependencies, import/no-unresolved\nimport type { TypedDocumentNode } from '@graphql-typed-document-node/core';\n\nimport type { MissingFieldError } from './common';\nimport type { Reference } from '../../../utilities';\n\nexport namespace DataProxy {\n export interface Query<TVariables, TData> {\n /**\n * The GraphQL query shape to be used constructed using the `gql` template\n * string tag from `graphql-tag`. The query will be used to determine the\n * shape of the data to be read.\n */\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * Any variables that the GraphQL query may depend on.\n */\n variables?: TVariables;\n\n /**\n * The root id to be used. Defaults to \"ROOT_QUERY\", which is the ID of the\n * root query object. This property makes writeQuery capable of writing data\n * to any object in the cache.\n */\n id?: string;\n }\n\n export interface Fragment<TVariables, TData> {\n /**\n * The root id to be used. This id should take the same form as the\n * value returned by your `dataIdFromObject` function. If a value with your\n * id does not exist in the store, `null` will be returned.\n */\n id?: string;\n\n /**\n * A GraphQL document created using the `gql` template string tag from\n * `graphql-tag` with one or more fragments which will be used to determine\n * the shape of data to read. If you provide more than one fragment in this\n * document then you must also specify `fragmentName` to select a single.\n */\n fragment: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * The name of the fragment in your GraphQL document to be used. If you do\n * not provide a `fragmentName` and there is only one fragment in your\n * `fragment` document then that fragment will be used.\n */\n fragmentName?: string;\n\n /**\n * Any variables that your GraphQL fragments depend on.\n */\n variables?: TVariables;\n }\n\n export interface ReadQueryOptions<TData, TVariables>\n extends Query<TVariables, TData> {\n /**\n * Whether to return incomplete data rather than null.\n * Defaults to false.\n */\n returnPartialData?: boolean;\n /**\n * Whether to read from optimistic or non-optimistic cache data. If\n * this named option is provided, the optimistic parameter of the\n * readQuery method can be omitted. Defaults to false.\n */\n optimistic?: boolean;\n /**\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n */\n canonizeResults?: boolean;\n }\n\n export interface ReadFragmentOptions<TData, TVariables>\n extends Fragment<TVariables, TData> {\n /**\n * Whether to return incomplete data rather than null.\n * Defaults to false.\n */\n returnPartialData?: boolean;\n /**\n * Whether to read from optimistic or non-optimistic cache data. If\n * this named option is provided, the optimistic parameter of the\n * readQuery method can be omitted. Defaults to false.\n */\n optimistic?: boolean;\n /**\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n */\n canonizeResults?: boolean;\n }\n\n export interface WriteOptions<TData> {\n /**\n * The data you will be writing to the store.\n */\n data: TData;\n /**\n * Whether to notify query watchers (default: true).\n */\n broadcast?: boolean;\n /**\n * When true, ignore existing field data rather than merging it with\n * incoming data (default: false).\n */\n overwrite?: boolean;\n }\n\n export interface WriteQueryOptions<TData, TVariables>\n extends Query<TVariables, TData>, WriteOptions<TData> {}\n\n export interface WriteFragmentOptions<TData, TVariables>\n extends Fragment<TVariables, TData>, WriteOptions<TData> {}\n\n export interface UpdateQueryOptions<TData, TVariables>\n extends Omit<(\n ReadQueryOptions<TData, TVariables> &\n WriteQueryOptions<TData, TVariables>\n ), 'data'> {}\n\n export interface UpdateFragmentOptions<TData, TVariables>\n extends Omit<(\n ReadFragmentOptions<TData, TVariables> &\n WriteFragmentOptions<TData, TVariables>\n ), 'data'> {}\n\n export type DiffResult<T> = {\n result?: T;\n complete?: boolean;\n missing?: MissingFieldError[];\n fromOptimisticTransaction?: boolean;\n }\n}\n\n/**\n * A proxy to the normalized data living in our store. This interface allows a\n * user to read and write denormalized data which feels natural to the user\n * whilst in the background this data is being converted into the normalized\n * store format.\n */\nexport interface DataProxy {\n /**\n * Reads a GraphQL query from the root query id.\n */\n readQuery<QueryType, TVariables = any>(\n options: DataProxy.ReadQueryOptions<QueryType, TVariables>,\n optimistic?: boolean,\n ): QueryType | null;\n\n /**\n * Reads a GraphQL fragment from any arbitrary id. If there is more than\n * one fragment in the provided document then a `fragmentName` must be\n * provided to select the correct fragment.\n */\n readFragment<FragmentType, TVariables = any>(\n options: DataProxy.ReadFragmentOptions<FragmentType, TVariables>,\n optimistic?: boolean,\n ): FragmentType | null;\n\n /**\n * Writes a GraphQL query to the root query id.\n */\n writeQuery<TData = any, TVariables = any>(\n options: DataProxy.WriteQueryOptions<TData, TVariables>,\n ): Reference | undefined;\n\n /**\n * Writes a GraphQL fragment to any arbitrary id. If there is more than\n * one fragment in the provided document then a `fragmentName` must be\n * provided to select the correct fragment.\n */\n writeFragment<TData = any, TVariables = any>(\n options: DataProxy.WriteFragmentOptions<TData, TVariables>,\n ): Reference | undefined;\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { DocumentNode, FieldNode } from 'graphql';
2
- import { Reference, StoreObject, StoreValue, isReference } from '../../../utilities';
3
- import { StorageType } from '../../inmemory/policies';
1
+ import type { DocumentNode, FieldNode } from 'graphql';
2
+ import type { Reference, StoreObject, StoreValue, isReference } from '../../../utilities';
3
+ import type { StorageType } from '../../inmemory/policies';
4
4
  export type SafeReadonly<T> = T extends object ? Readonly<T> : T;
5
5
  export type MissingTree = string | {
6
6
  readonly [key: string]: MissingTree;
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/cache/core/types/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAStD,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,QAAQ,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AAC;SAC1B;QAIA,KAAY,CAAC,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;;IACxD,CAAC;IAGH,wBAAC;AAAD,CAAC,AAzBD,CAAuC,KAAK,GAyB3C","sourcesContent":["import { DocumentNode, FieldNode } from 'graphql';\n\nimport {\n Reference,\n StoreObject,\n StoreValue,\n isReference,\n} from '../../../utilities';\n\nimport { StorageType } from '../../inmemory/policies';\n\n// The Readonly<T> type only really works for object types, since it marks\n// all of the object's properties as readonly, but there are many cases when\n// a generic type parameter like TExisting might be a string or some other\n// primitive type, in which case we need to avoid wrapping it with Readonly.\n// SafeReadonly<string> collapses to just string, which makes string\n// assignable to SafeReadonly<any>, whereas string is not assignable to\n// Readonly<any>, somewhat surprisingly.\nexport type SafeReadonly<T> = T extends object ? Readonly<T> : T;\n\nexport type MissingTree = string | {\n readonly [key: string]: MissingTree;\n};\n\nexport class MissingFieldError extends Error {\n constructor(\n public readonly message: string,\n public readonly path: MissingTree | Array<string | number>,\n public readonly query: DocumentNode,\n public readonly variables?: Record<string, any>,\n ) {\n // 'Error' breaks prototype chain here\n super(message);\n\n if (Array.isArray(this.path)) {\n this.missing = this.message;\n for (let i = this.path.length - 1; i >= 0; --i) {\n this.missing = { [this.path[i]]: this.missing };\n }\n } else {\n this.missing = this.path;\n }\n\n // We're not using `Object.setPrototypeOf` here as it isn't fully supported\n // on Android (see issue #3236).\n (this as any).__proto__ = MissingFieldError.prototype;\n }\n\n public readonly missing: MissingTree;\n}\n\nexport interface FieldSpecifier {\n typename?: string;\n fieldName: string;\n field?: FieldNode;\n args?: Record<string, any>;\n variables?: Record<string, any>;\n}\n\nexport interface ReadFieldOptions extends FieldSpecifier {\n from?: StoreObject | Reference;\n}\n\nexport interface ReadFieldFunction {\n <V = StoreValue>(options: ReadFieldOptions): SafeReadonly<V> | undefined;\n <V = StoreValue>(\n fieldName: string,\n from?: StoreObject | Reference,\n ): SafeReadonly<V> | undefined;\n}\n\nexport type ToReferenceFunction = (\n objOrIdOrRef: StoreObject | string | Reference,\n mergeIntoStore?: boolean,\n) => Reference | undefined;\n\nexport type CanReadFunction = (value: StoreValue) => boolean;\n\nexport type ModifierDetails = {\n DELETE: any;\n INVALIDATE: any;\n fieldName: string;\n storeFieldName: string;\n readField: ReadFieldFunction;\n canRead: CanReadFunction;\n isReference: typeof isReference;\n toReference: ToReferenceFunction;\n storage: StorageType;\n}\n\nexport type Modifier<T> = (value: T, details: ModifierDetails) => T;\n\nexport type Modifiers = {\n [fieldName: string]: Modifier<any>;\n};\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../src/cache/core/types/common.ts"],"names":[],"mappings":";AAwBA;IAAuC,qCAAK;IAC1C,2BACkB,OAAe,EACf,IAA0C,EAC1C,KAAmB,EACnB,SAA+B;;QAJjD,YAOE,kBAAM,OAAO,CAAC,SAcf;QApBiB,aAAO,GAAP,OAAO,CAAQ;QACf,UAAI,GAAJ,IAAI,CAAsC;QAC1C,WAAK,GAAL,KAAK,CAAc;QACnB,eAAS,GAAT,SAAS,CAAsB;QAK/C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAI,CAAC,IAAI,CAAC,EAAE;YAC5B,KAAI,CAAC,OAAO,GAAG,KAAI,CAAC,OAAO,CAAC;YAC5B,KAAK,IAAI,CAAC,GAAG,KAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE;gBAC9C,KAAI,CAAC,OAAO,aAAK,GAAC,KAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAG,KAAI,CAAC,OAAO,KAAE,CAAC;aACjD;SACF;aAAM;YACL,KAAI,CAAC,OAAO,GAAG,KAAI,CAAC,IAAI,CAAC;SAC1B;QAIA,KAAY,CAAC,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;;IACxD,CAAC;IAGH,wBAAC;AAAD,CAAC,AAzBD,CAAuC,KAAK,GAyB3C","sourcesContent":["import type { DocumentNode, FieldNode } from 'graphql';\n\nimport type {\n Reference,\n StoreObject,\n StoreValue,\n isReference,\n} from '../../../utilities';\n\nimport type { StorageType } from '../../inmemory/policies';\n\n// The Readonly<T> type only really works for object types, since it marks\n// all of the object's properties as readonly, but there are many cases when\n// a generic type parameter like TExisting might be a string or some other\n// primitive type, in which case we need to avoid wrapping it with Readonly.\n// SafeReadonly<string> collapses to just string, which makes string\n// assignable to SafeReadonly<any>, whereas string is not assignable to\n// Readonly<any>, somewhat surprisingly.\nexport type SafeReadonly<T> = T extends object ? Readonly<T> : T;\n\nexport type MissingTree = string | {\n readonly [key: string]: MissingTree;\n};\n\nexport class MissingFieldError extends Error {\n constructor(\n public readonly message: string,\n public readonly path: MissingTree | Array<string | number>,\n public readonly query: DocumentNode,\n public readonly variables?: Record<string, any>,\n ) {\n // 'Error' breaks prototype chain here\n super(message);\n\n if (Array.isArray(this.path)) {\n this.missing = this.message;\n for (let i = this.path.length - 1; i >= 0; --i) {\n this.missing = { [this.path[i]]: this.missing };\n }\n } else {\n this.missing = this.path;\n }\n\n // We're not using `Object.setPrototypeOf` here as it isn't fully supported\n // on Android (see issue #3236).\n (this as any).__proto__ = MissingFieldError.prototype;\n }\n\n public readonly missing: MissingTree;\n}\n\nexport interface FieldSpecifier {\n typename?: string;\n fieldName: string;\n field?: FieldNode;\n args?: Record<string, any>;\n variables?: Record<string, any>;\n}\n\nexport interface ReadFieldOptions extends FieldSpecifier {\n from?: StoreObject | Reference;\n}\n\nexport interface ReadFieldFunction {\n <V = StoreValue>(options: ReadFieldOptions): SafeReadonly<V> | undefined;\n <V = StoreValue>(\n fieldName: string,\n from?: StoreObject | Reference,\n ): SafeReadonly<V> | undefined;\n}\n\nexport type ToReferenceFunction = (\n objOrIdOrRef: StoreObject | string | Reference,\n mergeIntoStore?: boolean,\n) => Reference | undefined;\n\nexport type CanReadFunction = (value: StoreValue) => boolean;\n\nexport type ModifierDetails = {\n DELETE: any;\n INVALIDATE: any;\n fieldName: string;\n storeFieldName: string;\n readField: ReadFieldFunction;\n canRead: CanReadFunction;\n isReference: typeof isReference;\n toReference: ToReferenceFunction;\n storage: StorageType;\n}\n\nexport type Modifier<T> = (value: T, details: ModifierDetails) => T;\n\nexport type Modifiers = {\n [fieldName: string]: Modifier<any>;\n};\n"]}
@@ -1,9 +1,9 @@
1
1
  import { Trie } from '@wry/trie';
2
- import { StoreValue, StoreObject, Reference } from '../../utilities';
3
- import { NormalizedCache, NormalizedCacheObject } from './types';
4
- import { Policies, StorageType } from './policies';
5
- import { Cache } from '../core/types/Cache';
6
- import { SafeReadonly, Modifier, Modifiers, ToReferenceFunction, CanReadFunction } from '../core/types/common';
2
+ import type { StoreValue, StoreObject, Reference } from '../../utilities';
3
+ import type { NormalizedCache, NormalizedCacheObject } from './types';
4
+ import type { Policies, StorageType } from './policies';
5
+ import type { Cache } from '../core/types/Cache';
6
+ import type { SafeReadonly, Modifier, Modifiers, ToReferenceFunction, CanReadFunction } from '../core/types/common';
7
7
  export declare abstract class EntityStore implements NormalizedCache {
8
8
  readonly policies: Policies;
9
9
  readonly group: CacheGroup;
@@ -1 +1 @@
1
- {"version":3,"file":"entityStore.d.ts","sourceRoot":"","sources":["../../../src/cache/inmemory/entityStore.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAEL,UAAU,EACV,WAAW,EACX,SAAS,EAMV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EAET,mBAAmB,EACnB,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAM9B,8BAAsB,WAAY,YAAW,eAAe;aAIxC,QAAQ,EAAE,QAAQ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";
2
+ import { invariant } from "../../utilities/globals/index.js";
3
3
  import { dep } from 'optimism';
4
4
  import { equal } from '@wry/equality';
5
5
  import { Trie } from '@wry/trie';
@@ -91,7 +91,7 @@ var EntityStore = (function () {
91
91
  : newer;
92
92
  if (!incoming)
93
93
  return;
94
- __DEV__ ? invariant(typeof dataId === "string", "store.merge expects a string ID") : invariant(typeof dataId === "string", 1);
94
+ invariant(typeof dataId === "string", 1);
95
95
  var merged = new DeepMerger(storeObjectReconciler).merge(existing, incoming);
96
96
  this.data[dataId] = merged;
97
97
  if (merged !== existing) {