@apollo/client 4.0.11 → 4.0.12-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 (317) hide show
  1. package/CHANGELOG.md +204 -0
  2. package/__cjs/cache/core/cache.cjs +216 -52
  3. package/__cjs/cache/core/cache.cjs.map +1 -1
  4. package/__cjs/cache/core/cache.d.cts +141 -25
  5. package/__cjs/cache/core/types/Cache.d.cts +77 -17
  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 +6 -4
  9. package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
  10. package/__cjs/cache/inmemory/helpers.d.cts +1 -1
  11. package/__cjs/cache/inmemory/inMemoryCache.cjs +62 -1
  12. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  13. package/__cjs/cache/inmemory/inMemoryCache.d.cts +48 -0
  14. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  15. package/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
  16. package/__cjs/cache/inmemory/policies.cjs +56 -17
  17. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  18. package/__cjs/cache/inmemory/policies.d.cts +30 -6
  19. package/__cjs/cache/inmemory/readFromStore.cjs +3 -3
  20. package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
  21. package/__cjs/cache/inmemory/types.d.cts +2 -0
  22. package/__cjs/cache/inmemory/writeToStore.cjs +24 -10
  23. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  24. package/__cjs/cache/inmemory/writeToStore.d.cts +2 -1
  25. package/__cjs/core/ApolloClient.cjs +31 -49
  26. package/__cjs/core/ApolloClient.cjs.map +1 -1
  27. package/__cjs/core/ApolloClient.d.cts +143 -17
  28. package/__cjs/core/ObservableQuery.cjs +162 -128
  29. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  30. package/__cjs/core/ObservableQuery.d.cts +1 -0
  31. package/__cjs/core/QueryInfo.cjs +9 -1
  32. package/__cjs/core/QueryInfo.cjs.map +1 -1
  33. package/__cjs/core/QueryInfo.d.cts +2 -1
  34. package/__cjs/core/QueryManager.cjs +46 -24
  35. package/__cjs/core/QueryManager.cjs.map +1 -1
  36. package/__cjs/core/QueryManager.d.cts +18 -2
  37. package/__cjs/incremental/handlers/defer20220824.cjs +44 -19
  38. package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
  39. package/__cjs/incremental/handlers/defer20220824.d.cts +15 -7
  40. package/__cjs/incremental/handlers/graphql17Alpha9.cjs +222 -0
  41. package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -0
  42. package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +98 -0
  43. package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
  44. package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
  45. package/__cjs/incremental/index.cjs +3 -1
  46. package/__cjs/incremental/index.cjs.map +1 -1
  47. package/__cjs/incremental/index.d.cts +1 -0
  48. package/__cjs/incremental/types.d.cts +9 -0
  49. package/__cjs/invariantErrorCodes.cjs +78 -62
  50. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +13 -1
  51. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
  52. package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +1 -1
  53. package/__cjs/link/core/ApolloLink.cjs +3 -3
  54. package/__cjs/link/error/index.cjs +1 -1
  55. package/__cjs/link/error/index.cjs.map +1 -1
  56. package/__cjs/link/error/index.d.cts +1 -1
  57. package/__cjs/link/http/checkFetcher.cjs +1 -1
  58. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
  59. package/__cjs/link/persisted-queries/index.cjs +2 -2
  60. package/__cjs/link/ws/index.cjs +1 -1
  61. package/__cjs/local-state/LocalState.cjs +28 -14
  62. package/__cjs/local-state/LocalState.cjs.map +1 -1
  63. package/__cjs/local-state/LocalState.d.cts +3 -2
  64. package/__cjs/masking/types.d.cts +2 -1
  65. package/__cjs/react/hooks/internal/useDeepMemo.cjs +2 -0
  66. package/__cjs/react/hooks/internal/useDeepMemo.cjs.map +1 -1
  67. package/__cjs/react/hooks/useBackgroundQuery.cjs +1 -3
  68. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  69. package/__cjs/react/hooks/useFragment.cjs +38 -87
  70. package/__cjs/react/hooks/useFragment.cjs.map +1 -1
  71. package/__cjs/react/hooks/useFragment.d.cts +65 -6
  72. package/__cjs/react/hooks/useLazyQuery.cjs +2 -0
  73. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  74. package/__cjs/react/hooks/useMutation.cjs +7 -1
  75. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  76. package/__cjs/react/hooks/useMutation.d.cts +13 -1
  77. package/__cjs/react/hooks/useQuery.cjs +1 -4
  78. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  79. package/__cjs/react/hooks/useQuery.d.cts +1 -1
  80. package/__cjs/react/hooks/useQueryRefHandlers.cjs +1 -3
  81. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  82. package/__cjs/react/hooks/useReadQuery.cjs +1 -3
  83. package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
  84. package/__cjs/react/hooks/useSubscription.cjs +1 -1
  85. package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
  86. package/__cjs/react/hooks/useSuspenseFragment.cjs +16 -16
  87. package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
  88. package/__cjs/react/hooks/useSuspenseFragment.d.cts +33 -7
  89. package/__cjs/react/hooks/useSuspenseQuery.cjs +4 -4
  90. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  91. package/__cjs/react/internal/cache/FragmentReference.cjs +3 -22
  92. package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
  93. package/__cjs/react/internal/cache/FragmentReference.d.cts +2 -4
  94. package/__cjs/react/internal/cache/QueryReference.cjs +16 -0
  95. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  96. package/__cjs/react/internal/cache/QueryReference.d.cts +5 -0
  97. package/__cjs/react/internal/cache/SuspenseCache.cjs.map +1 -1
  98. package/__cjs/react/internal/cache/SuspenseCache.d.cts +1 -1
  99. package/__cjs/react/internal/cache/types.d.cts +2 -2
  100. package/__cjs/react/query-preloader/createQueryPreloader.cjs +41 -1
  101. package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
  102. package/__cjs/react/ssr/useSSRQuery.cjs +1 -0
  103. package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
  104. package/__cjs/utilities/DeepPartial.cjs.map +1 -1
  105. package/__cjs/utilities/DeepPartial.d.cts +1 -1
  106. package/__cjs/utilities/internal/DeepMerger.cjs +36 -4
  107. package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -1
  108. package/__cjs/utilities/internal/DeepMerger.d.cts +20 -4
  109. package/__cjs/utilities/internal/combineLatestBatched.cjs +71 -0
  110. package/__cjs/utilities/internal/combineLatestBatched.cjs.map +1 -0
  111. package/__cjs/utilities/internal/combineLatestBatched.d.cts +14 -0
  112. package/__cjs/utilities/internal/constants.cjs +17 -1
  113. package/__cjs/utilities/internal/constants.cjs.map +1 -1
  114. package/__cjs/utilities/internal/constants.d.cts +16 -0
  115. package/__cjs/utilities/internal/getStoreKeyName.cjs +1 -0
  116. package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
  117. package/__cjs/utilities/internal/index.cjs +8 -2
  118. package/__cjs/utilities/internal/index.cjs.map +1 -1
  119. package/__cjs/utilities/internal/index.d.cts +4 -1
  120. package/__cjs/utilities/internal/mapObservableFragment.cjs +27 -0
  121. package/__cjs/utilities/internal/mapObservableFragment.cjs.map +1 -0
  122. package/__cjs/utilities/internal/mapObservableFragment.d.cts +3 -0
  123. package/__cjs/utilities/internal/memoize.cjs +2 -2
  124. package/__cjs/utilities/internal/memoize.cjs.map +1 -1
  125. package/__cjs/utilities/internal/memoize.d.cts +2 -1
  126. package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs +61 -0
  127. package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs.map +1 -0
  128. package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.d.cts +11 -0
  129. package/__cjs/utilities/internal/ponyfills/index.cjs +6 -0
  130. package/__cjs/utilities/internal/ponyfills/index.cjs.map +1 -0
  131. package/__cjs/utilities/internal/ponyfills/index.d.cts +3 -0
  132. package/__cjs/utilities/internal/ponyfills/index.react-native.cjs +6 -0
  133. package/__cjs/utilities/internal/ponyfills/index.react-native.cjs.map +1 -0
  134. package/__cjs/utilities/internal/ponyfills/index.react-native.d.cts +2 -0
  135. package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs +3 -0
  136. package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs.map +1 -0
  137. package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.d.cts +24 -0
  138. package/__cjs/version.cjs +1 -1
  139. package/__cjs/version.cjs.map +1 -1
  140. package/cache/core/cache.d.ts +141 -25
  141. package/cache/core/cache.js +219 -55
  142. package/cache/core/cache.js.map +1 -1
  143. package/cache/core/types/Cache.d.ts +77 -17
  144. package/cache/core/types/Cache.js.map +1 -1
  145. package/cache/index.d.ts +1 -1
  146. package/cache/index.js.map +1 -1
  147. package/cache/inmemory/entityStore.js +6 -4
  148. package/cache/inmemory/entityStore.js.map +1 -1
  149. package/cache/inmemory/helpers.d.ts +1 -1
  150. package/cache/inmemory/inMemoryCache.d.ts +48 -0
  151. package/cache/inmemory/inMemoryCache.js +62 -1
  152. package/cache/inmemory/inMemoryCache.js.map +1 -1
  153. package/cache/inmemory/key-extractor.js +1 -1
  154. package/cache/inmemory/key-extractor.js.map +1 -1
  155. package/cache/inmemory/policies.d.ts +30 -6
  156. package/cache/inmemory/policies.js +45 -7
  157. package/cache/inmemory/policies.js.map +1 -1
  158. package/cache/inmemory/readFromStore.js +3 -3
  159. package/cache/inmemory/readFromStore.js.map +1 -1
  160. package/cache/inmemory/types.d.ts +2 -0
  161. package/cache/inmemory/types.js.map +1 -1
  162. package/cache/inmemory/writeToStore.d.ts +2 -1
  163. package/cache/inmemory/writeToStore.js +26 -12
  164. package/cache/inmemory/writeToStore.js.map +1 -1
  165. package/core/ApolloClient.d.ts +143 -17
  166. package/core/ApolloClient.js +32 -50
  167. package/core/ApolloClient.js.map +1 -1
  168. package/core/ObservableQuery.d.ts +1 -0
  169. package/core/ObservableQuery.js +165 -131
  170. package/core/ObservableQuery.js.map +1 -1
  171. package/core/QueryInfo.d.ts +2 -1
  172. package/core/QueryInfo.js +10 -2
  173. package/core/QueryInfo.js.map +1 -1
  174. package/core/QueryManager.d.ts +18 -2
  175. package/core/QueryManager.js +47 -25
  176. package/core/QueryManager.js.map +1 -1
  177. package/incremental/handlers/defer20220824.d.ts +15 -7
  178. package/incremental/handlers/defer20220824.js +44 -19
  179. package/incremental/handlers/defer20220824.js.map +1 -1
  180. package/incremental/handlers/graphql17Alpha9.d.ts +98 -0
  181. package/incremental/handlers/graphql17Alpha9.js +218 -0
  182. package/incremental/handlers/graphql17Alpha9.js.map +1 -0
  183. package/incremental/handlers/notImplemented.js +1 -1
  184. package/incremental/handlers/notImplemented.js.map +1 -1
  185. package/incremental/index.d.ts +1 -0
  186. package/incremental/index.js +3 -2
  187. package/incremental/index.js.map +1 -1
  188. package/incremental/types.d.ts +9 -0
  189. package/incremental/types.js.map +1 -1
  190. package/invariantErrorCodes.js +78 -62
  191. package/legacyEntryPoints/utilities/internal/ponyfills/index.d.ts +1 -0
  192. package/legacyEntryPoints/utilities/internal/ponyfills/index.js +1 -0
  193. package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.cjs +1 -0
  194. package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.d.cts +1 -0
  195. package/link/client-awareness/ClientAwarenessLink.d.ts +1 -1
  196. package/link/client-awareness/ClientAwarenessLink.js +13 -1
  197. package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
  198. package/link/core/ApolloLink.js +3 -3
  199. package/link/error/index.d.ts +1 -1
  200. package/link/error/index.js +1 -1
  201. package/link/error/index.js.map +1 -1
  202. package/link/http/checkFetcher.js +1 -1
  203. package/link/http/parseAndCheckHttpResponse.js +1 -1
  204. package/link/persisted-queries/index.js +2 -2
  205. package/link/ws/index.js +1 -1
  206. package/local-state/LocalState.d.ts +3 -2
  207. package/local-state/LocalState.js +28 -14
  208. package/local-state/LocalState.js.map +1 -1
  209. package/masking/types.d.ts +2 -1
  210. package/masking/types.js.map +1 -1
  211. package/package.json +15 -1
  212. package/react/hooks/internal/useDeepMemo.js +2 -0
  213. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  214. package/react/hooks/useBackgroundQuery.js +1 -3
  215. package/react/hooks/useBackgroundQuery.js.map +1 -1
  216. package/react/hooks/useFragment.d.ts +65 -6
  217. package/react/hooks/useFragment.js +38 -87
  218. package/react/hooks/useFragment.js.map +1 -1
  219. package/react/hooks/useLazyQuery.js +2 -0
  220. package/react/hooks/useLazyQuery.js.map +1 -1
  221. package/react/hooks/useMutation.d.ts +13 -1
  222. package/react/hooks/useMutation.js +7 -1
  223. package/react/hooks/useMutation.js.map +1 -1
  224. package/react/hooks/useQuery.js +1 -4
  225. package/react/hooks/useQuery.js.map +1 -1
  226. package/react/hooks/useQueryRefHandlers.js +1 -3
  227. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  228. package/react/hooks/useReadQuery.js +1 -3
  229. package/react/hooks/useReadQuery.js.map +1 -1
  230. package/react/hooks/useSubscription.js +1 -1
  231. package/react/hooks/useSubscription.js.map +1 -1
  232. package/react/hooks/useSuspenseFragment.d.ts +33 -7
  233. package/react/hooks/useSuspenseFragment.js +17 -17
  234. package/react/hooks/useSuspenseFragment.js.map +1 -1
  235. package/react/hooks/useSuspenseQuery.js +4 -4
  236. package/react/hooks/useSuspenseQuery.js.map +1 -1
  237. package/react/hooks-compiled/internal/useDeepMemo.js +2 -0
  238. package/react/hooks-compiled/internal/useDeepMemo.js.map +1 -1
  239. package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js +0 -2
  240. package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js.map +1 -1
  241. package/react/hooks-compiled/useBackgroundQuery.js +1 -3
  242. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  243. package/react/hooks-compiled/useFragment.d.ts +65 -6
  244. package/react/hooks-compiled/useFragment.js +110 -88
  245. package/react/hooks-compiled/useFragment.js.map +1 -1
  246. package/react/hooks-compiled/useLazyQuery.js +2 -0
  247. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  248. package/react/hooks-compiled/useLoadableQuery.js +69 -75
  249. package/react/hooks-compiled/useMutation.d.ts +13 -1
  250. package/react/hooks-compiled/useMutation.js +5 -13
  251. package/react/hooks-compiled/useMutation.js.map +1 -1
  252. package/react/hooks-compiled/useQuery.js +44 -56
  253. package/react/hooks-compiled/useQuery.js.map +1 -1
  254. package/react/hooks-compiled/useQueryRefHandlers.js +1 -5
  255. package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
  256. package/react/hooks-compiled/useReadQuery.js +77 -14
  257. package/react/hooks-compiled/useReadQuery.js.map +1 -1
  258. package/react/hooks-compiled/useSubscription.js +237 -93
  259. package/react/hooks-compiled/useSubscription.js.map +1 -1
  260. package/react/hooks-compiled/useSuspenseFragment.d.ts +33 -7
  261. package/react/hooks-compiled/useSuspenseFragment.js +17 -17
  262. package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
  263. package/react/hooks-compiled/useSuspenseQuery.js +4 -8
  264. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  265. package/react/index.compiled.d.ts +1 -1
  266. package/react/index.compiled.js +1 -1
  267. package/react/index.compiled.js.map +1 -1
  268. package/react/internal/cache/FragmentReference.d.ts +2 -4
  269. package/react/internal/cache/FragmentReference.js +3 -22
  270. package/react/internal/cache/FragmentReference.js.map +1 -1
  271. package/react/internal/cache/QueryReference.d.ts +5 -0
  272. package/react/internal/cache/QueryReference.js +16 -0
  273. package/react/internal/cache/QueryReference.js.map +1 -1
  274. package/react/internal/cache/SuspenseCache.d.ts +1 -1
  275. package/react/internal/cache/SuspenseCache.js.map +1 -1
  276. package/react/internal/cache/types.d.ts +2 -2
  277. package/react/internal/cache/types.js.map +1 -1
  278. package/react/query-preloader/createQueryPreloader.js +41 -1
  279. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  280. package/react/ssr/useSSRQuery.js +1 -0
  281. package/react/ssr/useSSRQuery.js.map +1 -1
  282. package/utilities/DeepPartial.d.ts +1 -1
  283. package/utilities/DeepPartial.js.map +1 -1
  284. package/utilities/internal/DeepMerger.d.ts +20 -4
  285. package/utilities/internal/DeepMerger.js +36 -4
  286. package/utilities/internal/DeepMerger.js.map +1 -1
  287. package/utilities/internal/combineLatestBatched.d.ts +14 -0
  288. package/utilities/internal/combineLatestBatched.js +68 -0
  289. package/utilities/internal/combineLatestBatched.js.map +1 -0
  290. package/utilities/internal/constants.d.ts +16 -0
  291. package/utilities/internal/constants.js +16 -0
  292. package/utilities/internal/constants.js.map +1 -1
  293. package/utilities/internal/getStoreKeyName.js +1 -0
  294. package/utilities/internal/getStoreKeyName.js.map +1 -1
  295. package/utilities/internal/index.d.ts +4 -1
  296. package/utilities/internal/index.js +3 -1
  297. package/utilities/internal/index.js.map +1 -1
  298. package/utilities/internal/mapObservableFragment.d.ts +3 -0
  299. package/utilities/internal/mapObservableFragment.js +24 -0
  300. package/utilities/internal/mapObservableFragment.js.map +1 -0
  301. package/utilities/internal/memoize.d.ts +2 -1
  302. package/utilities/internal/memoize.js +2 -2
  303. package/utilities/internal/memoize.js.map +1 -1
  304. package/utilities/internal/ponyfills/FinalizationRegistry.d.ts +11 -0
  305. package/utilities/internal/ponyfills/FinalizationRegistry.js +57 -0
  306. package/utilities/internal/ponyfills/FinalizationRegistry.js.map +1 -0
  307. package/utilities/internal/ponyfills/index.d.ts +3 -0
  308. package/utilities/internal/ponyfills/index.js +3 -0
  309. package/utilities/internal/ponyfills/index.js.map +1 -0
  310. package/utilities/internal/ponyfills/index.react-native.d.ts +2 -0
  311. package/utilities/internal/ponyfills/index.react-native.js +2 -0
  312. package/utilities/internal/ponyfills/index.react-native.js.map +1 -0
  313. package/utilities/internal/types/ExtensionsWithStreamDetails.d.ts +24 -0
  314. package/utilities/internal/types/ExtensionsWithStreamDetails.js +2 -0
  315. package/utilities/internal/types/ExtensionsWithStreamDetails.js.map +1 -0
  316. package/version.js +1 -1
  317. package/version.js.map +1 -1
