@apollo/client 4.0.12-beta.0 → 4.0.13

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 (340) hide show
  1. package/CHANGELOG.md +10 -194
  2. package/__cjs/cache/core/cache.cjs +48 -169
  3. package/__cjs/cache/core/cache.cjs.map +1 -1
  4. package/__cjs/cache/core/cache.d.cts +25 -94
  5. package/__cjs/cache/core/types/Cache.d.cts +17 -49
  6. package/__cjs/cache/index.cjs.map +1 -1
  7. package/__cjs/cache/index.d.cts +1 -1
  8. package/__cjs/cache/inmemory/entityStore.cjs +4 -6
  9. package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
  10. package/__cjs/cache/inmemory/fragmentRegistry.cjs +5 -0
  11. package/__cjs/cache/inmemory/fragmentRegistry.cjs.map +1 -1
  12. package/__cjs/cache/inmemory/helpers.d.cts +1 -1
  13. package/__cjs/cache/inmemory/inMemoryCache.cjs +1 -15
  14. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  15. package/__cjs/cache/inmemory/inMemoryCache.d.cts +0 -1
  16. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  17. package/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
  18. package/__cjs/cache/inmemory/policies.cjs +17 -56
  19. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  20. package/__cjs/cache/inmemory/policies.d.cts +6 -30
  21. package/__cjs/cache/inmemory/readFromStore.cjs +3 -3
  22. package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
  23. package/__cjs/cache/inmemory/types.d.cts +0 -2
  24. package/__cjs/cache/inmemory/writeToStore.cjs +10 -24
  25. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  26. package/__cjs/cache/inmemory/writeToStore.d.cts +1 -2
  27. package/__cjs/core/ApolloClient.cjs +49 -31
  28. package/__cjs/core/ApolloClient.cjs.map +1 -1
  29. package/__cjs/core/ApolloClient.d.cts +17 -143
  30. package/__cjs/core/ObservableQuery.cjs +128 -162
  31. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  32. package/__cjs/core/ObservableQuery.d.cts +0 -1
  33. package/__cjs/core/QueryInfo.cjs +1 -9
  34. package/__cjs/core/QueryInfo.cjs.map +1 -1
  35. package/__cjs/core/QueryInfo.d.cts +1 -2
  36. package/__cjs/core/QueryManager.cjs +24 -46
  37. package/__cjs/core/QueryManager.cjs.map +1 -1
  38. package/__cjs/core/QueryManager.d.cts +2 -18
  39. package/__cjs/incremental/handlers/defer20220824.cjs +19 -44
  40. package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
  41. package/__cjs/incremental/handlers/defer20220824.d.cts +7 -15
  42. package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
  43. package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
  44. package/__cjs/incremental/index.cjs +1 -3
  45. package/__cjs/incremental/index.cjs.map +1 -1
  46. package/__cjs/incremental/index.d.cts +0 -1
  47. package/__cjs/incremental/types.d.cts +0 -9
  48. package/__cjs/invariantErrorCodes.cjs +62 -78
  49. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +1 -13
  50. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
  51. package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +1 -1
  52. package/__cjs/link/core/ApolloLink.cjs +3 -3
  53. package/__cjs/link/http/checkFetcher.cjs +1 -1
  54. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
  55. package/__cjs/link/persisted-queries/index.cjs +2 -2
  56. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +51 -50
  57. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
  58. package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +3 -0
  59. package/__cjs/link/ws/index.cjs +1 -1
  60. package/__cjs/local-state/LocalState.cjs +14 -28
  61. package/__cjs/local-state/LocalState.cjs.map +1 -1
  62. package/__cjs/local-state/LocalState.d.cts +2 -3
  63. package/__cjs/masking/types.d.cts +1 -2
  64. package/__cjs/react/hooks/internal/useDeepMemo.cjs +0 -2
  65. package/__cjs/react/hooks/internal/useDeepMemo.cjs.map +1 -1
  66. package/__cjs/react/hooks/useApolloClient.cjs +1 -1
  67. package/__cjs/react/hooks/useApolloClient.cjs.map +1 -1
  68. package/__cjs/react/hooks/useApolloClient.d.cts +1 -1
  69. package/__cjs/react/hooks/useBackgroundQuery.cjs +3 -1
  70. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  71. package/__cjs/react/hooks/useFragment.cjs +87 -38
  72. package/__cjs/react/hooks/useFragment.cjs.map +1 -1
  73. package/__cjs/react/hooks/useFragment.d.cts +6 -65
  74. package/__cjs/react/hooks/useLazyQuery.cjs +0 -2
  75. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  76. package/__cjs/react/hooks/useMutation.cjs +1 -7
  77. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  78. package/__cjs/react/hooks/useMutation.d.cts +1 -13
  79. package/__cjs/react/hooks/useQuery.cjs +4 -1
  80. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  81. package/__cjs/react/hooks/useQuery.d.cts +1 -1
  82. package/__cjs/react/hooks/useQueryRefHandlers.cjs +3 -1
  83. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  84. package/__cjs/react/hooks/useReadQuery.cjs +3 -1
  85. package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
  86. package/__cjs/react/hooks/useSubscription.cjs +1 -1
  87. package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
  88. package/__cjs/react/hooks/useSuspenseFragment.cjs +16 -16
  89. package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
  90. package/__cjs/react/hooks/useSuspenseFragment.d.cts +7 -33
  91. package/__cjs/react/hooks/useSuspenseQuery.cjs +4 -4
  92. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  93. package/__cjs/react/internal/cache/FragmentReference.cjs +22 -3
  94. package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
  95. package/__cjs/react/internal/cache/FragmentReference.d.cts +4 -2
  96. package/__cjs/react/internal/cache/QueryReference.cjs +0 -16
  97. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  98. package/__cjs/react/internal/cache/QueryReference.d.cts +0 -5
  99. package/__cjs/react/internal/cache/SuspenseCache.cjs.map +1 -1
  100. package/__cjs/react/internal/cache/SuspenseCache.d.cts +1 -1
  101. package/__cjs/react/internal/cache/types.d.cts +2 -2
  102. package/__cjs/react/query-preloader/createQueryPreloader.cjs +1 -41
  103. package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
  104. package/__cjs/react/ssr/useSSRQuery.cjs +0 -1
  105. package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
  106. package/__cjs/utilities/DeepPartial.cjs.map +1 -1
  107. package/__cjs/utilities/DeepPartial.d.cts +1 -1
  108. package/__cjs/utilities/internal/DeepMerger.cjs +4 -36
  109. package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -1
  110. package/__cjs/utilities/internal/DeepMerger.d.cts +4 -20
  111. package/__cjs/utilities/internal/bindCacheKey.cjs +21 -0
  112. package/__cjs/utilities/internal/bindCacheKey.cjs.map +1 -0
  113. package/__cjs/utilities/internal/bindCacheKey.d.cts +15 -0
  114. package/__cjs/utilities/internal/compact.cjs +1 -1
  115. package/__cjs/utilities/internal/compact.cjs.map +1 -1
  116. package/__cjs/utilities/internal/constants.cjs +1 -17
  117. package/__cjs/utilities/internal/constants.cjs.map +1 -1
  118. package/__cjs/utilities/internal/constants.d.cts +0 -16
  119. package/__cjs/utilities/internal/getStoreKeyName.cjs +0 -1
  120. package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
  121. package/__cjs/utilities/internal/index.cjs +4 -8
  122. package/__cjs/utilities/internal/index.cjs.map +1 -1
  123. package/__cjs/utilities/internal/index.d.cts +2 -4
  124. package/__cjs/utilities/internal/memoize.cjs +2 -2
  125. package/__cjs/utilities/internal/memoize.cjs.map +1 -1
  126. package/__cjs/utilities/internal/memoize.d.cts +1 -2
  127. package/__cjs/version.cjs +1 -1
  128. package/__cjs/version.cjs.map +1 -1
  129. package/cache/core/cache.d.ts +25 -94
  130. package/cache/core/cache.js +51 -172
  131. package/cache/core/cache.js.map +1 -1
  132. package/cache/core/types/Cache.d.ts +17 -49
  133. package/cache/core/types/Cache.js.map +1 -1
  134. package/cache/index.d.ts +1 -1
  135. package/cache/index.js.map +1 -1
  136. package/cache/inmemory/entityStore.js +4 -6
  137. package/cache/inmemory/entityStore.js.map +1 -1
  138. package/cache/inmemory/fragmentRegistry.js +6 -1
  139. package/cache/inmemory/fragmentRegistry.js.map +1 -1
  140. package/cache/inmemory/helpers.d.ts +1 -1
  141. package/cache/inmemory/inMemoryCache.d.ts +0 -1
  142. package/cache/inmemory/inMemoryCache.js +1 -15
  143. package/cache/inmemory/inMemoryCache.js.map +1 -1
  144. package/cache/inmemory/key-extractor.js +1 -1
  145. package/cache/inmemory/key-extractor.js.map +1 -1
  146. package/cache/inmemory/policies.d.ts +6 -30
  147. package/cache/inmemory/policies.js +7 -45
  148. package/cache/inmemory/policies.js.map +1 -1
  149. package/cache/inmemory/readFromStore.js +3 -3
  150. package/cache/inmemory/readFromStore.js.map +1 -1
  151. package/cache/inmemory/types.d.ts +0 -2
  152. package/cache/inmemory/types.js.map +1 -1
  153. package/cache/inmemory/writeToStore.d.ts +1 -2
  154. package/cache/inmemory/writeToStore.js +12 -26
  155. package/cache/inmemory/writeToStore.js.map +1 -1
  156. package/core/ApolloClient.d.ts +17 -143
  157. package/core/ApolloClient.js +50 -32
  158. package/core/ApolloClient.js.map +1 -1
  159. package/core/ObservableQuery.d.ts +0 -1
  160. package/core/ObservableQuery.js +131 -165
  161. package/core/ObservableQuery.js.map +1 -1
  162. package/core/QueryInfo.d.ts +1 -2
  163. package/core/QueryInfo.js +2 -10
  164. package/core/QueryInfo.js.map +1 -1
  165. package/core/QueryManager.d.ts +2 -18
  166. package/core/QueryManager.js +25 -47
  167. package/core/QueryManager.js.map +1 -1
  168. package/incremental/handlers/defer20220824.d.ts +7 -15
  169. package/incremental/handlers/defer20220824.js +19 -44
  170. package/incremental/handlers/defer20220824.js.map +1 -1
  171. package/incremental/handlers/notImplemented.js +1 -1
  172. package/incremental/handlers/notImplemented.js.map +1 -1
  173. package/incremental/index.d.ts +0 -1
  174. package/incremental/index.js +2 -3
  175. package/incremental/index.js.map +1 -1
  176. package/incremental/types.d.ts +0 -9
  177. package/incremental/types.js.map +1 -1
  178. package/invariantErrorCodes.js +62 -78
  179. package/link/client-awareness/ClientAwarenessLink.d.ts +1 -1
  180. package/link/client-awareness/ClientAwarenessLink.js +1 -13
  181. package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
  182. package/link/core/ApolloLink.js +3 -3
  183. package/link/http/checkFetcher.js +1 -1
  184. package/link/http/parseAndCheckHttpResponse.js +1 -1
  185. package/link/persisted-queries/index.js +2 -2
  186. package/link/remove-typename/removeTypenameFromVariables.d.ts +3 -0
  187. package/link/remove-typename/removeTypenameFromVariables.js +51 -50
  188. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  189. package/link/ws/index.js +1 -1
  190. package/local-state/LocalState.d.ts +2 -3
  191. package/local-state/LocalState.js +14 -28
  192. package/local-state/LocalState.js.map +1 -1
  193. package/masking/types.d.ts +1 -2
  194. package/masking/types.js.map +1 -1
  195. package/package.json +1 -15
  196. package/react/hooks/internal/useDeepMemo.js +0 -2
  197. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  198. package/react/hooks/useApolloClient.d.ts +1 -1
  199. package/react/hooks/useApolloClient.js +1 -1
  200. package/react/hooks/useApolloClient.js.map +1 -1
  201. package/react/hooks/useBackgroundQuery.js +3 -1
  202. package/react/hooks/useBackgroundQuery.js.map +1 -1
  203. package/react/hooks/useFragment.d.ts +6 -65
  204. package/react/hooks/useFragment.js +87 -38
  205. package/react/hooks/useFragment.js.map +1 -1
  206. package/react/hooks/useLazyQuery.js +0 -2
  207. package/react/hooks/useLazyQuery.js.map +1 -1
  208. package/react/hooks/useMutation.d.ts +1 -13
  209. package/react/hooks/useMutation.js +1 -7
  210. package/react/hooks/useMutation.js.map +1 -1
  211. package/react/hooks/useQuery.js +4 -1
  212. package/react/hooks/useQuery.js.map +1 -1
  213. package/react/hooks/useQueryRefHandlers.js +3 -1
  214. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  215. package/react/hooks/useReadQuery.js +3 -1
  216. package/react/hooks/useReadQuery.js.map +1 -1
  217. package/react/hooks/useSubscription.js +1 -1
  218. package/react/hooks/useSubscription.js.map +1 -1
  219. package/react/hooks/useSuspenseFragment.d.ts +7 -33
  220. package/react/hooks/useSuspenseFragment.js +17 -17
  221. package/react/hooks/useSuspenseFragment.js.map +1 -1
  222. package/react/hooks/useSuspenseQuery.js +4 -4
  223. package/react/hooks/useSuspenseQuery.js.map +1 -1
  224. package/react/hooks-compiled/internal/useDeepMemo.js +0 -2
  225. package/react/hooks-compiled/internal/useDeepMemo.js.map +1 -1
  226. package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js +2 -0
  227. package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js.map +1 -1
  228. package/react/hooks-compiled/useApolloClient.d.ts +1 -1
  229. package/react/hooks-compiled/useApolloClient.js +1 -1
  230. package/react/hooks-compiled/useApolloClient.js.map +1 -1
  231. package/react/hooks-compiled/useBackgroundQuery.js +3 -1
  232. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  233. package/react/hooks-compiled/useFragment.d.ts +6 -65
  234. package/react/hooks-compiled/useFragment.js +88 -110
  235. package/react/hooks-compiled/useFragment.js.map +1 -1
  236. package/react/hooks-compiled/useLazyQuery.js +0 -2
  237. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  238. package/react/hooks-compiled/useLoadableQuery.js +75 -69
  239. package/react/hooks-compiled/useMutation.d.ts +1 -13
  240. package/react/hooks-compiled/useMutation.js +13 -5
  241. package/react/hooks-compiled/useMutation.js.map +1 -1
  242. package/react/hooks-compiled/useQuery.js +56 -44
  243. package/react/hooks-compiled/useQuery.js.map +1 -1
  244. package/react/hooks-compiled/useQueryRefHandlers.js +5 -1
  245. package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
  246. package/react/hooks-compiled/useReadQuery.js +14 -77
  247. package/react/hooks-compiled/useReadQuery.js.map +1 -1
  248. package/react/hooks-compiled/useSubscription.js +93 -237
  249. package/react/hooks-compiled/useSubscription.js.map +1 -1
  250. package/react/hooks-compiled/useSuspenseFragment.d.ts +7 -33
  251. package/react/hooks-compiled/useSuspenseFragment.js +17 -17
  252. package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
  253. package/react/hooks-compiled/useSuspenseQuery.js +8 -4
  254. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  255. package/react/index.compiled.d.ts +1 -1
  256. package/react/index.compiled.js +1 -1
  257. package/react/index.compiled.js.map +1 -1
  258. package/react/internal/cache/FragmentReference.d.ts +4 -2
  259. package/react/internal/cache/FragmentReference.js +22 -3
  260. package/react/internal/cache/FragmentReference.js.map +1 -1
  261. package/react/internal/cache/QueryReference.d.ts +0 -5
  262. package/react/internal/cache/QueryReference.js +0 -16
  263. package/react/internal/cache/QueryReference.js.map +1 -1
  264. package/react/internal/cache/SuspenseCache.d.ts +1 -1
  265. package/react/internal/cache/SuspenseCache.js.map +1 -1
  266. package/react/internal/cache/types.d.ts +2 -2
  267. package/react/internal/cache/types.js.map +1 -1
  268. package/react/query-preloader/createQueryPreloader.js +1 -41
  269. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  270. package/react/ssr/useSSRQuery.js +0 -1
  271. package/react/ssr/useSSRQuery.js.map +1 -1
  272. package/utilities/DeepPartial.d.ts +1 -1
  273. package/utilities/DeepPartial.js.map +1 -1
  274. package/utilities/internal/DeepMerger.d.ts +4 -20
  275. package/utilities/internal/DeepMerger.js +4 -36
  276. package/utilities/internal/DeepMerger.js.map +1 -1
  277. package/utilities/internal/bindCacheKey.d.ts +15 -0
  278. package/utilities/internal/bindCacheKey.js +18 -0
  279. package/utilities/internal/bindCacheKey.js.map +1 -0
  280. package/utilities/internal/compact.js +1 -1
  281. package/utilities/internal/compact.js.map +1 -1
  282. package/utilities/internal/constants.d.ts +0 -16
  283. package/utilities/internal/constants.js +0 -16
  284. package/utilities/internal/constants.js.map +1 -1
  285. package/utilities/internal/getStoreKeyName.js +0 -1
  286. package/utilities/internal/getStoreKeyName.js.map +1 -1
  287. package/utilities/internal/index.d.ts +2 -4
  288. package/utilities/internal/index.js +2 -3
  289. package/utilities/internal/index.js.map +1 -1
  290. package/utilities/internal/memoize.d.ts +1 -2
  291. package/utilities/internal/memoize.js +2 -2
  292. package/utilities/internal/memoize.js.map +1 -1
  293. package/version.js +1 -1
  294. package/version.js.map +1 -1
  295. package/__cjs/incremental/handlers/graphql17Alpha9.cjs +0 -222
  296. package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +0 -1
  297. package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +0 -98
  298. package/__cjs/utilities/internal/combineLatestBatched.cjs +0 -71
  299. package/__cjs/utilities/internal/combineLatestBatched.cjs.map +0 -1
  300. package/__cjs/utilities/internal/combineLatestBatched.d.cts +0 -14
  301. package/__cjs/utilities/internal/mapObservableFragment.cjs +0 -27
  302. package/__cjs/utilities/internal/mapObservableFragment.cjs.map +0 -1
  303. package/__cjs/utilities/internal/mapObservableFragment.d.cts +0 -3
  304. package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs +0 -61
  305. package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs.map +0 -1
  306. package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.d.cts +0 -11
  307. package/__cjs/utilities/internal/ponyfills/index.cjs +0 -6
  308. package/__cjs/utilities/internal/ponyfills/index.cjs.map +0 -1
  309. package/__cjs/utilities/internal/ponyfills/index.d.cts +0 -3
  310. package/__cjs/utilities/internal/ponyfills/index.react-native.cjs +0 -6
  311. package/__cjs/utilities/internal/ponyfills/index.react-native.cjs.map +0 -1
  312. package/__cjs/utilities/internal/ponyfills/index.react-native.d.cts +0 -2
  313. package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs +0 -3
  314. package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs.map +0 -1
  315. package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.d.cts +0 -24
  316. package/incremental/handlers/graphql17Alpha9.d.ts +0 -98
  317. package/incremental/handlers/graphql17Alpha9.js +0 -218
  318. package/incremental/handlers/graphql17Alpha9.js.map +0 -1
  319. package/legacyEntryPoints/utilities/internal/ponyfills/index.d.ts +0 -1
  320. package/legacyEntryPoints/utilities/internal/ponyfills/index.js +0 -1
  321. package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.cjs +0 -1
  322. package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.d.cts +0 -1
  323. package/utilities/internal/combineLatestBatched.d.ts +0 -14
  324. package/utilities/internal/combineLatestBatched.js +0 -68
  325. package/utilities/internal/combineLatestBatched.js.map +0 -1
  326. package/utilities/internal/mapObservableFragment.d.ts +0 -3
  327. package/utilities/internal/mapObservableFragment.js +0 -24
  328. package/utilities/internal/mapObservableFragment.js.map +0 -1
  329. package/utilities/internal/ponyfills/FinalizationRegistry.d.ts +0 -11
  330. package/utilities/internal/ponyfills/FinalizationRegistry.js +0 -57
  331. package/utilities/internal/ponyfills/FinalizationRegistry.js.map +0 -1
  332. package/utilities/internal/ponyfills/index.d.ts +0 -3
  333. package/utilities/internal/ponyfills/index.js +0 -3
  334. package/utilities/internal/ponyfills/index.js.map +0 -1
  335. package/utilities/internal/ponyfills/index.react-native.d.ts +0 -2
  336. package/utilities/internal/ponyfills/index.react-native.js +0 -2
  337. package/utilities/internal/ponyfills/index.react-native.js.map +0 -1
  338. package/utilities/internal/types/ExtensionsWithStreamDetails.d.ts +0 -24
  339. package/utilities/internal/types/ExtensionsWithStreamDetails.js +0 -2
  340. package/utilities/internal/types/ExtensionsWithStreamDetails.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  import { equal } from "@wry/equality";