@@ -1,6 +1,6 @@
1
1
  import type { DocumentNode } from "graphql";
2
2
  import type { Observable } from "rxjs";
3
- import type { ApolloCache, IgnoreModifier, Reference } from "@apollo/client/cache";
3
+ import type { ApolloCache, Cache, IgnoreModifier, Reference } from "@apollo/client/cache";
4
4
  import type { Incremental } from "@apollo/client/incremental";
5
5
  import type { ApolloLink } from "@apollo/client/link";
6
6
  import type { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
@@ -87,6 +87,14 @@ export declare namespace ApolloClient {
87
87
  * queries.
88
88
  */
89
89
  incrementalHandler?: Incremental.Handler<any>;
90
+ /**
91
+ * @experimental
92
+ * Allows passing in "experiments", experimental features that might one day
93
+ * become part of Apollo Client's core functionality.
94
+ * Keep in mind that these features might change the core of Apollo Client.
95
+ * Do not pass in experiments that are not provided by Apollo.
96
+ */
97
+ experiments?: ApolloClient.Experiment[];
90
98
  }
91
99
  interface DevtoolsOptions {
92
100
  /**
@@ -376,7 +384,13 @@ export declare namespace ApolloClient {
376
384
  extensions?: Record<string, unknown>;
377
385
  }
378
386
  type WatchFragmentOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables> = ApolloCache.WatchFragmentOptions<TData, TVariables>;
379
- type WatchFragmentResult<TData = unknown> = ApolloCache.WatchFragmentResult<TData>;
387
+ type WatchFragmentResult<TData = unknown> = ApolloCache.WatchFragmentResult<MaybeMasked<TData>>;
388
+ interface ObservableFragment<TData = unknown> extends Observable<ApolloClient.WatchFragmentResult<TData>> {
389
+ /**
390
+ * Return the current result for the fragment.
391
+ */
392
+ getCurrentResult: () => ApolloClient.WatchFragmentResult<TData>;
393
+ }
380
394
  /**
381
395
  * Watched query options.
382
396
  */
@@ -523,12 +537,6 @@ export declare namespace ApolloClient {
523
537
  }
524
538
  namespace Base {
525
539
  interface ReadFragmentOptions<TData, TVariables extends OperationVariables> {
526
- /**
527
- * The root id to be used. This id should take the same form as the
528
- * value returned by the `cache.identify` function. If a value with your
529
- * id does not exist in the store, `null` will be returned.
530
- */
531
- id?: string;
532
540
  /**
533
541
  * A GraphQL document created using the `gql` template string tag
534
542
  * with one or more fragments which will be used to determine
@@ -557,7 +565,27 @@ export declare namespace ApolloClient {
557
565
  optimistic?: boolean;
558
566
  }
559
567
  }
560
- type ReadFragmentOptions<TData, TVariables extends OperationVariables> = Base.ReadFragmentOptions<TData, TVariables> & VariablesOption<TVariables>;
568
+ namespace DocumentationTypes {
569
+ interface ReadFragmentOptions<TData, TVariables extends OperationVariables> extends Base.ReadFragmentOptions<TData, TVariables> {
570
+ /**
571
+ * The root id to be used. This id should take the same form as the
572
+ * value returned by the `cache.identify` function. If a value with your
573
+ * id does not exist in the store, `null` will be returned.
574
+ */
575
+ id?: string;
576
+ /**
577
+ * An object containing a `__typename` and primary key fields
578
+ * (such as `id`) identifying the entity object from which the fragment will
579
+ * be retrieved, or a `{ __ref: "..." }` reference, or a `string` ID
580
+ * (uncommon).
581
+ *
582
+ * @remarks
583
+ * `from` is given precedence over `id` when both are provided.
584
+ */
585
+ from?: ApolloCache.FromOptionValue<TData>;
586
+ }
587
+ }
588
+ type ReadFragmentOptions<TData, TVariables extends OperationVariables> = Base.ReadFragmentOptions<TData, TVariables> & VariablesOption<TVariables> & Cache.CacheIdentifierOption<TData>;
561
589
  namespace DocumentationTypes {
562
590
  interface WriteQueryOptions<TData, TVariables extends OperationVariables> extends Base.WriteQueryOptions<TData, TVariables> {
563
591
  /**
@@ -595,6 +623,11 @@ export declare namespace ApolloClient {
595
623
  * @defaultValue false
596
624
  */
597
625
  overwrite?: boolean;
626
+ /**
627
+ * GraphQL extensions for the write operation. Any provided `extensions`
628
+ * are available in `merge` functions.
629
+ */
630
+ extensions?: Record<string, unknown>;
598
631
  }
599
632
  }
600
633
  type WriteQueryOptions<TData, TVariables extends OperationVariables> = Base.WriteQueryOptions<TData, TVariables> & VariablesOption<TVariables>;
@@ -608,12 +641,6 @@ export declare namespace ApolloClient {
608
641
  }
609
642
  namespace Base {
610
643
  interface WriteFragmentOptions<TData, TVariables extends OperationVariables> {
611
- /**
612
- * The root id to be used. This id should take the same form as the
613
- * value returned by the `cache.identify` function. If a value with your
614
- * id does not exist in the store, `null` will be returned.
615
- */
616
- id?: string;
617
644
  /**
618
645
  * A GraphQL document created using the `gql` template string tag from
619
646
  * `graphql-tag` with one or more fragments which will be used to determine
@@ -645,15 +672,35 @@ export declare namespace ApolloClient {
645
672
  overwrite?: boolean;
646
673
  }
647
674
  }
648
- type WriteFragmentOptions<TData, TVariables extends OperationVariables> = Base.WriteFragmentOptions<TData, TVariables> & VariablesOption<TVariables>;
675
+ type WriteFragmentOptions<TData, TVariables extends OperationVariables> = Base.WriteFragmentOptions<TData, TVariables> & VariablesOption<TVariables> & Cache.CacheIdentifierOption<TData>;
649
676
  namespace DocumentationTypes {
650
677
  interface WriteFragmentOptions<TData, TVariables extends OperationVariables> extends Base.WriteFragmentOptions<TData, TVariables> {
678
+ /**
679
+ * The root id to be used. This id should take the same form as the
680
+ * value returned by the `cache.identify` function. If a value with your
681
+ * id does not exist in the store, `null` will be returned.
682
+ */
683
+ id?: string;
684
+ /**
685
+ * An object containing a `__typename` and primary key fields
686
+ * (such as `id`) identifying the entity object from which the fragment will
687
+ * be retrieved, or a `{ __ref: "..." }` reference, or a `string` ID
688
+ * (uncommon).
689
+ *
690
+ * @remarks
691
+ * `from` is given precedence over `id` when both are provided.
692
+ */
693
+ from?: ApolloCache.FromOptionValue<TData>;
651
694
  /**
652
695
  * Any variables that your GraphQL fragments depend on.
653
696
  */
654
697
  variables?: TVariables;
655
698
  }
656
699
  }
700
+ interface Experiment {
701
+ (this: ApolloClient, options: ApolloClient.Options): void;
702
+ v: 1;
703
+ }
657
704
  }
658
705
  /**
659
706
  * This is the primary Apollo Client class. It is used to send GraphQL documents (i.e. queries
@@ -826,7 +873,86 @@ export declare class ApolloClient {
826
873
  * the cache to identify the fragment and optionally specify whether to react
827
874
  * to optimistic updates.
828
875
  */
829
- watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables>): Observable<ApolloClient.WatchFragmentResult<MaybeMasked<TData>>>;
876
+ watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables> & {
877
+ from: Array<ApolloCache.FromOptionValue<TData>>;
878
+ }): ApolloClient.ObservableFragment<Array<TData>>;
879
+ /**
880
+ * Watches the cache store of the fragment according to the options specified
881
+ * and returns an `Observable`. We can subscribe to this
882
+ * `Observable` and receive updated results through an
883
+ * observer when the cache store changes.
884
+ *
885
+ * You must pass in a GraphQL document with a single fragment or a document
886
+ * with multiple fragments that represent what you are reading. If you pass
887
+ * in a document with multiple fragments then you must also specify a
888
+ * `fragmentName`.
889
+ *
890
+ * @since 3.10.0
891
+ * @param options - An object of type `WatchFragmentOptions` that allows
892
+ * the cache to identify the fragment and optionally specify whether to react
893
+ * to optimistic updates.
894
+ */
895
+ watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables> & {
896
+ from: Array<null>;
897
+ }): ApolloClient.ObservableFragment<Array<null>>;
898
+ watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables> & {
899
+ from: Array<ApolloCache.FromOptionValue<TData> | null>;
900
+ }): ApolloClient.ObservableFragment<Array<TData | null>>;
901
+ /**
902
+ * Watches the cache store of the fragment according to the options specified
903
+ * and returns an `Observable`. We can subscribe to this
904
+ * `Observable` and receive updated results through an
905
+ * observer when the cache store changes.
906
+ *
907
+ * You must pass in a GraphQL document with a single fragment or a document
908
+ * with multiple fragments that represent what you are reading. If you pass
909
+ * in a document with multiple fragments then you must also specify a
910
+ * `fragmentName`.
911
+ *
912
+ * @since 3.10.0
913
+ * @param options - An object of type `WatchFragmentOptions` that allows
914
+ * the cache to identify the fragment and optionally specify whether to react
915
+ * to optimistic updates.
916
+ */
917
+ watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables> & {
918
+ from: null;
919
+ }): ApolloClient.ObservableFragment<null>;
920
+ /**
921
+ * Watches the cache store of the fragment according to the options specified
922
+ * and returns an `Observable`. We can subscribe to this
923
+ * `Observable` and receive updated results through an
924
+ * observer when the cache store changes.
925
+ *
926
+ * You must pass in a GraphQL document with a single fragment or a document
927
+ * with multiple fragments that represent what you are reading. If you pass
928
+ * in a document with multiple fragments then you must also specify a
929
+ * `fragmentName`.
930
+ *
931
+ * @since 3.10.0
932
+ * @param options - An object of type `WatchFragmentOptions` that allows
933
+ * the cache to identify the fragment and optionally specify whether to react
934
+ * to optimistic updates.
935
+ */
936
+ watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables> & {
937
+ from: ApolloCache.FromOptionValue<TData>;
938
+ }): ApolloClient.ObservableFragment<TData>;
939
+ /**
940
+ * Watches the cache store of the fragment according to the options specified
941
+ * and returns an `Observable`. We can subscribe to this
942
+ * `Observable` and receive updated results through an
943
+ * observer when the cache store changes.
944
+ *
945
+ * You must pass in a GraphQL document with a single fragment or a document
946
+ * with multiple fragments that represent what you are reading. If you pass
947
+ * in a document with multiple fragments then you must also specify a
948
+ * `fragmentName`.
949
+ *
950
+ * @since 3.10.0
951
+ * @param options - An object of type `WatchFragmentOptions` that allows
952
+ * the cache to identify the fragment and optionally specify whether to react
953
+ * to optimistic updates.
954
+ */
955
+ watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables>): ApolloClient.ObservableFragment<TData | null>;
830
956
  /**
831
957
  * Tries to read some data from the store in the shape of the provided
832
958
  * GraphQL fragment without making a network request. This method will read a
@@ -69,6 +69,9 @@ class ObservableQuery {
69
69
  get networkStatus() {
70
70
  return this.subject.getValue().result.networkStatus;
71
71
  }
72
+ get cache() {
73
+ return this.queryManager.cache;
74
+ }
72
75
  constructor({ queryManager, options, transformedQuery = queryManager.transform(options.query), }) {
73
76
  this.queryManager = queryManager;
74
77
  // active state
@@ -81,7 +84,7 @@ class ObservableQuery {
81
84
  // Make sure we don't store "standby" as the initialFetchPolicy.
82
85
  initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
83
86
  if (options[internal_1.variablesUnknownSymbol]) {
84
- (0, invariant_1.invariant)(fetchPolicy === "standby", 77);
87
+ (0, invariant_1.invariant)(fetchPolicy === "standby", 80);
85
88
  this.variablesUnknown = true;
86
89
  }
87
90
  this.lastQuery = transformedQuery;
@@ -210,7 +213,7 @@ class ObservableQuery {
210
213
  * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
211
214
  */