2
- import { BehaviorSubject, filter, Observable, share, Subject, tap } from "rxjs";
3
- import { isNetworkRequestInFlight, isNetworkRequestSettled, } from "@apollo/client/utilities";
2
+ import { BehaviorSubject, Observable, share, Subject, tap } from "rxjs";
3
+ import { isNetworkRequestInFlight } from "@apollo/client/utilities";
4
4
  import { __DEV__ } from "@apollo/client/utilities/environment";
5
- import { compact, equalByQuery, extensionsSymbol, filterMap, getOperationDefinition, getOperationName, getQueryDefinition, preventUnhandledRejection, toQueryResult, variablesUnknownSymbol, } from "@apollo/client/utilities/internal";
5
+ import { compact, equalByQuery, filterMap, getOperationDefinition, getOperationName, getQueryDefinition, preventUnhandledRejection, toQueryResult, variablesUnknownSymbol, } from "@apollo/client/utilities/internal";
6
6
  import { invariant } from "@apollo/client/utilities/invariant";
7
7
  import { NetworkStatus } from "./networkStatus.js";
8
8
  const { assign, hasOwnProperty } = Object;
@@ -61,9 +61,6 @@ export class ObservableQuery {
61
61
  get networkStatus() {
62
62
  return this.subject.getValue().result.networkStatus;
63
63
  }
64
- get cache() {
65
- return this.queryManager.cache;
66
- }
67
64
  constructor({ queryManager, options, transformedQuery = queryManager.transform(options.query), }) {
68
65
  this.queryManager = queryManager;
69
66
  // active state
@@ -76,7 +73,7 @@ export class ObservableQuery {
76
73
  // Make sure we don't store "standby" as the initialFetchPolicy.
77
74
  initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
78
75
  if (options[variablesUnknownSymbol]) {
79
- invariant(fetchPolicy === "standby", 80);
76
+ invariant(fetchPolicy === "standby", 77);
80
77
  this.variablesUnknown = true;
81
78
  }
82
79
  this.lastQuery = transformedQuery;
@@ -205,7 +202,7 @@ export class ObservableQuery {
205
202
  * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
206
203
  */
207
204
  getCacheDiff({ optimistic = true } = {}) {
208
- return this.cache.diff({
205
+ return this.queryManager.cache.diff({
209
206
  query: this.query,
210
207
  variables: this.variables,
211
208
  returnPartialData: true,
@@ -316,7 +313,7 @@ export class ObservableQuery {
316
313
  }
317
314
  },
318
315
  };
319
- const cancelWatch = this.cache.watch(watch);
316
+ const cancelWatch = this.queryManager.cache.watch(watch);
320
317
  this.unsubscribeFromCache = Object.assign(() => {
321
318
  this.unsubscribeFromCache = undefined;
322
319
  cancelWatch();
@@ -380,7 +377,7 @@ export class ObservableQuery {
380
377
  const queryDef = getQueryDefinition(this.query);
381
378
  const vars = queryDef.variableDefinitions;
382
379
  if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
383
- __DEV__ && invariant.warn(81, variables, queryDef.name?.value || queryDef);
380
+ __DEV__ && invariant.warn(78, variables, queryDef.name?.value || queryDef);
384
381
  }
385
382
  }
386
383
  if (variables && !equal(this.variables, variables)) {
@@ -396,7 +393,7 @@ export class ObservableQuery {
396
393
  fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
397
394
  invariant(
398
395
  this.options.fetchPolicy !== "cache-only",
399
- 82,
396
+ 79,
400
397
  getOperationName(this.query, "(anonymous)")
401
398
  );
402
399
  const combinedOptions = {
@@ -430,7 +427,7 @@ export class ObservableQuery {
430
427
  let wasUpdated = false;
431
428
  const isCached = this.options.fetchPolicy !== "no-cache";
432
429
  if (!isCached) {
433
- invariant(updateQuery, 83);
430
+ invariant(updateQuery, 80);
434
431
  }
435
432
  const { finalize, pushNotification } = this.pushOperation(NetworkStatus.fetchMore);
436
433
  pushNotification({
@@ -438,149 +435,109 @@ export class ObservableQuery {
438
435
  kind: "N",
439
436
  value: {},
440
437
  }, { shouldEmit: 3 /* EmitBehavior.networkStatusChange */ });
441
- const { promise, operator } = getTrackingOperatorPromise();
442
- const { observable } = this.queryManager.fetchObservableWithInfo(combinedOptions, { networkStatus: NetworkStatus.fetchMore, exposeExtensions: true });
443
- const subscription = observable
444
- .pipe(operator, filter((notification) => notification.kind === "N" && notification.source === "network"))
445
- .subscribe({
446
- next: (notification) => {
447
- wasUpdated = false;
448
- const fetchMoreResult = notification.value;
449
- const extensions = fetchMoreResult[extensionsSymbol];
450
- if (isNetworkRequestSettled(notification.value.networkStatus)) {
451
- finalize();
452
- }
453
- if (isCached) {
454
- // Separately getting a diff here before the batch - `onWatchUpdated` might be
455
- // called with an `undefined` `lastDiff` on the watcher if the cache was just subscribed to.
456
- const lastDiff = this.getCacheDiff();
457
- // Performing this cache update inside a cache.batch transaction ensures
458
- // any affected cache.watch watchers are notified at most once about any
459
- // updates. Most watchers will be using the QueryInfo class, which
460
- // responds to notifications by calling reobserveCacheFirst to deliver
461
- // fetchMore cache results back to this ObservableQuery.
462
- this.cache.batch({
463
- update: (cache) => {
464
- if (updateQuery) {
465
- cache.updateQuery({
466
- query: this.query,
467
- variables: this.variables,
468
- returnPartialData: true,
469
- optimistic: false,
470
- extensions,
471
- }, (previous) => updateQuery(previous, {
472
- fetchMoreResult: fetchMoreResult.data,
473
- variables: combinedOptions.variables,
474
- }));
475
- }
476
- else {
477
- // If we're using a field policy instead of updateQuery, the only
478
- // thing we need to do is write the new data to the cache using
479
- // combinedOptions.variables (instead of this.variables, which is
480
- // what this.updateQuery uses, because it works by abusing the
481
- // original field value, keyed by the original variables).
482
- cache.writeQuery({
483
- query: combinedOptions.query,
484
- variables: combinedOptions.variables,
485
- data: fetchMoreResult.data,
486
- extensions,
487
- });
488
- }
489
- },
490
- onWatchUpdated: (watch, diff) => {
491
- if (watch.watcher === this &&
492
- !equal(diff.result, lastDiff.result)) {
493
- wasUpdated = true;
494
- const lastResult = this.getCurrentResult();
495
- // Let the cache watch from resubscribeCache handle the final
496
- // result
497
- if (isNetworkRequestInFlight(fetchMoreResult.networkStatus)) {
498
- pushNotification({
499
- kind: "N",
500
- source: "network",
501
- value: {
502
- ...lastResult,
503
- networkStatus: (fetchMoreResult.networkStatus ===
504
- NetworkStatus.error) ?
505
- NetworkStatus.ready
506
- : fetchMoreResult.networkStatus,
507
- // will be overwritten anyways, just here for types sake
508
- loading: false,
509
- data: diff.result,
510
- dataState: fetchMoreResult.dataState === "streaming" ?
511
- "streaming"
512
- : "complete",
513
- },
514
- });
515
- }
516
- }
517
- },
518
- });
519
- }
520
- else {
521
- // There is a possibility `lastResult` may not be set when
522
- // `fetchMore` is called which would cause this to crash. This should
523
- // only happen if we haven't previously reported a result. We don't
524
- // quite know what the right behavior should be here since this block
525
- // of code runs after the fetch result has executed on the network.
526
- // We plan to let it crash in the meantime.
527
- //
528
- // If we get bug reports due to the `data` property access on
529
- // undefined, this should give us a real-world scenario that we can
530
- // use to test against and determine the right behavior. If we do end
531
- // up changing this behavior, this may require, for example, an
532
- // adjustment to the types on `updateQuery` since that function
533
- // expects that the first argument always contains previous result
534
- // data, but not `undefined`.
535
- const lastResult = this.getCurrentResult();
536
- const data = updateQuery(lastResult.data, {
537
- fetchMoreResult: fetchMoreResult.data,
538
- variables: combinedOptions.variables,
539
- });
540
- pushNotification({
541
- kind: "N",
542
- value: {
543
- ...lastResult,
544
- networkStatus: NetworkStatus.ready,
545
- // will be overwritten anyways, just here for types sake
546
- loading: false,
547
- data: data,
548
- dataState: lastResult.dataState === "streaming" ?
549
- "streaming"
550
- : "complete",
551
- },
552
- source: "network",
553
- });
554
- }
555
- },
556
- });
557
- return preventUnhandledRejection(promise
558
- .then((result) => toQueryResult(this.maskResult(result)))
438
+ return this.queryManager
439
+ .fetchQuery(combinedOptions, NetworkStatus.fetchMore)
440
+ .then((fetchMoreResult) => {
441
+ // disable the `fetchMore` override that is currently active
442
+ // the next updates caused by this should not be `fetchMore` anymore,
443
+ // but `ready` or whatever other calculated loading state is currently
444
+ // appropriate
445
+ finalize();
446
+ if (isCached) {
447
+ // Separately getting a diff here before the batch - `onWatchUpdated` might be
448
+ // called with an `undefined` `lastDiff` on the watcher if the cache was just subscribed to.
449
+ const lastDiff = this.getCacheDiff();
450
+ // Performing this cache update inside a cache.batch transaction ensures
451
+ // any affected cache.watch watchers are notified at most once about any
452
+ // updates. Most watchers will be using the QueryInfo class, which
453
+ // responds to notifications by calling reobserveCacheFirst to deliver
454
+ // fetchMore cache results back to this ObservableQuery.
455
+ this.queryManager.cache.batch({
456
+ update: (cache) => {
457
+ if (updateQuery) {
458
+ cache.updateQuery({
459
+ query: this.query,
460
+ variables: this.variables,
461
+ returnPartialData: true,
462
+ optimistic: false,
463
+ }, (previous) => updateQuery(previous, {
464
+ fetchMoreResult: fetchMoreResult.data,
465
+ variables: combinedOptions.variables,
466
+ }));
467
+ }
468
+ else {
469
+ // If we're using a field policy instead of updateQuery, the only
470
+ // thing we need to do is write the new data to the cache using
471
+ // combinedOptions.variables (instead of this.variables, which is
472
+ // what this.updateQuery uses, because it works by abusing the
473
+ // original field value, keyed by the original variables).
474
+ cache.writeQuery({
475
+ query: combinedOptions.query,
476
+ variables: combinedOptions.variables,
477
+ data: fetchMoreResult.data,
478
+ });
479
+ }
480
+ },
481
+ onWatchUpdated: (watch, diff) => {
482
+ if (watch.watcher === this &&
483
+ !equal(diff.result, lastDiff.result)) {
484
+ wasUpdated = true;
485
+ }
486
+ },
487
+ });
488
+ }
489
+ else {
490
+ // There is a possibility `lastResult` may not be set when
491
+ // `fetchMore` is called which would cause this to crash. This should
492
+ // only happen if we haven't previously reported a result. We don't
493
+ // quite know what the right behavior should be here since this block
494
+ // of code runs after the fetch result has executed on the network.
495
+ // We plan to let it crash in the meantime.
496
+ //
497
+ // If we get bug reports due to the `data` property access on
498
+ // undefined, this should give us a real-world scenario that we can
499
+ // use to test against and determine the right behavior. If we do end
500
+ // up changing this behavior, this may require, for example, an
501
+ // adjustment to the types on `updateQuery` since that function
502
+ // expects that the first argument always contains previous result
503
+ // data, but not `undefined`.
504
+ const lastResult = this.getCurrentResult();
505
+ const data = updateQuery(lastResult.data, {
506
+ fetchMoreResult: fetchMoreResult.data,
507
+ variables: combinedOptions.variables,
508
+ });
509
+ // was reportResult
510
+ pushNotification({
511
+ kind: "N",
512
+ value: {
513
+ ...lastResult,
514
+ networkStatus: NetworkStatus.ready,
515
+ // will be overwritten anyways, just here for types sake
516
+ loading: false,
517
+ data: data,
518
+ dataState: lastResult.dataState === "streaming" ? "streaming" : "complete",
519
+ },
520
+ source: "network",
521
+ });
522
+ }
523
+ return this.maskResult(fetchMoreResult);
524
+ })
559
525
  .finally(() => {
560
- subscription.unsubscribe();
526
+ // call `finalize` a second time in case the `.then` case above was not reached
561
527
  finalize();
528
+ // In case the cache writes above did not generate a broadcast
529
+ // notification (which would have been intercepted by onWatchUpdated),
530
+ // likely because the written data were the same as what was already in
531
+ // the cache, we still want fetchMore to deliver its final loading:false
532
+ // result with the unchanged data.
562
533
  if (isCached && !wasUpdated) {
563
- const lastResult = this.getCurrentResult();
564
- if (lastResult.dataState === "streaming") {
565
- pushNotification({
566
- kind: "N",
567
- source: "network",
568
- value: {
569
- ...lastResult,
570
- dataState: "complete",
571
- networkStatus: NetworkStatus.ready,
572
- },
573
- });
574
- }
575
- else {
576
- pushNotification({
577
- kind: "N",
578
- source: "newNetworkStatus",
579
- value: {},
580
- }, { shouldEmit: 1 /* EmitBehavior.force */ });
581
- }
534
+ pushNotification({
535
+ kind: "N",
536
+ source: "newNetworkStatus",
537
+ value: {},
538
+ }, { shouldEmit: 1 /* EmitBehavior.force */ });
582
539
  }
583
- }));
540
+ });
584
541
  }
585
542
  // XXX the subscription variables are separate from the query variables.
586
543
  // if you want to update subscription variables, right now you have to do that separately,
@@ -606,7 +563,7 @@ export class ObservableQuery {
606
563
  onError(error);
607
564
  }
608
565
  else {
609
- invariant.error(84, error);
566
+ invariant.error(81, error);
610
567
  }
611
568
  return;
612
569
  }
@@ -684,7 +641,7 @@ export class ObservableQuery {
684
641
  previousData: result,
685
642
  });
686
643
  if (newResult) {
687
- this.cache.writeQuery({
644
+ queryManager.cache.writeQuery({
688
645
  query: this.options.query,
689
646
  data: newResult,
690
647
  variables: this.variables,
@@ -850,7 +807,7 @@ export class ObservableQuery {
850
807
  if (!this.didWarnCacheOnlyPolling &&
851
808
  pollInterval &&
852
809
  fetchPolicy === "cache-only") {
853
- __DEV__ && invariant.warn(85, getOperationName(this.query, "(anonymous)"));
810
+ __DEV__ && invariant.warn(82, getOperationName(this.query, "(anonymous)"));
854
811
  this.didWarnCacheOnlyPolling = true;
855
812
  }
856
813
  }
@@ -991,7 +948,15 @@ export class ObservableQuery {
991
948
  this.cancelPolling();
992
949
  }
993
950
  this.resubscribeCache();
994
- const { promise, operator: promiseOperator } = getTrackingOperatorPromise(
951
+ const { promise, operator: promiseOperator } = getTrackingOperatorPromise((value) => {
952
+ switch (value.kind) {
953
+ case "E":
954
+ throw value.error;
955
+ case "N":
956
+ if (value.source !== "newNetworkStatus" && !value.value.loading)
957
+ return value.value;
958
+ }
959
+ },
995
960
  // This default value should only be used when using a `fetchPolicy` of
996
961
  // `standby` since that fetch policy completes without emitting a
997
962
  // result. Since we are converting this to a QueryResult type, we
@@ -1113,8 +1078,8 @@ export class ObservableQuery {
1113
1078
  const { dirty } = this;
1114
1079
  this.resetNotifications();
1115
1080
  if (dirty &&
1116
- (this.options.fetchPolicy === "cache-only" ||
1117
- this.options.fetchPolicy === "cache-and-network" ||
1081
+ (this.options.fetchPolicy == "cache-only" ||
1082
+ this.options.fetchPolicy == "cache-and-network" ||
1118
1083
  !this.activeOperations.size)) {
1119
1084
  const diff = this.getCacheDiff();
1120
1085
  if (
@@ -1344,13 +1309,13 @@ export class ObservableQuery {
1344
1309
  }
1345
1310
  export function logMissingFieldErrors(missing) {
1346
1311
  if (__DEV__ && missing) {
1347
- __DEV__ && invariant.debug(86, missing);
1312
+ __DEV__ && invariant.debug(83, missing);
1348
1313
  }
1349
1314
  }
1350
1315
  function isEqualQuery(a, b) {
1351
1316
  return !!(a && b && a.query === b.query && equal(a.variables, b.variables));
1352
1317
  }
1353
- function getTrackingOperatorPromise(defaultValue) {
1318
+ function getTrackingOperatorPromise(filterMapCb, defaultValue) {
1354
1319
  let lastValue = defaultValue, resolve, reject;
1355
1320
  const promise = new Promise((res, rej) => {
1356
1321
  resolve = res;
@@ -1358,13 +1323,14 @@ function getTrackingOperatorPromise(defaultValue) {
1358
1323
  });
1359
1324
  const operator = tap({
1360
1325
  next(value) {
1361
- if (value.kind === "E") {
1362
- return reject(value.error);
1326
+ try {
1327
+ const newValue = filterMapCb(value);
1328
+ if (newValue !== undefined) {
1329
+ lastValue = newValue;
1330
+ }
1363
1331
  }
1364
- if (value.kind === "N" &&
1365
- value.source !== "newNetworkStatus" &&
1366
- !value.value.loading) {
1367
- lastValue = value.value;
1332
+ catch (error) {
1333
+ reject(error);
1368
1334
  }
1369
1335
  },
1370
1336
  finalize: () => {