212
215
  getCacheDiff({ optimistic = true } = {}) {
213
- return this.queryManager.cache.diff({
216
+ return this.cache.diff({
214
217
  query: this.query,
215
218
  variables: this.variables,
216
219
  returnPartialData: true,
@@ -321,7 +324,7 @@ class ObservableQuery {
321
324
  }
322
325
  },
323
326
  };
324
- const cancelWatch = this.queryManager.cache.watch(watch);
327
+ const cancelWatch = this.cache.watch(watch);
325
328
  this.unsubscribeFromCache = Object.assign(() => {
326
329
  this.unsubscribeFromCache = undefined;
327
330
  cancelWatch();
@@ -385,7 +388,7 @@ class ObservableQuery {
385
388
  const queryDef = (0, internal_1.getQueryDefinition)(this.query);
386
389
  const vars = queryDef.variableDefinitions;
387
390
  if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
388
- __DEV__ && invariant_1.invariant.warn(78, variables, queryDef.name?.value || queryDef);
391
+ __DEV__ && invariant_1.invariant.warn(81, variables, queryDef.name?.value || queryDef);
389
392
  }
390
393
  }
391
394
  if (variables && !(0, equality_1.equal)(this.variables, variables)) {
@@ -401,7 +404,7 @@ class ObservableQuery {
401
404
  fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
402
405
  (0, invariant_1.invariant)(
403
406
  this.options.fetchPolicy !== "cache-only",
404
- 79,
407
+ 82,
405
408
  (0, internal_1.getOperationName)(this.query, "(anonymous)")
406
409
  );
407
410
  const combinedOptions = {
@@ -435,7 +438,7 @@ class ObservableQuery {
435
438
  let wasUpdated = false;
436
439
  const isCached = this.options.fetchPolicy !== "no-cache";
437
440
  if (!isCached) {
438
- (0, invariant_1.invariant)(updateQuery, 80);
441
+ (0, invariant_1.invariant)(updateQuery, 83);
439
442
  }
440
443
  const { finalize, pushNotification } = this.pushOperation(networkStatus_js_1.NetworkStatus.fetchMore);
441
444
  pushNotification({
@@ -443,109 +446,149 @@ class ObservableQuery {
443
446
  kind: "N",
444
447
  value: {},
445
448
  }, { shouldEmit: 3 /* EmitBehavior.networkStatusChange */ });
446
- return this.queryManager
447
- .fetchQuery(combinedOptions, networkStatus_js_1.NetworkStatus.fetchMore)
448
- .then((fetchMoreResult) => {
449
- // disable the `fetchMore` override that is currently active
450
- // the next updates caused by this should not be `fetchMore` anymore,
451
- // but `ready` or whatever other calculated loading state is currently
452
- // appropriate
453
- finalize();
454
- if (isCached) {
455
- // Separately getting a diff here before the batch - `onWatchUpdated` might be
456
- // called with an `undefined` `lastDiff` on the watcher if the cache was just subscribed to.
457
- const lastDiff = this.getCacheDiff();
458
- // Performing this cache update inside a cache.batch transaction ensures
459
- // any affected cache.watch watchers are notified at most once about any
460
- // updates. Most watchers will be using the QueryInfo class, which
461
- // responds to notifications by calling reobserveCacheFirst to deliver
462
- // fetchMore cache results back to this ObservableQuery.
463
- this.queryManager.cache.batch({
464
- update: (cache) => {
465
- if (updateQuery) {
466
- cache.updateQuery({
467
- query: this.query,
468
- variables: this.variables,
469
- returnPartialData: true,
470
- optimistic: false,
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
- });
487
- }
488
- },
489
- onWatchUpdated: (watch, diff) => {
490
- if (watch.watcher === this &&
491
- !(0, equality_1.equal)(diff.result, lastDiff.result)) {
492
- wasUpdated = true;
493
- }
494
- },
495
- });
496
- }
497
- else {
498
- // There is a possibility `lastResult` may not be set when
499
- // `fetchMore` is called which would cause this to crash. This should
500
- // only happen if we haven't previously reported a result. We don't
501
- // quite know what the right behavior should be here since this block
502
- // of code runs after the fetch result has executed on the network.
503
- // We plan to let it crash in the meantime.
504
- //
505
- // If we get bug reports due to the `data` property access on
506
- // undefined, this should give us a real-world scenario that we can
507
- // use to test against and determine the right behavior. If we do end
508
- // up changing this behavior, this may require, for example, an
509
- // adjustment to the types on `updateQuery` since that function
510
- // expects that the first argument always contains previous result
511
- // data, but not `undefined`.
512
- const lastResult = this.getCurrentResult();
513
- const data = updateQuery(lastResult.data, {
514
- fetchMoreResult: fetchMoreResult.data,
515
- variables: combinedOptions.variables,
516
- });
517
- // was reportResult
518
- pushNotification({
519
- kind: "N",
520
- value: {
521
- ...lastResult,
522
- networkStatus: networkStatus_js_1.NetworkStatus.ready,
523
- // will be overwritten anyways, just here for types sake
524
- loading: false,
525
- data: data,
526
- dataState: lastResult.dataState === "streaming" ? "streaming" : "complete",
527
- },
528
- source: "network",
529
- });
530
- }
531
- return this.maskResult(fetchMoreResult);
532
- })
449
+ const { promise, operator } = getTrackingOperatorPromise();
450
+ const { observable } = this.queryManager.fetchObservableWithInfo(combinedOptions, { networkStatus: networkStatus_js_1.NetworkStatus.fetchMore, exposeExtensions: true });
451
+ const subscription = observable
452
+ .pipe(operator, (0, rxjs_1.filter)((notification) => notification.kind === "N" && notification.source === "network"))
453
+ .subscribe({
454
+ next: (notification) => {
455
+ wasUpdated = false;
456
+ const fetchMoreResult = notification.value;
457
+ const extensions = fetchMoreResult[internal_1.extensionsSymbol];
458
+ if ((0, utilities_1.isNetworkRequestSettled)(notification.value.networkStatus)) {
459
+ finalize();
460
+ }
461
+ if (isCached) {
462
+ // Separately getting a diff here before the batch - `onWatchUpdated` might be
463
+ // called with an `undefined` `lastDiff` on the watcher if the cache was just subscribed to.
464
+ const lastDiff = this.getCacheDiff();
465
+ // Performing this cache update inside a cache.batch transaction ensures
466
+ // any affected cache.watch watchers are notified at most once about any
467
+ // updates. Most watchers will be using the QueryInfo class, which
468
+ // responds to notifications by calling reobserveCacheFirst to deliver
469
+ // fetchMore cache results back to this ObservableQuery.
470
+ this.cache.batch({
471
+ update: (cache) => {
472
+ if (updateQuery) {
473
+ cache.updateQuery({
474
+ query: this.query,
475
+ variables: this.variables,
476
+ returnPartialData: true,
477
+ optimistic: false,
478
+ extensions,
479
+ }, (previous) => updateQuery(previous, {
480
+ fetchMoreResult: fetchMoreResult.data,
481
+ variables: combinedOptions.variables,
482
+ }));
483
+ }
484
+ else {
485
+ // If we're using a field policy instead of updateQuery, the only
486
+ // thing we need to do is write the new data to the cache using
487
+ // combinedOptions.variables (instead of this.variables, which is
488
+ // what this.updateQuery uses, because it works by abusing the
489
+ // original field value, keyed by the original variables).
490
+ cache.writeQuery({
491
+ query: combinedOptions.query,
492
+ variables: combinedOptions.variables,
493
+ data: fetchMoreResult.data,
494
+ extensions,
495
+ });
496
+ }
497
+ },
498
+ onWatchUpdated: (watch, diff) => {
499
+ if (watch.watcher === this &&
500
+ !(0, equality_1.equal)(diff.result, lastDiff.result)) {
501
+ wasUpdated = true;
502
+ const lastResult = this.getCurrentResult();
503
+ // Let the cache watch from resubscribeCache handle the final
504
+ // result
505
+ if ((0, utilities_1.isNetworkRequestInFlight)(fetchMoreResult.networkStatus)) {
506
+ pushNotification({
507
+ kind: "N",
508
+ source: "network",
509
+ value: {
510
+ ...lastResult,
511
+ networkStatus: (fetchMoreResult.networkStatus ===
512
+ networkStatus_js_1.NetworkStatus.error) ?
513
+ networkStatus_js_1.NetworkStatus.ready
514
+ : fetchMoreResult.networkStatus,
515
+ // will be overwritten anyways, just here for types sake
516
+ loading: false,
517
+ data: diff.result,
518
+ dataState: fetchMoreResult.dataState === "streaming" ?
519
+ "streaming"
520
+ : "complete",
521
+ },
522
+ });
523
+ }
524
+ }
525
+ },
526
+ });
527
+ }
528
+ else {
529
+ // There is a possibility `lastResult` may not be set when
530
+ // `fetchMore` is called which would cause this to crash. This should
531
+ // only happen if we haven't previously reported a result. We don't
532
+ // quite know what the right behavior should be here since this block
533
+ // of code runs after the fetch result has executed on the network.
534
+ // We plan to let it crash in the meantime.
535
+ //
536
+ // If we get bug reports due to the `data` property access on
537
+ // undefined, this should give us a real-world scenario that we can
538
+ // use to test against and determine the right behavior. If we do end
539
+ // up changing this behavior, this may require, for example, an
540
+ // adjustment to the types on `updateQuery` since that function
541
+ // expects that the first argument always contains previous result
542
+ // data, but not `undefined`.
543
+ const lastResult = this.getCurrentResult();
544
+ const data = updateQuery(lastResult.data, {
545
+ fetchMoreResult: fetchMoreResult.data,
546
+ variables: combinedOptions.variables,
547
+ });
548
+ pushNotification({
549
+ kind: "N",
550
+ value: {
551
+ ...lastResult,
552
+ networkStatus: networkStatus_js_1.NetworkStatus.ready,
553
+ // will be overwritten anyways, just here for types sake
554
+ loading: false,
555
+ data: data,
556
+ dataState: lastResult.dataState === "streaming" ?
557
+ "streaming"
558
+ : "complete",
559
+ },
560
+ source: "network",
561
+ });
562
+ }
563
+ },
564
+ });
565
+ return (0, internal_1.preventUnhandledRejection)(promise
566
+ .then((result) => (0, internal_1.toQueryResult)(this.maskResult(result)))
533
567
  .finally(() => {
534
- // call `finalize` a second time in case the `.then` case above was not reached
568
+ subscription.unsubscribe();
535
569
  finalize();
536
- // In case the cache writes above did not generate a broadcast
537
- // notification (which would have been intercepted by onWatchUpdated),
538
- // likely because the written data were the same as what was already in
539
- // the cache, we still want fetchMore to deliver its final loading:false
540
- // result with the unchanged data.
541
570
  if (isCached && !wasUpdated) {
542
- pushNotification({
543
- kind: "N",
544
- source: "newNetworkStatus",
545
- value: {},
546
- }, { shouldEmit: 1 /* EmitBehavior.force */ });
571
+ const lastResult = this.getCurrentResult();
572
+ if (lastResult.dataState === "streaming") {
573
+ pushNotification({
574
+ kind: "N",
575
+ source: "network",
576
+ value: {
577
+ ...lastResult,
578
+ dataState: "complete",
579
+ networkStatus: networkStatus_js_1.NetworkStatus.ready,
580
+ },
581
+ });
582
+ }
583
+ else {
584
+ pushNotification({
585
+ kind: "N",
586
+ source: "newNetworkStatus",
587
+ value: {},
588
+ }, { shouldEmit: 1 /* EmitBehavior.force */ });
589
+ }
547
590
  }
548
- });
591
+ }));
549
592
  }
550
593
  // XXX the subscription variables are separate from the query variables.
551
594
  // if you want to update subscription variables, right now you have to do that separately,
@@ -571,7 +614,7 @@ class ObservableQuery {
571
614
  onError(error);
572
615
  }
573
616
  else {
574
- invariant_1.invariant.error(81, error);
617
+ invariant_1.invariant.error(84, error);
575
618
  }
576
619
  return;
577
620
  }
@@ -649,7 +692,7 @@ class ObservableQuery {
649
692
  previousData: result,
650
693
  });
651
694
  if (newResult) {
652
- queryManager.cache.writeQuery({
695
+ this.cache.writeQuery({
653
696
  query: this.options.query,
654
697
  data: newResult,
655
698
  variables: this.variables,
@@ -815,7 +858,7 @@ class ObservableQuery {
815
858
  if (!this.didWarnCacheOnlyPolling &&
816
859
  pollInterval &&
817
860
  fetchPolicy === "cache-only") {
818
- __DEV__ && invariant_1.invariant.warn(82, (0, internal_1.getOperationName)(this.query, "(anonymous)"));
861
+ __DEV__ && invariant_1.invariant.warn(85, (0, internal_1.getOperationName)(this.query, "(anonymous)"));
819
862
  this.didWarnCacheOnlyPolling = true;
820
863
  }
821
864
  }
@@ -956,15 +999,7 @@ class ObservableQuery {
956
999
  this.cancelPolling();
957
1000
  }
958
1001
  this.resubscribeCache();
959
- const { promise, operator: promiseOperator } = getTrackingOperatorPromise((value) => {
960
- switch (value.kind) {
961
- case "E":
962
- throw value.error;
963
- case "N":
964
- if (value.source !== "newNetworkStatus" && !value.value.loading)
965
- return value.value;
966
- }
967
- },
1002
+ const { promise, operator: promiseOperator } = getTrackingOperatorPromise(
968
1003
  // This default value should only be used when using a `fetchPolicy` of
969
1004
  // `standby` since that fetch policy completes without emitting a
970
1005
  // result. Since we are converting this to a QueryResult type, we
@@ -1086,8 +1121,8 @@ class ObservableQuery {
1086
1121
  const { dirty } = this;
1087
1122
  this.resetNotifications();
1088
1123
  if (dirty &&
1089
- (this.options.fetchPolicy == "cache-only" ||
1090
- this.options.fetchPolicy == "cache-and-network" ||
1124
+ (this.options.fetchPolicy === "cache-only" ||
1125
+ this.options.fetchPolicy === "cache-and-network" ||
1091
1126
  !this.activeOperations.size)) {
1092
1127
  const diff = this.getCacheDiff();
1093
1128
  if (
@@ -1318,13 +1353,13 @@ class ObservableQuery {
1318
1353
  exports.ObservableQuery = ObservableQuery;
1319
1354
  function logMissingFieldErrors(missing) {
1320
1355
  if (environment_1.__DEV__ && missing) {
1321
- __DEV__ && invariant_1.invariant.debug(83, missing);
1356
+ __DEV__ && invariant_1.invariant.debug(86, missing);
1322
1357
  }
1323
1358
  }
1324
1359
  function isEqualQuery(a, b) {
1325
1360
  return !!(a && b && a.query === b.query && (0, equality_1.equal)(a.variables, b.variables));
1326
1361
  }
1327
- function getTrackingOperatorPromise(filterMapCb, defaultValue) {
1362
+ function getTrackingOperatorPromise(defaultValue) {
1328
1363
  let lastValue = defaultValue, resolve, reject;
1329
1364
  const promise = new Promise((res, rej) => {
1330
1365
  resolve = res;
@@ -1332,14 +1367,13 @@ function getTrackingOperatorPromise(filterMapCb, defaultValue) {
1332
1367
  });
1333
1368
  const operator = (0, rxjs_1.tap)({
1334
1369
  next(value) {
1335
- try {
1336
- const newValue = filterMapCb(value);
1337
- if (newValue !== undefined) {
1338
- lastValue = newValue;
1339
- }
1370
+ if (value.kind === "E") {
1371
+ return reject(value.error);
1340
1372
  }
1341
- catch (error) {
1342
- reject(error);
1373
+ if (value.kind === "N" &&
1374
+ value.source !== "newNetworkStatus" &&
1375
+ !value.value.loading) {
1376
+ lastValue = value.value;
1343
1377
  }
1344
1378
  },
1345
1379
  finalize: () => {