@apollo/client 3.9.0-alpha.4 → 3.9.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 (738) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/beige-geese-wink.md +5 -0
  3. package/.changeset/breezy-spiders-tap.md +38 -0
  4. package/.changeset/clean-items-smash.md +5 -0
  5. package/.changeset/cold-llamas-turn.md +8 -0
  6. package/.changeset/config.json +14 -0
  7. package/.changeset/dirty-kids-crash.md +5 -0
  8. package/.changeset/dirty-tigers-matter.md +13 -0
  9. package/.changeset/forty-cups-shop.md +5 -0
  10. package/.changeset/friendly-clouds-laugh.md +7 -0
  11. package/.changeset/hot-ducks-burn.md +5 -0
  12. package/.changeset/mighty-coats-check.md +47 -0
  13. package/.changeset/polite-avocados-warn.md +5 -0
  14. package/.changeset/pre.json +37 -0
  15. package/.changeset/quick-hats-marry.md +5 -0
  16. package/.changeset/rare-snakes-melt.md +24 -0
  17. package/.changeset/shaggy-ears-scream.md +5 -0
  18. package/.changeset/shaggy-sheep-pull.md +5 -0
  19. package/.changeset/sixty-boxes-rest.md +8 -0
  20. package/.changeset/sour-sheep-walk.md +7 -0
  21. package/.changeset/strong-terms-perform.md +46 -0
  22. package/.changeset/swift-zoos-collect.md +19 -0
  23. package/.changeset/thick-mice-collect.md +5 -0
  24. package/.changeset/thick-tips-cry.md +9 -0
  25. package/.changeset/thirty-ties-arrive.md +26 -0
  26. package/.changeset/tough-timers-begin.md +8 -0
  27. package/.changeset/unlucky-rats-decide.md +5 -0
  28. package/.changeset/violet-lions-draw.md +5 -0
  29. package/.changeset/wet-forks-rhyme.md +5 -0
  30. package/.changeset/wild-dolphins-jog.md +5 -0
  31. package/.changeset/yellow-flies-repeat.md +5 -0
  32. package/CHANGELOG.md +3649 -0
  33. package/apollo-client.cjs +775 -451
  34. package/apollo-client.cjs.map +1 -1
  35. package/apollo-client.min.cjs +1 -1
  36. package/cache/cache.cjs +210 -156
  37. package/cache/cache.cjs.map +1 -1
  38. package/cache/cache.cjs.native.js +210 -156
  39. package/cache/core/cache.d.ts +19 -0
  40. package/cache/core/cache.js +28 -7
  41. package/cache/core/cache.js.map +1 -1
  42. package/cache/core/types/Cache.d.ts +8 -1
  43. package/cache/core/types/Cache.js.map +1 -1
  44. package/cache/core/types/DataProxy.d.ts +104 -0
  45. package/cache/core/types/DataProxy.js.map +1 -1
  46. package/cache/core/types/common.d.ts +5 -1
  47. package/cache/core/types/common.js +4 -1
  48. package/cache/core/types/common.js.map +1 -1
  49. package/cache/inmemory/entityStore.d.ts +10 -1
  50. package/cache/inmemory/entityStore.js +190 -29
  51. package/cache/inmemory/entityStore.js.map +1 -1
  52. package/cache/inmemory/fixPolyfills.js +9 -0
  53. package/cache/inmemory/fixPolyfills.js.map +1 -1
  54. package/cache/inmemory/fixPolyfills.native.js +12 -0
  55. package/cache/inmemory/fixPolyfills.native.js.map +1 -1
  56. package/cache/inmemory/fragmentRegistry.d.ts +1 -0
  57. package/cache/inmemory/fragmentRegistry.js +39 -14
  58. package/cache/inmemory/fragmentRegistry.js.map +1 -1
  59. package/cache/inmemory/helpers.js +20 -11
  60. package/cache/inmemory/helpers.js.map +1 -1
  61. package/cache/inmemory/inMemoryCache.d.ts +9 -0
  62. package/cache/inmemory/inMemoryCache.js +172 -10
  63. package/cache/inmemory/inMemoryCache.js.map +1 -1
  64. package/cache/inmemory/key-extractor.js +72 -4
  65. package/cache/inmemory/key-extractor.js.map +1 -1
  66. package/cache/inmemory/object-canon.js +87 -3
  67. package/cache/inmemory/object-canon.js.map +1 -1
  68. package/cache/inmemory/policies.js +190 -43
  69. package/cache/inmemory/policies.js.map +1 -1
  70. package/cache/inmemory/reactiveVars.js +20 -2
  71. package/cache/inmemory/reactiveVars.js.map +1 -1
  72. package/cache/inmemory/readFromStore.d.ts +4 -0
  73. package/cache/inmemory/readFromStore.js +65 -12
  74. package/cache/inmemory/readFromStore.js.map +1 -1
  75. package/cache/inmemory/types.d.ts +46 -0
  76. package/cache/inmemory/types.js.map +1 -1
  77. package/cache/inmemory/writeToStore.js +152 -25
  78. package/cache/inmemory/writeToStore.js.map +1 -1
  79. package/config/jest/setup.js +2 -0
  80. package/config/jest/setup.js.map +1 -1
  81. package/core/ApolloClient.d.ts +273 -3
  82. package/core/ApolloClient.js +239 -7
  83. package/core/ApolloClient.js.map +1 -1
  84. package/core/LocalState.d.ts +4 -6
  85. package/core/LocalState.js +56 -18
  86. package/core/LocalState.js.map +1 -1
  87. package/core/ObservableQuery.d.ts +27 -0
  88. package/core/ObservableQuery.js +246 -31
  89. package/core/ObservableQuery.js.map +1 -1
  90. package/core/QueryInfo.d.ts +4 -3
  91. package/core/QueryInfo.js +122 -13
  92. package/core/QueryInfo.js.map +1 -1
  93. package/core/QueryManager.d.ts +9 -2
  94. package/core/QueryManager.js +259 -53
  95. package/core/QueryManager.js.map +1 -1
  96. package/core/core.cjs +222 -122
  97. package/core/core.cjs.map +1 -1
  98. package/core/core.cjs.native.js +222 -122
  99. package/core/equalByQuery.js +20 -1
  100. package/core/equalByQuery.js.map +1 -1
  101. package/core/index.d.ts +1 -1
  102. package/core/index.js +19 -0
  103. package/core/index.js.map +1 -1
  104. package/core/networkStatus.d.ts +39 -0
  105. package/core/networkStatus.js +39 -0
  106. package/core/networkStatus.js.map +1 -1
  107. package/core/types.d.ts +9 -0
  108. package/core/types.js.map +1 -1
  109. package/core/watchQueryOptions.d.ts +245 -2
  110. package/core/watchQueryOptions.js.map +1 -1
  111. package/dev/dev.cjs +10 -119
  112. package/dev/dev.cjs.map +1 -1
  113. package/dev/dev.cjs.native.js +10 -119
  114. package/dev/loadErrorMessageHandler.js.map +1 -1
  115. package/errors/errors.cjs +1 -1
  116. package/errors/errors.cjs.map +1 -1
  117. package/errors/errors.cjs.native.js +1 -1
  118. package/errors/index.js +14 -1
  119. package/errors/index.js.map +1 -1
  120. package/invariantErrorCodes.js +6 -8
  121. package/link/batch/batch.cjs +2 -2
  122. package/link/batch/batch.cjs.map +1 -1
  123. package/link/batch/batch.cjs.native.js +2 -2
  124. package/link/batch/batchLink.d.ts +21 -0
  125. package/link/batch/batchLink.js +2 -1
  126. package/link/batch/batchLink.js.map +1 -1
  127. package/link/batch/batching.js +24 -1
  128. package/link/batch/batching.js.map +1 -1
  129. package/link/batch-http/batch-http.cjs +3 -2
  130. package/link/batch-http/batch-http.cjs.map +1 -1
  131. package/link/batch-http/batch-http.cjs.native.js +3 -2
  132. package/link/batch-http/batchHttpLink.d.ts +4 -0
  133. package/link/batch-http/batchHttpLink.js +53 -2
  134. package/link/batch-http/batchHttpLink.js.map +1 -1
  135. package/link/context/context.cjs.map +1 -1
  136. package/link/context/index.js +1 -0
  137. package/link/context/index.js.map +1 -1
  138. package/link/core/ApolloLink.d.ts +15 -0
  139. package/link/core/ApolloLink.js +20 -9
  140. package/link/core/ApolloLink.js.map +1 -1
  141. package/link/core/core.cjs +13 -9
  142. package/link/core/core.cjs.map +1 -1
  143. package/link/core/core.cjs.native.js +13 -9
  144. package/link/error/error.cjs +1 -1
  145. package/link/error/error.cjs.map +1 -1
  146. package/link/error/error.cjs.native.js +1 -1
  147. package/link/error/index.d.ts +3 -0
  148. package/link/error/index.js +4 -1
  149. package/link/error/index.js.map +1 -1
  150. package/link/http/HttpLink.d.ts +0 -2
  151. package/link/http/HttpLink.js +1 -1
  152. package/link/http/HttpLink.js.map +1 -1
  153. package/link/http/checkFetcher.js.map +1 -1
  154. package/link/http/createHttpLink.js +23 -1
  155. package/link/http/createHttpLink.js.map +1 -1
  156. package/link/http/createSignalIfSupported.d.ts +5 -0
  157. package/link/http/createSignalIfSupported.js +5 -0
  158. package/link/http/createSignalIfSupported.js.map +1 -1
  159. package/link/http/http.cjs +14 -12
  160. package/link/http/http.cjs.map +1 -1
  161. package/link/http/http.cjs.native.js +14 -12
  162. package/link/http/index.js +2 -1
  163. package/link/http/index.js.map +1 -1
  164. package/link/http/iterators/async.d.ts +4 -0
  165. package/link/http/iterators/async.js +4 -0
  166. package/link/http/iterators/async.js.map +1 -1
  167. package/link/http/iterators/nodeStream.d.ts +4 -0
  168. package/link/http/iterators/nodeStream.js +4 -0
  169. package/link/http/iterators/nodeStream.js.map +1 -1
  170. package/link/http/iterators/promise.d.ts +4 -0
  171. package/link/http/iterators/promise.js +4 -0
  172. package/link/http/iterators/promise.js.map +1 -1
  173. package/link/http/iterators/reader.d.ts +4 -0
  174. package/link/http/iterators/reader.js +4 -0
  175. package/link/http/iterators/reader.js.map +1 -1
  176. package/link/http/parseAndCheckHttpResponse.js +51 -10
  177. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  178. package/link/http/responseIterator.d.ts +4 -0
  179. package/link/http/responseIterator.js +6 -0
  180. package/link/http/responseIterator.js.map +1 -1
  181. package/link/http/rewriteURIForGET.d.ts +1 -1
  182. package/link/http/rewriteURIForGET.js +10 -0
  183. package/link/http/rewriteURIForGET.js.map +1 -1
  184. package/link/http/selectHttpOptionsAndBody.d.ts +45 -0
  185. package/link/http/selectHttpOptionsAndBody.js +23 -0
  186. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  187. package/link/http/selectURI.js.map +1 -1
  188. package/link/http/serializeFetchParameter.js.map +1 -1
  189. package/link/persisted-queries/index.d.ts +11 -1
  190. package/link/persisted-queries/index.js +62 -7
  191. package/link/persisted-queries/index.js.map +1 -1
  192. package/link/persisted-queries/persisted-queries.cjs +30 -7
  193. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  194. package/link/persisted-queries/persisted-queries.cjs.native.js +30 -7
  195. package/link/remove-typename/remove-typename.cjs +30 -11
  196. package/link/remove-typename/remove-typename.cjs.map +1 -1
  197. package/link/remove-typename/remove-typename.cjs.native.js +30 -11
  198. package/link/remove-typename/removeTypenameFromVariables.d.ts +9 -1
  199. package/link/remove-typename/removeTypenameFromVariables.js +31 -12
  200. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  201. package/link/retry/delayFunction.d.ts +29 -0
  202. package/link/retry/delayFunction.js +6 -0
  203. package/link/retry/delayFunction.js.map +1 -1
  204. package/link/retry/retry.cjs +5 -5
  205. package/link/retry/retry.cjs.map +1 -1
  206. package/link/retry/retry.cjs.native.js +5 -5
  207. package/link/retry/retryFunction.d.ts +20 -0
  208. package/link/retry/retryLink.d.ts +6 -0
  209. package/link/retry/retryLink.js +31 -6
  210. package/link/retry/retryLink.js.map +1 -1
  211. package/link/schema/index.d.ts +13 -0
  212. package/link/schema/index.js +3 -3
  213. package/link/schema/index.js.map +1 -1
  214. package/link/schema/schema.cjs +3 -3
  215. package/link/schema/schema.cjs.map +1 -1
  216. package/link/schema/schema.cjs.native.js +3 -3
  217. package/link/subscriptions/index.js +35 -2
  218. package/link/subscriptions/index.js.map +1 -1
  219. package/link/subscriptions/subscriptions.cjs +3 -2
  220. package/link/subscriptions/subscriptions.cjs.map +1 -1
  221. package/link/subscriptions/subscriptions.cjs.native.js +3 -2
  222. package/link/utils/createOperation.js.map +1 -1
  223. package/link/utils/filterOperationVariables.js +4 -0
  224. package/link/utils/filterOperationVariables.js.map +1 -1
  225. package/link/utils/toPromise.js.map +1 -1
  226. package/link/utils/transformOperation.js +3 -2
  227. package/link/utils/transformOperation.js.map +1 -1
  228. package/link/utils/utils.cjs +2 -2
  229. package/link/utils/utils.cjs.map +1 -1
  230. package/link/utils/utils.cjs.native.js +2 -2
  231. package/link/utils/validateOperation.js.map +1 -1
  232. package/link/ws/index.d.ts +12 -0
  233. package/link/ws/index.js +1 -1
  234. package/link/ws/index.js.map +1 -1
  235. package/link/ws/ws.cjs +1 -1
  236. package/link/ws/ws.cjs.map +1 -1
  237. package/link/ws/ws.cjs.native.js +1 -1
  238. package/package.json +53 -41
  239. package/react/cache/QueryReference.d.ts +27 -13
  240. package/react/cache/QueryReference.js +122 -42
  241. package/react/cache/QueryReference.js.map +1 -1
  242. package/react/cache/SuspenseCache.d.ts +10 -0
  243. package/react/cache/SuspenseCache.js +1 -2
  244. package/react/cache/SuspenseCache.js.map +1 -1
  245. package/react/cache/getSuspenseCache.js.map +1 -1
  246. package/react/cache/types.d.ts +3 -0
  247. package/react/cache/types.js.map +1 -1
  248. package/react/context/ApolloContext.d.ts +5 -0
  249. package/react/context/ApolloContext.js +10 -3
  250. package/react/context/ApolloContext.js.map +1 -1
  251. package/react/context/context.cjs +1 -3
  252. package/react/context/context.cjs.map +1 -1
  253. package/react/context/context.cjs.native.js +1 -3
  254. package/react/hoc/graphql.js.map +1 -1
  255. package/react/hoc/hoc-utils.js +3 -1
  256. package/react/hoc/hoc-utils.js.map +1 -1
  257. package/react/hoc/hoc.cjs +9 -17
  258. package/react/hoc/hoc.cjs.map +1 -1
  259. package/react/hoc/hoc.cjs.native.js +9 -17
  260. package/react/hoc/mutation-hoc.js +9 -4
  261. package/react/hoc/mutation-hoc.js.map +1 -1
  262. package/react/hoc/query-hoc.js +10 -4
  263. package/react/hoc/query-hoc.js.map +1 -1
  264. package/react/hoc/subscription-hoc.js +10 -4
  265. package/react/hoc/subscription-hoc.js.map +1 -1
  266. package/react/hoc/withApollo.js +3 -4
  267. package/react/hoc/withApollo.js.map +1 -1
  268. package/react/hooks/hooks.cjs +230 -98
  269. package/react/hooks/hooks.cjs.map +1 -1
  270. package/react/hooks/hooks.cjs.native.js +230 -98
  271. package/react/hooks/index.d.ts +4 -0
  272. package/react/hooks/index.js +2 -0
  273. package/react/hooks/index.js.map +1 -1
  274. package/react/hooks/internal/__use.js +5 -0
  275. package/react/hooks/internal/__use.js.map +1 -1
  276. package/react/hooks/internal/index.d.ts +1 -0
  277. package/react/hooks/internal/index.js +2 -0
  278. package/react/hooks/internal/index.js.map +1 -1
  279. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  280. package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -3
  281. package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
  282. package/react/hooks/internal/useRenderGuard.d.ts +2 -0
  283. package/react/hooks/internal/useRenderGuard.js +17 -0
  284. package/react/hooks/internal/useRenderGuard.js.map +1 -0
  285. package/react/hooks/useBackgroundQuery.d.ts +12 -9
  286. package/react/hooks/useBackgroundQuery.js +14 -11
  287. package/react/hooks/useBackgroundQuery.js.map +1 -1
  288. package/react/hooks/useFragment.js +4 -3
  289. package/react/hooks/useFragment.js.map +1 -1
  290. package/react/hooks/useLazyQuery.js +13 -4
  291. package/react/hooks/useLazyQuery.js.map +1 -1
  292. package/react/hooks/useLoadableQuery.d.ts +30 -0
  293. package/react/hooks/useLoadableQuery.js +61 -0
  294. package/react/hooks/useLoadableQuery.js.map +1 -0
  295. package/react/hooks/useMutation.js +8 -3
  296. package/react/hooks/useMutation.js.map +1 -1
  297. package/react/hooks/useQuery.d.ts +11 -0
  298. package/react/hooks/useQuery.js +138 -6
  299. package/react/hooks/useQuery.js.map +1 -1
  300. package/react/hooks/useQueryRefHandlers.d.ts +35 -0
  301. package/react/hooks/useQueryRefHandlers.js +48 -0
  302. package/react/hooks/useQueryRefHandlers.js.map +1 -0
  303. package/react/hooks/useReactiveVar.js +5 -0
  304. package/react/hooks/useReactiveVar.js.map +1 -1
  305. package/react/hooks/useReadQuery.d.ts +19 -0
  306. package/react/hooks/useReadQuery.js +9 -9
  307. package/react/hooks/useReadQuery.js.map +1 -1
  308. package/react/hooks/useSubscription.js +5 -0
  309. package/react/hooks/useSubscription.js.map +1 -1
  310. package/react/hooks/useSuspenseQuery.js +22 -22
  311. package/react/hooks/useSuspenseQuery.js.map +1 -1
  312. package/react/hooks/useSyncExternalStore.js +53 -1
  313. package/react/hooks/useSyncExternalStore.js.map +1 -1
  314. package/react/index.d.ts +2 -0
  315. package/react/index.js +1 -0
  316. package/react/index.js.map +1 -1
  317. package/react/parser/index.d.ts +3 -0
  318. package/react/parser/index.js +16 -6
  319. package/react/parser/index.js.map +1 -1
  320. package/react/parser/parser.cjs +19 -5
  321. package/react/parser/parser.cjs.map +1 -1
  322. package/react/parser/parser.cjs.native.js +19 -5
  323. package/react/query-preloader/createQueryPreloader.d.ts +253 -0
  324. package/react/query-preloader/createQueryPreloader.js +29 -0
  325. package/react/query-preloader/createQueryPreloader.js.map +1 -0
  326. package/react/react.cjs +248 -1
  327. package/react/react.cjs.map +1 -1
  328. package/react/react.cjs.native.js +248 -1
  329. package/react/ssr/RenderPromises.js +21 -1
  330. package/react/ssr/RenderPromises.js.map +1 -1
  331. package/react/ssr/getDataFromTree.js +18 -3
  332. package/react/ssr/getDataFromTree.js.map +1 -1
  333. package/react/ssr/ssr.cjs +6 -4
  334. package/react/ssr/ssr.cjs.map +1 -1
  335. package/react/ssr/ssr.cjs.native.js +6 -4
  336. package/react/types/types.d.ts +129 -1
  337. package/react/types/types.js.map +1 -1
  338. package/testing/core/core.cjs +14 -11
  339. package/testing/core/core.cjs.map +1 -1
  340. package/testing/core/core.cjs.native.js +14 -11
  341. package/testing/core/itAsync.d.ts +1 -1
  342. package/testing/core/itAsync.js.map +1 -1
  343. package/testing/core/mocking/mockFetch.d.ts +2 -2
  344. package/testing/core/mocking/mockFetch.js +8 -4
  345. package/testing/core/mocking/mockFetch.js.map +1 -1
  346. package/testing/core/mocking/mockLink.d.ts +1 -1
  347. package/testing/core/mocking/mockLink.js +17 -7
  348. package/testing/core/mocking/mockLink.js.map +1 -1
  349. package/testing/core/mocking/mockQueryManager.js +2 -0
  350. package/testing/core/mocking/mockQueryManager.js.map +1 -1
  351. package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
  352. package/testing/core/mocking/mockSubscriptionLink.js +1 -1
  353. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  354. package/testing/core/mocking/mockWatchQuery.js +1 -1
  355. package/testing/core/mocking/mockWatchQuery.js.map +1 -1
  356. package/testing/core/observableToPromise.d.ts +17 -3
  357. package/testing/core/observableToPromise.js +5 -0
  358. package/testing/core/observableToPromise.js.map +1 -1
  359. package/testing/core/subscribeAndCount.js +3 -0
  360. package/testing/core/subscribeAndCount.js.map +1 -1
  361. package/testing/core/wait.js +2 -2
  362. package/testing/core/wait.js.map +1 -1
  363. package/testing/core/withConsoleSpy.d.ts +3 -0
  364. package/testing/core/withConsoleSpy.js +7 -1
  365. package/testing/core/withConsoleSpy.js.map +1 -1
  366. package/testing/core/wrap.js +2 -0
  367. package/testing/core/wrap.js.map +1 -1
  368. package/testing/internal/ObservableStream.js +14 -14
  369. package/testing/internal/ObservableStream.js.map +1 -1
  370. package/testing/internal/disposables/disableActWarnings.d.ts +10 -0
  371. package/testing/internal/disposables/disableActWarnings.js +15 -0
  372. package/testing/internal/disposables/disableActWarnings.js.map +1 -0
  373. package/testing/internal/disposables/index.d.ts +1 -0
  374. package/testing/internal/disposables/index.js +1 -0
  375. package/testing/internal/disposables/index.js.map +1 -1
  376. package/testing/internal/disposables/spyOnConsole.d.ts +1 -0
  377. package/testing/internal/disposables/spyOnConsole.js +2 -0
  378. package/testing/internal/disposables/spyOnConsole.js.map +1 -1
  379. package/testing/internal/disposables/withCleanup.d.ts +1 -0
  380. package/testing/internal/disposables/withCleanup.js +3 -0
  381. package/testing/internal/disposables/withCleanup.js.map +1 -1
  382. package/testing/internal/index.d.ts +4 -0
  383. package/testing/internal/index.js +2 -0
  384. package/testing/internal/index.js.map +1 -1
  385. package/testing/internal/profile/Render.d.ts +32 -1
  386. package/testing/internal/profile/Render.js +14 -2
  387. package/testing/internal/profile/Render.js.map +1 -1
  388. package/testing/internal/profile/context.d.ts +10 -0
  389. package/testing/internal/profile/context.js +14 -0
  390. package/testing/internal/profile/context.js.map +1 -0
  391. package/testing/internal/profile/index.d.ts +2 -2
  392. package/testing/internal/profile/index.js +1 -1
  393. package/testing/internal/profile/index.js.map +1 -1
  394. package/testing/internal/profile/profile.d.ts +67 -13
  395. package/testing/internal/profile/profile.js +153 -79
  396. package/testing/internal/profile/profile.js.map +1 -1
  397. package/testing/internal/profile/traces.d.ts +4 -0
  398. package/testing/internal/profile/traces.js +9 -5
  399. package/testing/internal/profile/traces.js.map +1 -1
  400. package/testing/internal/renderHelpers.d.ts +12 -0
  401. package/testing/internal/renderHelpers.js +22 -0
  402. package/testing/internal/renderHelpers.js.map +1 -0
  403. package/testing/internal/scenarios/index.d.ts +41 -0
  404. package/testing/internal/scenarios/index.js +46 -0
  405. package/testing/internal/scenarios/index.js.map +1 -0
  406. package/testing/matchers/ProfiledComponent.js +29 -26
  407. package/testing/matchers/ProfiledComponent.js.map +1 -1
  408. package/testing/matchers/index.js +4 -0
  409. package/testing/matchers/index.js.map +1 -1
  410. package/testing/matchers/toBeDisposed.d.ts +3 -0
  411. package/testing/matchers/toBeDisposed.js +26 -0
  412. package/testing/matchers/toBeDisposed.js.map +1 -0
  413. package/testing/matchers/toBeGarbageCollected.d.ts +8 -0
  414. package/testing/matchers/toBeGarbageCollected.js +48 -0
  415. package/testing/matchers/toBeGarbageCollected.js.map +1 -0
  416. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
  417. package/testing/matchers/toMatchDocument.js.map +1 -1
  418. package/testing/react/MockedProvider.d.ts +5 -1
  419. package/testing/react/MockedProvider.js +6 -2
  420. package/testing/react/MockedProvider.js.map +1 -1
  421. package/testing/testing.cjs +4 -2
  422. package/testing/testing.cjs.map +1 -1
  423. package/testing/testing.cjs.native.js +4 -2
  424. package/utilities/caching/caches.d.ts +34 -0
  425. package/utilities/caching/caches.js +64 -0
  426. package/utilities/caching/caches.js.map +1 -0
  427. package/utilities/caching/getMemoryInternals.d.ts +76 -0
  428. package/utilities/caching/getMemoryInternals.js +112 -0
  429. package/utilities/caching/getMemoryInternals.js.map +1 -0
  430. package/utilities/caching/index.d.ts +4 -0
  431. package/utilities/caching/index.js +3 -0
  432. package/utilities/caching/index.js.map +1 -0
  433. package/utilities/caching/sizes.d.ts +261 -0
  434. package/utilities/caching/sizes.js +27 -0
  435. package/utilities/caching/sizes.js.map +1 -0
  436. package/utilities/common/arrays.js +1 -0
  437. package/utilities/common/arrays.js.map +1 -1
  438. package/utilities/common/canUse.js +17 -2
  439. package/utilities/common/canUse.js.map +1 -1
  440. package/utilities/common/canonicalStringify.d.ts +17 -0
  441. package/utilities/common/canonicalStringify.js +49 -2
  442. package/utilities/common/canonicalStringify.js.map +1 -1
  443. package/utilities/common/cloneDeep.d.ts +3 -0
  444. package/utilities/common/cloneDeep.js +5 -0
  445. package/utilities/common/cloneDeep.js.map +1 -1
  446. package/utilities/common/compact.d.ts +4 -0
  447. package/utilities/common/compact.js +4 -0
  448. package/utilities/common/compact.js.map +1 -1
  449. package/utilities/common/errorHandling.js +1 -3
  450. package/utilities/common/errorHandling.js.map +1 -1
  451. package/utilities/common/incrementalResult.js +3 -0
  452. package/utilities/common/incrementalResult.js.map +1 -1
  453. package/utilities/common/makeUniqueId.js +2 -0
  454. package/utilities/common/makeUniqueId.js.map +1 -1
  455. package/utilities/common/maybeDeepFreeze.js +3 -0
  456. package/utilities/common/maybeDeepFreeze.js.map +1 -1
  457. package/utilities/common/mergeDeep.js +12 -1
  458. package/utilities/common/mergeDeep.js.map +1 -1
  459. package/utilities/common/mergeOptions.d.ts +1 -1
  460. package/utilities/common/mergeOptions.js.map +1 -1
  461. package/utilities/common/omitDeep.js.map +1 -1
  462. package/utilities/globals/global.js +7 -1
  463. package/utilities/globals/global.js.map +1 -1
  464. package/utilities/globals/globals.cjs +4 -5
  465. package/utilities/globals/globals.cjs.map +1 -1
  466. package/utilities/globals/globals.cjs.native.js +4 -5
  467. package/utilities/globals/index.d.ts +4 -0
  468. package/utilities/globals/index.js +7 -0
  469. package/utilities/globals/index.js.map +1 -1
  470. package/utilities/globals/invariantWrappers.d.ts +40 -0
  471. package/utilities/globals/invariantWrappers.js +11 -3
  472. package/utilities/globals/invariantWrappers.js.map +1 -1
  473. package/utilities/globals/maybe.js.map +1 -1
  474. package/utilities/graphql/DocumentTransform.d.ts +20 -6
  475. package/utilities/graphql/DocumentTransform.js +54 -29
  476. package/utilities/graphql/DocumentTransform.js.map +1 -1
  477. package/utilities/graphql/directives.js +3 -0
  478. package/utilities/graphql/directives.js.map +1 -1
  479. package/utilities/graphql/fragments.d.ts +25 -0
  480. package/utilities/graphql/fragments.js +36 -0
  481. package/utilities/graphql/fragments.js.map +1 -1
  482. package/utilities/graphql/getFromAST.d.ts +5 -0
  483. package/utilities/graphql/getFromAST.js +9 -0
  484. package/utilities/graphql/getFromAST.js.map +1 -1
  485. package/utilities/graphql/print.js +8 -5
  486. package/utilities/graphql/print.js.map +1 -1
  487. package/utilities/graphql/storeUtils.d.ts +14 -0
  488. package/utilities/graphql/storeUtils.js +8 -2
  489. package/utilities/graphql/storeUtils.js.map +1 -1
  490. package/utilities/graphql/transform.js +106 -7
  491. package/utilities/graphql/transform.js.map +1 -1
  492. package/utilities/index.d.ts +4 -0
  493. package/utilities/index.js +1 -0
  494. package/utilities/index.js.map +1 -1
  495. package/utilities/observables/Concast.d.ts +1 -1
  496. package/utilities/observables/Concast.js +85 -2
  497. package/utilities/observables/Concast.js.map +1 -1
  498. package/utilities/observables/Observable.js +6 -0
  499. package/utilities/observables/Observable.js.map +1 -1
  500. package/utilities/observables/asyncMap.js +12 -3
  501. package/utilities/observables/asyncMap.js.map +1 -1
  502. package/utilities/observables/iteration.js +3 -0
  503. package/utilities/observables/iteration.js.map +1 -1
  504. package/utilities/observables/subclassing.js +14 -0
  505. package/utilities/observables/subclassing.js.map +1 -1
  506. package/utilities/policies/pagination.js +47 -3
  507. package/utilities/policies/pagination.js.map +1 -1
  508. package/utilities/promises/decoration.js +1 -0
  509. package/utilities/promises/decoration.js.map +1 -1
  510. package/utilities/subscriptions/relay/index.js.map +1 -1
  511. package/utilities/subscriptions/relay/relay.cjs +9 -8
  512. package/utilities/subscriptions/relay/relay.cjs.map +1 -1
  513. package/utilities/subscriptions/relay/relay.cjs.native.js +9 -8
  514. package/utilities/subscriptions/urql/index.js.map +1 -1
  515. package/utilities/subscriptions/urql/urql.cjs +9 -8
  516. package/utilities/subscriptions/urql/urql.cjs.map +1 -1
  517. package/utilities/subscriptions/urql/urql.cjs.native.js +9 -8
  518. package/utilities/types/DeepOmit.js.map +1 -1
  519. package/utilities/types/DeepPartial.d.ts +1 -1
  520. package/utilities/types/DeepPartial.js +4 -0
  521. package/utilities/types/DeepPartial.js.map +1 -1
  522. package/utilities/types/IsStrictlyAny.js.map +1 -1
  523. package/utilities/types/OnlyRequiredProperties.d.ts +7 -0
  524. package/utilities/types/OnlyRequiredProperties.js +2 -0
  525. package/utilities/types/OnlyRequiredProperties.js.map +1 -0
  526. package/utilities/types/TODO.d.ts +3 -0
  527. package/utilities/types/TODO.js +2 -0
  528. package/utilities/types/TODO.js.map +1 -0
  529. package/utilities/utilities.cjs +114 -58
  530. package/utilities/utilities.cjs.map +1 -1
  531. package/utilities/utilities.cjs.native.js +114 -58
  532. package/version.js +1 -1
  533. package/cache/core/cache.d.ts.map +0 -1
  534. package/cache/core/types/Cache.d.ts.map +0 -1
  535. package/cache/core/types/DataProxy.d.ts.map +0 -1
  536. package/cache/core/types/common.d.ts.map +0 -1
  537. package/cache/index.d.ts.map +0 -1
  538. package/cache/inmemory/entityStore.d.ts.map +0 -1
  539. package/cache/inmemory/fixPolyfills.d.ts.map +0 -1
  540. package/cache/inmemory/fixPolyfills.native.d.ts.map +0 -1
  541. package/cache/inmemory/fragmentRegistry.d.ts.map +0 -1
  542. package/cache/inmemory/helpers.d.ts.map +0 -1
  543. package/cache/inmemory/inMemoryCache.d.ts.map +0 -1
  544. package/cache/inmemory/key-extractor.d.ts.map +0 -1
  545. package/cache/inmemory/object-canon.d.ts.map +0 -1
  546. package/cache/inmemory/policies.d.ts.map +0 -1
  547. package/cache/inmemory/reactiveVars.d.ts.map +0 -1
  548. package/cache/inmemory/readFromStore.d.ts.map +0 -1
  549. package/cache/inmemory/types.d.ts.map +0 -1
  550. package/cache/inmemory/writeToStore.d.ts.map +0 -1
  551. package/config/jest/setup.d.ts.map +0 -1
  552. package/core/ApolloClient.d.ts.map +0 -1
  553. package/core/LocalState.d.ts.map +0 -1
  554. package/core/ObservableQuery.d.ts.map +0 -1
  555. package/core/QueryInfo.d.ts.map +0 -1
  556. package/core/QueryManager.d.ts.map +0 -1
  557. package/core/equalByQuery.d.ts.map +0 -1
  558. package/core/index.d.ts.map +0 -1
  559. package/core/networkStatus.d.ts.map +0 -1
  560. package/core/types.d.ts.map +0 -1
  561. package/core/watchQueryOptions.d.ts.map +0 -1
  562. package/dev/index.d.ts.map +0 -1
  563. package/dev/loadDevMessages.d.ts.map +0 -1
  564. package/dev/loadErrorMessageHandler.d.ts.map +0 -1
  565. package/dev/loadErrorMessages.d.ts.map +0 -1
  566. package/errors/index.d.ts.map +0 -1
  567. package/index.d.ts.map +0 -1
  568. package/invariantErrorCodes.d.ts.map +0 -1
  569. package/link/batch/batchLink.d.ts.map +0 -1
  570. package/link/batch/batching.d.ts.map +0 -1
  571. package/link/batch/index.d.ts.map +0 -1
  572. package/link/batch-http/batchHttpLink.d.ts.map +0 -1
  573. package/link/batch-http/index.d.ts.map +0 -1
  574. package/link/context/index.d.ts.map +0 -1
  575. package/link/core/ApolloLink.d.ts.map +0 -1
  576. package/link/core/concat.d.ts.map +0 -1
  577. package/link/core/empty.d.ts.map +0 -1
  578. package/link/core/execute.d.ts.map +0 -1
  579. package/link/core/from.d.ts.map +0 -1
  580. package/link/core/index.d.ts.map +0 -1
  581. package/link/core/split.d.ts.map +0 -1
  582. package/link/core/types.d.ts.map +0 -1
  583. package/link/error/index.d.ts.map +0 -1
  584. package/link/http/HttpLink.d.ts.map +0 -1
  585. package/link/http/checkFetcher.d.ts.map +0 -1
  586. package/link/http/createHttpLink.d.ts.map +0 -1
  587. package/link/http/createSignalIfSupported.d.ts.map +0 -1
  588. package/link/http/index.d.ts.map +0 -1
  589. package/link/http/iterators/async.d.ts.map +0 -1
  590. package/link/http/iterators/nodeStream.d.ts.map +0 -1
  591. package/link/http/iterators/promise.d.ts.map +0 -1
  592. package/link/http/iterators/reader.d.ts.map +0 -1
  593. package/link/http/parseAndCheckHttpResponse.d.ts.map +0 -1
  594. package/link/http/responseIterator.d.ts.map +0 -1
  595. package/link/http/rewriteURIForGET.d.ts.map +0 -1
  596. package/link/http/selectHttpOptionsAndBody.d.ts.map +0 -1
  597. package/link/http/selectURI.d.ts.map +0 -1
  598. package/link/http/serializeFetchParameter.d.ts.map +0 -1
  599. package/link/persisted-queries/index.d.ts.map +0 -1
  600. package/link/remove-typename/index.d.ts.map +0 -1
  601. package/link/remove-typename/removeTypenameFromVariables.d.ts.map +0 -1
  602. package/link/retry/delayFunction.d.ts.map +0 -1
  603. package/link/retry/index.d.ts.map +0 -1
  604. package/link/retry/retryFunction.d.ts.map +0 -1
  605. package/link/retry/retryLink.d.ts.map +0 -1
  606. package/link/schema/index.d.ts.map +0 -1
  607. package/link/subscriptions/index.d.ts.map +0 -1
  608. package/link/utils/createOperation.d.ts.map +0 -1
  609. package/link/utils/filterOperationVariables.d.ts.map +0 -1
  610. package/link/utils/fromError.d.ts.map +0 -1
  611. package/link/utils/fromPromise.d.ts.map +0 -1
  612. package/link/utils/index.d.ts.map +0 -1
  613. package/link/utils/throwServerError.d.ts.map +0 -1
  614. package/link/utils/toPromise.d.ts.map +0 -1
  615. package/link/utils/transformOperation.d.ts.map +0 -1
  616. package/link/utils/validateOperation.d.ts.map +0 -1
  617. package/link/ws/index.d.ts.map +0 -1
  618. package/react/cache/QueryReference.d.ts.map +0 -1
  619. package/react/cache/SuspenseCache.d.ts.map +0 -1
  620. package/react/cache/getSuspenseCache.d.ts.map +0 -1
  621. package/react/cache/index.d.ts.map +0 -1
  622. package/react/cache/types.d.ts.map +0 -1
  623. package/react/components/Mutation.d.ts.map +0 -1
  624. package/react/components/Query.d.ts.map +0 -1
  625. package/react/components/Subscription.d.ts.map +0 -1
  626. package/react/components/index.d.ts.map +0 -1
  627. package/react/components/types.d.ts.map +0 -1
  628. package/react/context/ApolloConsumer.d.ts.map +0 -1
  629. package/react/context/ApolloContext.d.ts.map +0 -1
  630. package/react/context/ApolloProvider.d.ts.map +0 -1
  631. package/react/context/index.d.ts.map +0 -1
  632. package/react/hoc/graphql.d.ts.map +0 -1
  633. package/react/hoc/hoc-utils.d.ts.map +0 -1
  634. package/react/hoc/index.d.ts.map +0 -1
  635. package/react/hoc/mutation-hoc.d.ts.map +0 -1
  636. package/react/hoc/query-hoc.d.ts.map +0 -1
  637. package/react/hoc/subscription-hoc.d.ts.map +0 -1
  638. package/react/hoc/types.d.ts.map +0 -1
  639. package/react/hoc/withApollo.d.ts.map +0 -1
  640. package/react/hooks/constants.d.ts.map +0 -1
  641. package/react/hooks/index.d.ts.map +0 -1
  642. package/react/hooks/internal/__use.d.ts.map +0 -1
  643. package/react/hooks/internal/index.d.ts.map +0 -1
  644. package/react/hooks/internal/useDeepMemo.d.ts.map +0 -1
  645. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +0 -1
  646. package/react/hooks/useApolloClient.d.ts.map +0 -1
  647. package/react/hooks/useBackgroundQuery.d.ts.map +0 -1
  648. package/react/hooks/useFragment.d.ts.map +0 -1
  649. package/react/hooks/useLazyQuery.d.ts.map +0 -1
  650. package/react/hooks/useMutation.d.ts.map +0 -1
  651. package/react/hooks/useQuery.d.ts.map +0 -1
  652. package/react/hooks/useReactiveVar.d.ts.map +0 -1
  653. package/react/hooks/useReadQuery.d.ts.map +0 -1
  654. package/react/hooks/useSubscription.d.ts.map +0 -1
  655. package/react/hooks/useSuspenseQuery.d.ts.map +0 -1
  656. package/react/hooks/useSyncExternalStore.d.ts.map +0 -1
  657. package/react/index.d.ts.map +0 -1
  658. package/react/parser/index.d.ts.map +0 -1
  659. package/react/ssr/RenderPromises.d.ts.map +0 -1
  660. package/react/ssr/getDataFromTree.d.ts.map +0 -1
  661. package/react/ssr/index.d.ts.map +0 -1
  662. package/react/ssr/renderToStringWithData.d.ts.map +0 -1
  663. package/react/types/types.d.ts.map +0 -1
  664. package/testing/core/index.d.ts.map +0 -1
  665. package/testing/core/itAsync.d.ts.map +0 -1
  666. package/testing/core/mocking/mockClient.d.ts.map +0 -1
  667. package/testing/core/mocking/mockFetch.d.ts.map +0 -1
  668. package/testing/core/mocking/mockLink.d.ts.map +0 -1
  669. package/testing/core/mocking/mockQueryManager.d.ts.map +0 -1
  670. package/testing/core/mocking/mockSubscriptionLink.d.ts.map +0 -1
  671. package/testing/core/mocking/mockWatchQuery.d.ts.map +0 -1
  672. package/testing/core/observableToPromise.d.ts.map +0 -1
  673. package/testing/core/subscribeAndCount.d.ts.map +0 -1
  674. package/testing/core/wait.d.ts.map +0 -1
  675. package/testing/core/withConsoleSpy.d.ts.map +0 -1
  676. package/testing/core/wrap.d.ts.map +0 -1
  677. package/testing/index.d.ts.map +0 -1
  678. package/testing/internal/ObservableStream.d.ts.map +0 -1
  679. package/testing/internal/disposables/index.d.ts.map +0 -1
  680. package/testing/internal/disposables/spyOnConsole.d.ts.map +0 -1
  681. package/testing/internal/disposables/withCleanup.d.ts.map +0 -1
  682. package/testing/internal/index.d.ts.map +0 -1
  683. package/testing/internal/profile/Render.d.ts.map +0 -1
  684. package/testing/internal/profile/index.d.ts.map +0 -1
  685. package/testing/internal/profile/profile.d.ts.map +0 -1
  686. package/testing/internal/profile/traces.d.ts.map +0 -1
  687. package/testing/matchers/ProfiledComponent.d.ts.map +0 -1
  688. package/testing/matchers/index.d.ts.map +0 -1
  689. package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts.map +0 -1
  690. package/testing/matchers/toMatchDocument.d.ts.map +0 -1
  691. package/testing/react/MockedProvider.d.ts.map +0 -1
  692. package/utilities/common/arrays.d.ts.map +0 -1
  693. package/utilities/common/canUse.d.ts.map +0 -1
  694. package/utilities/common/canonicalStringify.d.ts.map +0 -1
  695. package/utilities/common/cloneDeep.d.ts.map +0 -1
  696. package/utilities/common/compact.d.ts.map +0 -1
  697. package/utilities/common/errorHandling.d.ts.map +0 -1
  698. package/utilities/common/filterInPlace.d.ts +0 -2
  699. package/utilities/common/filterInPlace.d.ts.map +0 -1
  700. package/utilities/common/filterInPlace.js +0 -11
  701. package/utilities/common/filterInPlace.js.map +0 -1
  702. package/utilities/common/incrementalResult.d.ts.map +0 -1
  703. package/utilities/common/makeUniqueId.d.ts.map +0 -1
  704. package/utilities/common/maybeDeepFreeze.d.ts.map +0 -1
  705. package/utilities/common/mergeDeep.d.ts.map +0 -1
  706. package/utilities/common/mergeOptions.d.ts.map +0 -1
  707. package/utilities/common/objects.d.ts.map +0 -1
  708. package/utilities/common/omitDeep.d.ts.map +0 -1
  709. package/utilities/common/stringifyForDisplay.d.ts.map +0 -1
  710. package/utilities/common/stripTypename.d.ts.map +0 -1
  711. package/utilities/globals/global.d.ts.map +0 -1
  712. package/utilities/globals/index.d.ts.map +0 -1
  713. package/utilities/globals/invariantWrappers.d.ts.map +0 -1
  714. package/utilities/globals/maybe.d.ts.map +0 -1
  715. package/utilities/graphql/DocumentTransform.d.ts.map +0 -1
  716. package/utilities/graphql/directives.d.ts.map +0 -1
  717. package/utilities/graphql/fragments.d.ts.map +0 -1
  718. package/utilities/graphql/getFromAST.d.ts.map +0 -1
  719. package/utilities/graphql/operations.d.ts.map +0 -1
  720. package/utilities/graphql/print.d.ts.map +0 -1
  721. package/utilities/graphql/storeUtils.d.ts.map +0 -1
  722. package/utilities/graphql/transform.d.ts.map +0 -1
  723. package/utilities/index.d.ts.map +0 -1
  724. package/utilities/observables/Concast.d.ts.map +0 -1
  725. package/utilities/observables/Observable.d.ts.map +0 -1
  726. package/utilities/observables/asyncMap.d.ts.map +0 -1
  727. package/utilities/observables/iteration.d.ts.map +0 -1
  728. package/utilities/observables/subclassing.d.ts.map +0 -1
  729. package/utilities/policies/pagination.d.ts.map +0 -1
  730. package/utilities/promises/decoration.d.ts.map +0 -1
  731. package/utilities/subscriptions/relay/index.d.ts.map +0 -1
  732. package/utilities/subscriptions/shared.d.ts.map +0 -1
  733. package/utilities/subscriptions/urql/index.d.ts.map +0 -1
  734. package/utilities/types/DeepOmit.d.ts.map +0 -1
  735. package/utilities/types/DeepPartial.d.ts.map +0 -1
  736. package/utilities/types/IsStrictlyAny.d.ts.map +0 -1
  737. package/utilities/types/Primitive.d.ts.map +0 -1
  738. package/version.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableQuery.js","sourceRoot":"","sources":["../../src/core/ObservableQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAM7E,OAAO,EACL,SAAS,EACT,OAAO,EACP,sBAAsB,EACtB,UAAU,EACV,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAkB/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEzC,IAAA,MAAM,GAAqB,MAAM,OAA3B,EAAE,cAAc,GAAK,MAAM,eAAX,CAAY;AAyB1C;IAGU,mCAAoC;IAwC5C,yBAAY,EAQX;YAPC,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,OAAO,aAAA;QAHT,YASE,kBAAM,UAAC,QAA4C;YAGjD,IAAI;gBACF,IAAI,WAAW,GAAI,QAAgB,CAAC,aAAa,CAAC,SAAS,CAAC;gBAC5D,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;oBACrC,WAAW,CAAC,KAAK,GAAG,wCAAwC,CAAC;iBAC9D;aACF;YAAC,WAAM,GAAE;YAEV,IAAM,KAAK,GAAG,CAAC,KAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YACnC,KAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAG7B,IAAM,IAAI,GAAG,KAAI,CAAC,IAAI,CAAC;YACvB,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;gBACtB,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC9C;iBAAM,IAAI,IAAI,IAA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K,UAAU,EAAE;oBACzC,OAAO,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;iBAC/C;gBAED,OAAO,WAAY,CAAC;YACtB,CAAC;SACF,CAAC,CAAC;KACJ;IAED,OAAO,QAAQ,CAAC,SAAS,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,wCAAwC,CAAC,KAAkB;IAClE,SAAS,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,OAAsD;IAEtD,IAAI,OAAO,IAAI,OAAO,EAAE;QACtB,SAAS,CAAC,KAAK,CAAC,iCAAiC,EAAE,OAAO,CAAC,CAAC;KAC7D;AACH,CAAC;AAED,SAAS,gBAAgB,CACvB,WAAmC;IAEnC,OAAO,CACL,WAAW,KAAK,cAAc;QAC9B,WAAW,KAAK,UAAU;QAC1B,WAAW,KAAK,SAAS,CAC1B,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from \"../utilities/globals/index.js\";\nimport type { DocumentNode } from \"graphql\";\nimport { equal } from \"@wry/equality\";\n\nimport { NetworkStatus, isNetworkRequestInFlight } from \"./networkStatus.js\";\nimport type {\n Concast,\n Observer,\n ObservableSubscription,\n} from \"../utilities/index.js\";\nimport {\n cloneDeep,\n compact,\n getOperationDefinition,\n Observable,\n iterateObserversSafely,\n fixObservableSubclass,\n getQueryDefinition,\n} from \"../utilities/index.js\";\nimport type { ApolloError } from \"../errors/index.js\";\nimport type { QueryManager } from \"./QueryManager.js\";\nimport type {\n ApolloQueryResult,\n OperationVariables,\n TypedDocumentNode,\n} from \"./types.js\";\nimport type {\n WatchQueryOptions,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n NextFetchPolicyContext,\n WatchQueryFetchPolicy,\n} from \"./watchQueryOptions.js\";\nimport type { QueryInfo } from \"./QueryInfo.js\";\nimport type { MissingFieldError } from \"../cache/index.js\";\nimport type { MissingTree } from \"../cache/core/types/common.js\";\nimport { equalByQuery } from \"./equalByQuery.js\";\n\nconst { assign, hasOwnProperty } = Object;\n\nexport interface FetchMoreOptions<\n TData = any,\n TVariables = OperationVariables,\n> {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult?: TData;\n variables?: TVariables;\n }\n ) => TData;\n}\n\nexport interface UpdateQueryOptions<TVariables> {\n variables?: TVariables;\n}\n\ninterface Last<TData, TVariables> {\n result: ApolloQueryResult<TData>;\n variables?: TVariables;\n error?: ApolloError;\n}\n\nexport class ObservableQuery<\n TData = any,\n TVariables extends OperationVariables = OperationVariables,\n> extends Observable<ApolloQueryResult<TData>> {\n public readonly options: WatchQueryOptions<TVariables, TData>;\n public readonly queryId: string;\n public readonly queryName?: string;\n\n // The `query` computed property will always reflect the document transformed\n // by the last run query. `this.options.query` will always reflect the raw\n // untransformed query to ensure document transforms with runtime conditionals\n // are run on the original document.\n public get query(): TypedDocumentNode<TData, TVariables> {\n return this.lastQuery || this.options.query;\n }\n\n // Computed shorthand for this.options.variables, preserved for\n // backwards compatibility.\n public get variables(): TVariables | undefined {\n return this.options.variables;\n }\n\n private isTornDown: boolean;\n private queryManager: QueryManager<any>;\n private observers = new Set<Observer<ApolloQueryResult<TData>>>();\n private subscriptions = new Set<ObservableSubscription>();\n\n private waitForOwnResult: boolean;\n private last?: Last<TData, TVariables>;\n private lastQuery?: DocumentNode;\n\n private queryInfo: QueryInfo;\n\n // When this.concast is defined, this.observer is the Observer currently\n // subscribed to that Concast.\n private concast?: Concast<ApolloQueryResult<TData>>;\n private observer?: Observer<ApolloQueryResult<TData>>;\n\n private pollingInfo?: {\n interval: number;\n timeout: ReturnType<typeof setTimeout>;\n };\n\n constructor({\n queryManager,\n queryInfo,\n options,\n }: {\n queryManager: QueryManager<any>;\n queryInfo: QueryInfo;\n options: WatchQueryOptions<TVariables, TData>;\n }) {\n super((observer: Observer<ApolloQueryResult<TData>>) => {\n // Zen Observable has its own error function, so in order to log correctly\n // we need to provide a custom error callback.\n try {\n var subObserver = (observer as any)._subscription._observer;\n if (subObserver && !subObserver.error) {\n subObserver.error = defaultSubscriptionObserverErrorCallback;\n }\n } catch {}\n\n const first = !this.observers.size;\n this.observers.add(observer);\n\n // Deliver most recent error or result.\n const last = this.last;\n if (last && last.error) {\n observer.error && observer.error(last.error);\n } else if (last && last.result) {\n observer.next && observer.next(last.result);\n }\n\n // Initiate observation of this query if it hasn't been reported to\n // the QueryManager yet.\n if (first) {\n // Blindly catching here prevents unhandled promise rejections,\n // and is safe because the ObservableQuery handles this error with\n // this.observer.error, so we're not just swallowing the error by\n // ignoring it here.\n this.reobserve().catch(() => {});\n }\n\n return () => {\n if (this.observers.delete(observer) && !this.observers.size) {\n this.tearDownQuery();\n }\n };\n });\n\n // related classes\n this.queryInfo = queryInfo;\n this.queryManager = queryManager;\n\n // active state\n this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy);\n this.isTornDown = false;\n\n const {\n watchQuery: { fetchPolicy: defaultFetchPolicy = \"cache-first\" } = {},\n } = queryManager.defaultOptions;\n\n const {\n fetchPolicy = defaultFetchPolicy,\n // Make sure we don't store \"standby\" as the initialFetchPolicy.\n initialFetchPolicy = fetchPolicy === \"standby\"\n ? defaultFetchPolicy\n : fetchPolicy,\n } = options;\n\n this.options = {\n ...options,\n\n // Remember the initial options.fetchPolicy so we can revert back to this\n // policy when variables change. This information can also be specified\n // (or overridden) by providing options.initialFetchPolicy explicitly.\n initialFetchPolicy,\n\n // This ensures this.options.fetchPolicy always has a string value, in\n // case options.fetchPolicy was not provided.\n fetchPolicy,\n };\n\n this.queryId = queryInfo.queryId || queryManager.generateQueryId();\n\n const opDef = getOperationDefinition(this.query);\n this.queryName = opDef && opDef.name && opDef.name.value;\n }\n\n public result(): Promise<ApolloQueryResult<TData>> {\n return new Promise((resolve, reject) => {\n // TODO: this code doesn’t actually make sense insofar as the observer\n // will never exist in this.observers due how zen-observable wraps observables.\n // https://github.com/zenparsing/zen-observable/blob/master/src/Observable.js#L169\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: (result: ApolloQueryResult<TData>) => {\n resolve(result);\n\n // Stop the query within the QueryManager if we can before\n // this function returns.\n //\n // We do this in order to prevent observers piling up within\n // the QueryManager. Notice that we only fully unsubscribe\n // from the subscription in a setTimeout(..., 0) call. This call can\n // actually be handled by the browser at a much later time. If queries\n // are fired in the meantime, observers that should have been removed\n // from the QueryManager will continue to fire, causing an unnecessary\n // performance hit.\n this.observers.delete(observer);\n if (!this.observers.size) {\n this.queryManager.removeQuery(this.queryId);\n }\n\n setTimeout(() => {\n subscription.unsubscribe();\n }, 0);\n },\n error: reject,\n };\n const subscription = this.subscribe(observer);\n });\n }\n\n public getCurrentResult(saveAsLastResult = true): ApolloQueryResult<TData> {\n // Use the last result as long as the variables match this.variables.\n const lastResult = this.getLastResult(true);\n\n const networkStatus =\n this.queryInfo.networkStatus ||\n (lastResult && lastResult.networkStatus) ||\n NetworkStatus.ready;\n\n const result = {\n ...lastResult,\n loading: isNetworkRequestInFlight(networkStatus),\n networkStatus,\n } as ApolloQueryResult<TData>;\n\n const { fetchPolicy = \"cache-first\" } = this.options;\n if (\n // These fetch policies should never deliver data from the cache, unless\n // redelivering a previously delivered result.\n skipCacheDataFor(fetchPolicy) ||\n // If this.options.query has @client(always: true) fields, we cannot\n // trust diff.result, since it was read from the cache without running\n // local resolvers (and it's too late to run resolvers now, since we must\n // return a result synchronously).\n this.queryManager.getDocumentInfo(this.query).hasForcedResolvers\n ) {\n // Fall through.\n } else if (this.waitForOwnResult) {\n // This would usually be a part of `QueryInfo.getDiff()`.\n // which we skip in the waitForOwnResult case since we are not\n // interested in the diff.\n this.queryInfo[\"updateWatch\"]();\n } else {\n const diff = this.queryInfo.getDiff();\n\n if (diff.complete || this.options.returnPartialData) {\n result.data = diff.result;\n }\n\n if (equal(result.data, {})) {\n result.data = void 0 as any;\n }\n\n if (diff.complete) {\n // Similar to setting result.partial to false, but taking advantage of the\n // falsiness of missing fields.\n delete result.partial;\n\n // If the diff is complete, and we're using a FetchPolicy that\n // terminates after a complete cache read, we can assume the next result\n // we receive will have NetworkStatus.ready and !loading.\n if (\n diff.complete &&\n result.networkStatus === NetworkStatus.loading &&\n (fetchPolicy === \"cache-first\" || fetchPolicy === \"cache-only\")\n ) {\n result.networkStatus = NetworkStatus.ready;\n result.loading = false;\n }\n } else {\n result.partial = true;\n }\n\n if (\n __DEV__ &&\n !diff.complete &&\n !this.options.partialRefetch &&\n !result.loading &&\n !result.data &&\n !result.error\n ) {\n logMissingFieldErrors(diff.missing);\n }\n }\n\n if (saveAsLastResult) {\n this.updateLastResult(result);\n }\n\n return result;\n }\n\n // Compares newResult to the snapshot we took of this.lastResult when it was\n // first received.\n public isDifferentFromLastResult(\n newResult: ApolloQueryResult<TData>,\n variables?: TVariables\n ) {\n if (!this.last) {\n return true;\n }\n\n const resultIsDifferent = this.queryManager.getDocumentInfo(this.query)\n .hasNonreactiveDirective\n ? !equalByQuery(this.query, this.last.result, newResult, this.variables)\n : !equal(this.last.result, newResult);\n\n return (\n resultIsDifferent || (variables && !equal(this.last.variables, variables))\n );\n }\n\n private getLast<K extends keyof Last<TData, TVariables>>(\n key: K,\n variablesMustMatch?: boolean\n ) {\n const last = this.last;\n if (\n last &&\n last[key] &&\n (!variablesMustMatch || equal(last.variables, this.variables))\n ) {\n return last[key];\n }\n }\n\n public getLastResult(\n variablesMustMatch?: boolean\n ): ApolloQueryResult<TData> | undefined {\n return this.getLast(\"result\", variablesMustMatch);\n }\n\n public getLastError(variablesMustMatch?: boolean): ApolloError | undefined {\n return this.getLast(\"error\", variablesMustMatch);\n }\n\n public resetLastResults(): void {\n delete this.last;\n this.isTornDown = false;\n }\n\n public resetQueryStoreErrors() {\n this.queryManager.resetErrors(this.queryId);\n }\n\n /**\n * Update the variables of this observable query, and fetch the new results.\n * This method should be preferred over `setVariables` in most use cases.\n *\n * @param variables: The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public refetch(\n variables?: Partial<TVariables>\n ): Promise<ApolloQueryResult<TData>> {\n const reobserveOptions: Partial<WatchQueryOptions<TVariables, TData>> = {\n // Always disable polling for refetches.\n pollInterval: 0,\n };\n\n // Unless the provided fetchPolicy always consults the network\n // (no-cache, network-only, or cache-and-network), override it with\n // network-only to force the refetch for this fetchQuery call.\n const { fetchPolicy } = this.options;\n if (fetchPolicy === \"cache-and-network\") {\n reobserveOptions.fetchPolicy = fetchPolicy;\n } else if (fetchPolicy === \"no-cache\") {\n reobserveOptions.fetchPolicy = \"no-cache\";\n } else {\n reobserveOptions.fetchPolicy = \"network-only\";\n }\n\n if (__DEV__ && variables && hasOwnProperty.call(variables, \"variables\")) {\n const queryDef = getQueryDefinition(this.query);\n const vars = queryDef.variableDefinitions;\n if (!vars || !vars.some((v) => v.variable.name.value === \"variables\")) {\n invariant.warn(\n `Called refetch(%o) for query %o, which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?`,\n variables,\n queryDef.name?.value || queryDef\n );\n }\n }\n\n if (variables && !equal(this.options.variables, variables)) {\n // Update the existing options with new variables\n reobserveOptions.variables = this.options.variables = {\n ...this.options.variables,\n ...variables,\n } as TVariables;\n }\n\n this.queryInfo.resetLastWrite();\n return this.reobserve(reobserveOptions, NetworkStatus.refetch);\n }\n\n public fetchMore<\n TFetchData = TData,\n TFetchVars extends OperationVariables = TVariables,\n >(\n fetchMoreOptions: FetchMoreQueryOptions<TFetchVars, TFetchData> & {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult: TFetchData;\n variables: TFetchVars;\n }\n ) => TData;\n }\n ): Promise<ApolloQueryResult<TFetchData>> {\n const combinedOptions = {\n ...(fetchMoreOptions.query\n ? fetchMoreOptions\n : {\n ...this.options,\n query: this.options.query,\n ...fetchMoreOptions,\n variables: {\n ...this.options.variables,\n ...fetchMoreOptions.variables,\n },\n }),\n // The fetchMore request goes immediately to the network and does\n // not automatically write its result to the cache (hence no-cache\n // instead of network-only), because we allow the caller of\n // fetchMore to provide an updateQuery callback that determines how\n // the data gets written to the cache.\n fetchPolicy: \"no-cache\",\n } as WatchQueryOptions<TFetchVars, TFetchData>;\n\n combinedOptions.query = this.transformDocument(combinedOptions.query);\n\n const qid = this.queryManager.generateQueryId();\n\n // If a temporary query is passed to `fetchMore`, we don't want to store\n // it as the last query result since it may be an optimized query for\n // pagination. We will however run the transforms on the original document\n // as well as the document passed in `fetchMoreOptions` to ensure the cache\n // uses the most up-to-date document which may rely on runtime conditionals.\n this.lastQuery = fetchMoreOptions.query\n ? this.transformDocument(this.options.query)\n : combinedOptions.query;\n\n // Simulate a loading result for the original query with\n // result.networkStatus === NetworkStatus.fetchMore.\n const { queryInfo } = this;\n const originalNetworkStatus = queryInfo.networkStatus;\n queryInfo.networkStatus = NetworkStatus.fetchMore;\n if (combinedOptions.notifyOnNetworkStatusChange) {\n this.observe();\n }\n\n const updatedQuerySet = new Set<DocumentNode>();\n\n return this.queryManager\n .fetchQuery(qid, combinedOptions, NetworkStatus.fetchMore)\n .then((fetchMoreResult) => {\n this.queryManager.removeQuery(qid);\n\n if (queryInfo.networkStatus === NetworkStatus.fetchMore) {\n queryInfo.networkStatus = originalNetworkStatus;\n }\n\n // Performing this cache update inside a cache.batch transaction ensures\n // any affected cache.watch watchers are notified at most once about any\n // updates. Most watchers will be using the QueryInfo class, which\n // responds to notifications by calling reobserveCacheFirst to deliver\n // fetchMore cache results back to this ObservableQuery.\n this.queryManager.cache.batch({\n update: (cache) => {\n const { updateQuery } = fetchMoreOptions;\n if (updateQuery) {\n cache.updateQuery(\n {\n query: this.query,\n variables: this.variables,\n returnPartialData: true,\n optimistic: false,\n },\n (previous) =>\n updateQuery(previous!, {\n fetchMoreResult: fetchMoreResult.data,\n variables: combinedOptions.variables as TFetchVars,\n })\n );\n } else {\n // If we're using a field policy instead of updateQuery, the only\n // thing we need to do is write the new data to the cache using\n // combinedOptions.variables (instead of this.variables, which is\n // what this.updateQuery uses, because it works by abusing the\n // original field value, keyed by the original variables).\n cache.writeQuery({\n query: combinedOptions.query,\n variables: combinedOptions.variables,\n data: fetchMoreResult.data,\n });\n }\n },\n\n onWatchUpdated: (watch) => {\n // Record the DocumentNode associated with any watched query whose\n // data were updated by the cache writes above.\n updatedQuerySet.add(watch.query);\n },\n });\n\n return fetchMoreResult;\n })\n .finally(() => {\n // In case the cache writes above did not generate a broadcast\n // notification (which would have been intercepted by onWatchUpdated),\n // likely because the written data were the same as what was already in\n // the cache, we still want fetchMore to deliver its final loading:false\n // result with the unchanged data.\n if (!updatedQuerySet.has(this.query)) {\n reobserveCacheFirst(this);\n }\n });\n }\n\n // XXX the subscription variables are separate from the query variables.\n // if you want to update subscription variables, right now you have to do that separately,\n // and you can only do it by stopping the subscription and then subscribing again with new variables.\n public subscribeToMore<\n TSubscriptionData = TData,\n TSubscriptionVariables extends OperationVariables = TVariables,\n >(\n options: SubscribeToMoreOptions<\n TData,\n TSubscriptionVariables,\n TSubscriptionData\n >\n ) {\n const subscription = this.queryManager\n .startGraphQLSubscription({\n query: options.document,\n variables: options.variables,\n context: options.context,\n })\n .subscribe({\n next: (subscriptionData: { data: TSubscriptionData }) => {\n const { updateQuery } = options;\n if (updateQuery) {\n this.updateQuery<TSubscriptionVariables>(\n (previous, { variables }) =>\n updateQuery(previous, {\n subscriptionData,\n variables,\n })\n );\n }\n },\n error: (err: any) => {\n if (options.onError) {\n options.onError(err);\n return;\n }\n invariant.error(\"Unhandled GraphQL subscription error\", err);\n },\n });\n\n this.subscriptions.add(subscription);\n\n return () => {\n if (this.subscriptions.delete(subscription)) {\n subscription.unsubscribe();\n }\n };\n }\n\n public setOptions(\n newOptions: Partial<WatchQueryOptions<TVariables, TData>>\n ): Promise<ApolloQueryResult<TData>> {\n return this.reobserve(newOptions);\n }\n\n public silentSetOptions(\n newOptions: Partial<WatchQueryOptions<TVariables, TData>>\n ) {\n const mergedOptions = compact(this.options, newOptions || {});\n assign(this.options, mergedOptions);\n }\n\n /**\n * Update the variables of this observable query, and fetch the new results\n * if they've changed. Most users should prefer `refetch` instead of\n * `setVariables` in order to to be properly notified of results even when\n * they come from the cache.\n *\n * Note: the `next` callback will *not* fire if the variables have not changed\n * or if the result is coming from cache.\n *\n * Note: the promise will return the old results immediately if the variables\n * have not changed.\n *\n * Note: the promise will return null immediately if the query is not active\n * (there are no subscribers).\n *\n * @private\n *\n * @param variables: The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public setVariables(\n variables: TVariables\n ): Promise<ApolloQueryResult<TData> | void> {\n if (equal(this.variables, variables)) {\n // If we have no observers, then we don't actually want to make a network\n // request. As soon as someone observes the query, the request will kick\n // off. For now, we just store any changes. (See #1077)\n return this.observers.size ? this.result() : Promise.resolve();\n }\n\n this.options.variables = variables;\n\n // See comment above\n if (!this.observers.size) {\n return Promise.resolve();\n }\n\n return this.reobserve(\n {\n // Reset options.fetchPolicy to its original value.\n fetchPolicy: this.options.initialFetchPolicy,\n variables,\n },\n NetworkStatus.setVariables\n );\n }\n\n public updateQuery<TVars extends OperationVariables = TVariables>(\n mapFn: (\n previousQueryResult: TData,\n options: Pick<WatchQueryOptions<TVars, TData>, \"variables\">\n ) => TData\n ): void {\n const { queryManager } = this;\n const { result } = queryManager.cache.diff<TData>({\n query: this.options.query,\n variables: this.variables,\n returnPartialData: true,\n optimistic: false,\n });\n\n const newResult = mapFn(result!, {\n variables: (this as any).variables,\n });\n\n if (newResult) {\n queryManager.cache.writeQuery({\n query: this.options.query,\n data: newResult,\n variables: this.variables,\n });\n\n queryManager.broadcastQueries();\n }\n }\n\n public startPolling(pollInterval: number) {\n this.options.pollInterval = pollInterval;\n this.updatePolling();\n }\n\n public stopPolling() {\n this.options.pollInterval = 0;\n this.updatePolling();\n }\n\n // Update options.fetchPolicy according to options.nextFetchPolicy.\n private applyNextFetchPolicy(\n reason: NextFetchPolicyContext<TData, TVariables>[\"reason\"],\n // It's possible to use this method to apply options.nextFetchPolicy to\n // options.fetchPolicy even if options !== this.options, though that happens\n // most often when the options are temporary, used for only one request and\n // then thrown away, so nextFetchPolicy may not end up mattering.\n options: WatchQueryOptions<TVariables, TData>\n ) {\n if (options.nextFetchPolicy) {\n const { fetchPolicy = \"cache-first\", initialFetchPolicy = fetchPolicy } =\n options;\n\n if (fetchPolicy === \"standby\") {\n // Do nothing, leaving options.fetchPolicy unchanged.\n } else if (typeof options.nextFetchPolicy === \"function\") {\n // When someone chooses \"cache-and-network\" or \"network-only\" as their\n // initial FetchPolicy, they often do not want future cache updates to\n // trigger unconditional network requests, which is what repeatedly\n // applying the \"cache-and-network\" or \"network-only\" policies would\n // seem to imply. Instead, when the cache reports an update after the\n // initial network request, it may be desirable for subsequent network\n // requests to be triggered only if the cache result is incomplete. To\n // that end, the options.nextFetchPolicy option provides an easy way to\n // update options.fetchPolicy after the initial network request, without\n // having to call observableQuery.setOptions.\n options.fetchPolicy = options.nextFetchPolicy(fetchPolicy, {\n reason,\n options,\n observable: this,\n initialFetchPolicy,\n });\n } else if (reason === \"variables-changed\") {\n options.fetchPolicy = initialFetchPolicy;\n } else {\n options.fetchPolicy = options.nextFetchPolicy;\n }\n }\n\n return options.fetchPolicy;\n }\n\n private fetch(\n options: WatchQueryOptions<TVariables, TData>,\n newNetworkStatus?: NetworkStatus,\n query?: DocumentNode\n ) {\n // TODO Make sure we update the networkStatus (and infer fetchVariables)\n // before actually committing to the fetch.\n this.queryManager.setObservableQuery(this);\n return this.queryManager[\"fetchConcastWithInfo\"](\n this.queryId,\n options,\n newNetworkStatus,\n query\n );\n }\n\n // Turns polling on or off based on this.options.pollInterval.\n private updatePolling() {\n // Avoid polling in SSR mode\n if (this.queryManager.ssrMode) {\n return;\n }\n\n const {\n pollingInfo,\n options: { pollInterval },\n } = this;\n\n if (!pollInterval) {\n if (pollingInfo) {\n clearTimeout(pollingInfo.timeout);\n delete this.pollingInfo;\n }\n return;\n }\n\n if (pollingInfo && pollingInfo.interval === pollInterval) {\n return;\n }\n\n invariant(\n pollInterval,\n \"Attempted to start a polling query without a polling interval.\"\n );\n\n const info = pollingInfo || (this.pollingInfo = {} as any);\n info.interval = pollInterval;\n\n const maybeFetch = () => {\n if (this.pollingInfo) {\n if (!isNetworkRequestInFlight(this.queryInfo.networkStatus)) {\n this.reobserve(\n {\n // Most fetchPolicy options don't make sense to use in a polling context, as\n // users wouldn't want to be polling the cache directly. However, network-only and\n // no-cache are both useful for when the user wants to control whether or not the\n // polled results are written to the cache.\n fetchPolicy:\n this.options.initialFetchPolicy === \"no-cache\"\n ? \"no-cache\"\n : \"network-only\",\n },\n NetworkStatus.poll\n ).then(poll, poll);\n } else {\n poll();\n }\n }\n };\n\n const poll = () => {\n const info = this.pollingInfo;\n if (info) {\n clearTimeout(info.timeout);\n info.timeout = setTimeout(maybeFetch, info.interval);\n }\n };\n\n poll();\n }\n\n private updateLastResult(\n newResult: ApolloQueryResult<TData>,\n variables = this.variables\n ) {\n let error: ApolloError | undefined = this.getLastError();\n // Preserve this.last.error unless the variables have changed.\n if (error && this.last && !equal(variables, this.last.variables)) {\n error = void 0;\n }\n return (this.last = {\n result: this.queryManager.assumeImmutableResults\n ? newResult\n : cloneDeep(newResult),\n variables,\n ...(error ? { error } : null),\n });\n }\n\n public reobserveAsConcast(\n newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,\n newNetworkStatus?: NetworkStatus\n ): Concast<ApolloQueryResult<TData>> {\n this.isTornDown = false;\n\n const useDisposableConcast =\n // Refetching uses a disposable Concast to allow refetches using different\n // options/variables, without permanently altering the options of the\n // original ObservableQuery.\n newNetworkStatus === NetworkStatus.refetch ||\n // The fetchMore method does not actually call the reobserve method, but,\n // if it did, it would definitely use a disposable Concast.\n newNetworkStatus === NetworkStatus.fetchMore ||\n // Polling uses a disposable Concast so the polling options (which force\n // fetchPolicy to be \"network-only\" or \"no-cache\") won't override the original options.\n newNetworkStatus === NetworkStatus.poll;\n\n // Save the old variables, since Object.assign may modify them below.\n const oldVariables = this.options.variables;\n const oldFetchPolicy = this.options.fetchPolicy;\n\n const mergedOptions = compact(this.options, newOptions || {});\n const options = useDisposableConcast\n ? // Disposable Concast fetches receive a shallow copy of this.options\n // (merged with newOptions), leaving this.options unmodified.\n mergedOptions\n : assign(this.options, mergedOptions);\n\n // Don't update options.query with the transformed query to avoid\n // overwriting this.options.query when we aren't using a disposable concast.\n // We want to ensure we can re-run the custom document transforms the next\n // time a request is made against the original query.\n const query = this.transformDocument(options.query);\n\n this.lastQuery = query;\n\n if (!useDisposableConcast) {\n // We can skip calling updatePolling if we're not changing this.options.\n this.updatePolling();\n\n // Reset options.fetchPolicy to its original value when variables change,\n // unless a new fetchPolicy was provided by newOptions.\n if (\n newOptions &&\n newOptions.variables &&\n !equal(newOptions.variables, oldVariables) &&\n // Don't mess with the fetchPolicy if it's currently \"standby\".\n options.fetchPolicy !== \"standby\" &&\n // If we're changing the fetchPolicy anyway, don't try to change it here\n // using applyNextFetchPolicy. The explicit options.fetchPolicy wins.\n options.fetchPolicy === oldFetchPolicy\n ) {\n this.applyNextFetchPolicy(\"variables-changed\", options);\n if (newNetworkStatus === void 0) {\n newNetworkStatus = NetworkStatus.setVariables;\n }\n }\n }\n\n this.waitForOwnResult &&= skipCacheDataFor(options.fetchPolicy);\n const finishWaitingForOwnResult = () => {\n if (this.concast === concast) {\n this.waitForOwnResult = false;\n }\n };\n\n const variables = options.variables && { ...options.variables };\n const { concast, fromLink } = this.fetch(options, newNetworkStatus, query);\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: (result) => {\n finishWaitingForOwnResult();\n this.reportResult(result, variables);\n },\n error: (error) => {\n finishWaitingForOwnResult();\n this.reportError(error, variables);\n },\n };\n\n if (!useDisposableConcast && (fromLink || !this.concast)) {\n // We use the {add,remove}Observer methods directly to avoid wrapping\n // observer with an unnecessary SubscriptionObserver object.\n if (this.concast && this.observer) {\n this.concast.removeObserver(this.observer);\n }\n\n this.concast = concast;\n this.observer = observer;\n }\n\n concast.addObserver(observer);\n\n return concast;\n }\n\n public reobserve(\n newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,\n newNetworkStatus?: NetworkStatus\n ) {\n return this.reobserveAsConcast(newOptions, newNetworkStatus).promise;\n }\n\n public resubscribeAfterError(\n onNext: (value: ApolloQueryResult<TData>) => void,\n onError?: (error: any) => void,\n onComplete?: () => void\n ): ObservableSubscription;\n\n public resubscribeAfterError(\n observer: Observer<ApolloQueryResult<TData>>\n ): ObservableSubscription;\n\n public resubscribeAfterError(...args: [any, any?, any?]) {\n // If `lastError` is set in the current when the subscription is re-created,\n // the subscription will immediately receive the error, which will\n // cause it to terminate again. To avoid this, we first clear\n // the last error/result from the `observableQuery` before re-starting\n // the subscription, and restore the last value afterwards so that the\n // subscription has a chance to stay open.\n const last = this.last;\n this.resetLastResults();\n\n const subscription = this.subscribe(...args);\n this.last = last;\n\n return subscription;\n }\n\n // (Re)deliver the current result to this.observers without applying fetch\n // policies or making network requests.\n private observe() {\n this.reportResult(\n // Passing false is important so that this.getCurrentResult doesn't\n // save the fetchMore result as this.lastResult, causing it to be\n // ignored due to the this.isDifferentFromLastResult check in\n // this.reportResult.\n this.getCurrentResult(false),\n this.variables\n );\n }\n\n private reportResult(\n result: ApolloQueryResult<TData>,\n variables: TVariables | undefined\n ) {\n const lastError = this.getLastError();\n const isDifferent = this.isDifferentFromLastResult(result, variables);\n // Update the last result even when isDifferentFromLastResult returns false,\n // because the query may be using the @nonreactive directive, and we want to\n // save the the latest version of any nonreactive subtrees (in case\n // getCurrentResult is called), even though we skip broadcasting changes.\n if (lastError || !result.partial || this.options.returnPartialData) {\n this.updateLastResult(result, variables);\n }\n if (lastError || isDifferent) {\n iterateObserversSafely(this.observers, \"next\", result);\n }\n }\n\n private reportError(error: ApolloError, variables: TVariables | undefined) {\n // Since we don't get the current result on errors, only the error, we\n // must mirror the updates that occur in QueryStore.markQueryError here\n const errorResult = {\n ...this.getLastResult(),\n error,\n errors: error.graphQLErrors,\n networkStatus: NetworkStatus.error,\n loading: false,\n } as ApolloQueryResult<TData>;\n\n this.updateLastResult(errorResult, variables);\n\n iterateObserversSafely(this.observers, \"error\", (this.last!.error = error));\n }\n\n public hasObservers() {\n return this.observers.size > 0;\n }\n\n private tearDownQuery() {\n if (this.isTornDown) return;\n if (this.concast && this.observer) {\n this.concast.removeObserver(this.observer);\n delete this.concast;\n delete this.observer;\n }\n\n this.stopPolling();\n // stop all active GraphQL subscriptions\n this.subscriptions.forEach((sub) => sub.unsubscribe());\n this.subscriptions.clear();\n this.queryManager.stopQuery(this.queryId);\n this.observers.clear();\n this.isTornDown = true;\n }\n\n private transformDocument(document: DocumentNode) {\n return this.queryManager.transform(document);\n }\n}\n\n// Necessary because the ObservableQuery constructor has a different\n// signature than the Observable constructor.\nfixObservableSubclass(ObservableQuery);\n\n// Reobserve with fetchPolicy effectively set to \"cache-first\", triggering\n// delivery of any new data from the cache, possibly falling back to the network\n// if any cache data are missing. This allows _complete_ cache results to be\n// delivered without also kicking off unnecessary network requests when\n// this.options.fetchPolicy is \"cache-and-network\" or \"network-only\". When\n// this.options.fetchPolicy is any other policy (\"cache-first\", \"cache-only\",\n// \"standby\", or \"no-cache\"), we call this.reobserve() as usual.\nexport function reobserveCacheFirst<TData, TVars extends OperationVariables>(\n obsQuery: ObservableQuery<TData, TVars>\n) {\n const { fetchPolicy, nextFetchPolicy } = obsQuery.options;\n\n if (fetchPolicy === \"cache-and-network\" || fetchPolicy === \"network-only\") {\n return obsQuery.reobserve({\n fetchPolicy: \"cache-first\",\n // Use a temporary nextFetchPolicy function that replaces itself with the\n // previous nextFetchPolicy value and returns the original fetchPolicy.\n nextFetchPolicy(this: WatchQueryOptions<TVars, TData>) {\n // Replace this nextFetchPolicy function in the options object with the\n // original this.options.nextFetchPolicy value.\n this.nextFetchPolicy = nextFetchPolicy;\n // If the original nextFetchPolicy value was a function, give it a\n // chance to decide what happens here.\n if (typeof nextFetchPolicy === \"function\") {\n return nextFetchPolicy.apply(this, arguments);\n }\n // Otherwise go back to the original this.options.fetchPolicy.\n return fetchPolicy!;\n },\n });\n }\n\n return obsQuery.reobserve();\n}\n\nfunction defaultSubscriptionObserverErrorCallback(error: ApolloError) {\n invariant.error(\"Unhandled error\", error.message, error.stack);\n}\n\nexport function logMissingFieldErrors(\n missing: MissingFieldError[] | MissingTree | undefined\n) {\n if (__DEV__ && missing) {\n invariant.debug(`Missing cache result fields: %o`, missing);\n }\n}\n\nfunction skipCacheDataFor(\n fetchPolicy?: WatchQueryFetchPolicy /* `undefined` would mean `\"cache-first\"` */\n) {\n return (\n fetchPolicy === \"network-only\" ||\n fetchPolicy === \"no-cache\" ||\n fetchPolicy === \"standby\"\n );\n}\n"]}
1
+ {"version":3,"file":"ObservableQuery.js","sourceRoot":"","sources":["../../src/core/ObservableQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAM7E,OAAO,EACL,SAAS,EACT,OAAO,EACP,sBAAsB,EACtB,UAAU,EACV,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAkB/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGzC,IAAA,MAAM,GAAqB,MAAM,OAA3B,EAAE,cAAc,GAAK,MAAM,eAAX,CAAY;AAyB1C;IAGU,mCAAoC;IAwC5C,yBAAY,EAQX;YAPC,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,OAAO,aAAA;QAMP,YAAA,MAAK,YAAC,UAAC,QAA4C;YACjD,0EAA0E;YAC1E,8CAA8C;YAC9C,IAAI,CAAC;gBACH,IAAI,WAAW,GAAI,QAAgB,CAAC,aAAa,CAAC,SAAS,CAAC;gBAC5D,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;oBACtC,WAAW,CA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IAAI,WAAW,KAAK,cAAc,EAAE,CAAC;QAC1E,OAAO,QAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,aAAa;YAC1B,yEAAyE;YACzE,uEAAuE;YACvE,eAAe,YAEb,kBAAyC,EACzC,OAA6C;gBAE7C,uEAAuE;gBACvE,+CAA+C;gBAC/C,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;gBACvC,kEAAkE;gBAClE,sCAAsC;gBACtC,IAAI,OAAO,IAAI,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;oBAC/C,OAAO,IAAI,CAAC,eAAe,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;gBAC3D,CAAC;gBACD,8DAA8D;gBAC9D,OAAO,WAAY,CAAC;YACtB,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC,SAAS,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,wCAAwC,CAAC,KAAkB;IAClE,SAAS,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,OAAsD;IAEtD,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;QACvB,SAAS,CAAC,KAAK,CAAC,iCAAiC,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CACvB,WAAmC,CAAC,4CAA4C;IAEhF,OAAO,CACL,WAAW,KAAK,cAAc;QAC9B,WAAW,KAAK,UAAU;QAC1B,WAAW,KAAK,SAAS,CAC1B,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from \"../utilities/globals/index.js\";\nimport type { DocumentNode } from \"graphql\";\nimport { equal } from \"@wry/equality\";\n\nimport { NetworkStatus, isNetworkRequestInFlight } from \"./networkStatus.js\";\nimport type {\n Concast,\n Observer,\n ObservableSubscription,\n} from \"../utilities/index.js\";\nimport {\n cloneDeep,\n compact,\n getOperationDefinition,\n Observable,\n iterateObserversSafely,\n fixObservableSubclass,\n getQueryDefinition,\n} from \"../utilities/index.js\";\nimport type { ApolloError } from \"../errors/index.js\";\nimport type { QueryManager } from \"./QueryManager.js\";\nimport type {\n ApolloQueryResult,\n OperationVariables,\n TypedDocumentNode,\n} from \"./types.js\";\nimport type {\n WatchQueryOptions,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n NextFetchPolicyContext,\n WatchQueryFetchPolicy,\n} from \"./watchQueryOptions.js\";\nimport type { QueryInfo } from \"./QueryInfo.js\";\nimport type { MissingFieldError } from \"../cache/index.js\";\nimport type { MissingTree } from \"../cache/core/types/common.js\";\nimport { equalByQuery } from \"./equalByQuery.js\";\nimport type { TODO } from \"../utilities/types/TODO.js\";\n\nconst { assign, hasOwnProperty } = Object;\n\nexport interface FetchMoreOptions<\n TData = any,\n TVariables = OperationVariables,\n> {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult?: TData;\n variables?: TVariables;\n }\n ) => TData;\n}\n\nexport interface UpdateQueryOptions<TVariables> {\n variables?: TVariables;\n}\n\ninterface Last<TData, TVariables> {\n result: ApolloQueryResult<TData>;\n variables?: TVariables;\n error?: ApolloError;\n}\n\nexport class ObservableQuery<\n TData = any,\n TVariables extends OperationVariables = OperationVariables,\n> extends Observable<ApolloQueryResult<TData>> {\n public readonly options: WatchQueryOptions<TVariables, TData>;\n public readonly queryId: string;\n public readonly queryName?: string;\n\n // The `query` computed property will always reflect the document transformed\n // by the last run query. `this.options.query` will always reflect the raw\n // untransformed query to ensure document transforms with runtime conditionals\n // are run on the original document.\n public get query(): TypedDocumentNode<TData, TVariables> {\n return this.lastQuery || this.options.query;\n }\n\n // Computed shorthand for this.options.variables, preserved for\n // backwards compatibility.\n public get variables(): TVariables | undefined {\n return this.options.variables;\n }\n\n private isTornDown: boolean;\n private queryManager: QueryManager<any>;\n private observers = new Set<Observer<ApolloQueryResult<TData>>>();\n private subscriptions = new Set<ObservableSubscription>();\n\n private waitForOwnResult: boolean;\n private last?: Last<TData, TVariables>;\n private lastQuery?: DocumentNode;\n\n private queryInfo: QueryInfo;\n\n // When this.concast is defined, this.observer is the Observer currently\n // subscribed to that Concast.\n private concast?: Concast<ApolloQueryResult<TData>>;\n private observer?: Observer<ApolloQueryResult<TData>>;\n\n private pollingInfo?: {\n interval: number;\n timeout: ReturnType<typeof setTimeout>;\n };\n\n constructor({\n queryManager,\n queryInfo,\n options,\n }: {\n queryManager: QueryManager<any>;\n queryInfo: QueryInfo;\n options: WatchQueryOptions<TVariables, TData>;\n }) {\n super((observer: Observer<ApolloQueryResult<TData>>) => {\n // Zen Observable has its own error function, so in order to log correctly\n // we need to provide a custom error callback.\n try {\n var subObserver = (observer as any)._subscription._observer;\n if (subObserver && !subObserver.error) {\n subObserver.error = defaultSubscriptionObserverErrorCallback;\n }\n } catch {}\n\n const first = !this.observers.size;\n this.observers.add(observer);\n\n // Deliver most recent error or result.\n const last = this.last;\n if (last && last.error) {\n observer.error && observer.error(last.error);\n } else if (last && last.result) {\n observer.next && observer.next(last.result);\n }\n\n // Initiate observation of this query if it hasn't been reported to\n // the QueryManager yet.\n if (first) {\n // Blindly catching here prevents unhandled promise rejections,\n // and is safe because the ObservableQuery handles this error with\n // this.observer.error, so we're not just swallowing the error by\n // ignoring it here.\n this.reobserve().catch(() => {});\n }\n\n return () => {\n if (this.observers.delete(observer) && !this.observers.size) {\n this.tearDownQuery();\n }\n };\n });\n\n // related classes\n this.queryInfo = queryInfo;\n this.queryManager = queryManager;\n\n // active state\n this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy);\n this.isTornDown = false;\n\n const {\n watchQuery: { fetchPolicy: defaultFetchPolicy = \"cache-first\" } = {},\n } = queryManager.defaultOptions;\n\n const {\n fetchPolicy = defaultFetchPolicy,\n // Make sure we don't store \"standby\" as the initialFetchPolicy.\n initialFetchPolicy = fetchPolicy === \"standby\" ? defaultFetchPolicy : (\n fetchPolicy\n ),\n } = options;\n\n this.options = {\n ...options,\n\n // Remember the initial options.fetchPolicy so we can revert back to this\n // policy when variables change. This information can also be specified\n // (or overridden) by providing options.initialFetchPolicy explicitly.\n initialFetchPolicy,\n\n // This ensures this.options.fetchPolicy always has a string value, in\n // case options.fetchPolicy was not provided.\n fetchPolicy,\n };\n\n this.queryId = queryInfo.queryId || queryManager.generateQueryId();\n\n const opDef = getOperationDefinition(this.query);\n this.queryName = opDef && opDef.name && opDef.name.value;\n }\n\n public result(): Promise<ApolloQueryResult<TData>> {\n return new Promise((resolve, reject) => {\n // TODO: this code doesn’t actually make sense insofar as the observer\n // will never exist in this.observers due how zen-observable wraps observables.\n // https://github.com/zenparsing/zen-observable/blob/master/src/Observable.js#L169\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: (result: ApolloQueryResult<TData>) => {\n resolve(result);\n\n // Stop the query within the QueryManager if we can before\n // this function returns.\n //\n // We do this in order to prevent observers piling up within\n // the QueryManager. Notice that we only fully unsubscribe\n // from the subscription in a setTimeout(..., 0) call. This call can\n // actually be handled by the browser at a much later time. If queries\n // are fired in the meantime, observers that should have been removed\n // from the QueryManager will continue to fire, causing an unnecessary\n // performance hit.\n this.observers.delete(observer);\n if (!this.observers.size) {\n this.queryManager.removeQuery(this.queryId);\n }\n\n setTimeout(() => {\n subscription.unsubscribe();\n }, 0);\n },\n error: reject,\n };\n const subscription = this.subscribe(observer);\n });\n }\n\n /** @internal */\n public resetDiff() {\n this.queryInfo.resetDiff();\n }\n\n public getCurrentResult(saveAsLastResult = true): ApolloQueryResult<TData> {\n // Use the last result as long as the variables match this.variables.\n const lastResult = this.getLastResult(true);\n\n const networkStatus =\n this.queryInfo.networkStatus ||\n (lastResult && lastResult.networkStatus) ||\n NetworkStatus.ready;\n\n const result = {\n ...lastResult,\n loading: isNetworkRequestInFlight(networkStatus),\n networkStatus,\n } as ApolloQueryResult<TData>;\n\n const { fetchPolicy = \"cache-first\" } = this.options;\n if (\n // These fetch policies should never deliver data from the cache, unless\n // redelivering a previously delivered result.\n skipCacheDataFor(fetchPolicy) ||\n // If this.options.query has @client(always: true) fields, we cannot\n // trust diff.result, since it was read from the cache without running\n // local resolvers (and it's too late to run resolvers now, since we must\n // return a result synchronously).\n this.queryManager.getDocumentInfo(this.query).hasForcedResolvers\n ) {\n // Fall through.\n } else if (this.waitForOwnResult) {\n // This would usually be a part of `QueryInfo.getDiff()`.\n // which we skip in the waitForOwnResult case since we are not\n // interested in the diff.\n this.queryInfo[\"updateWatch\"]();\n } else {\n const diff = this.queryInfo.getDiff();\n\n if (diff.complete || this.options.returnPartialData) {\n result.data = diff.result;\n }\n\n if (equal(result.data, {})) {\n result.data = void 0 as any;\n }\n\n if (diff.complete) {\n // Similar to setting result.partial to false, but taking advantage of the\n // falsiness of missing fields.\n delete result.partial;\n\n // If the diff is complete, and we're using a FetchPolicy that\n // terminates after a complete cache read, we can assume the next result\n // we receive will have NetworkStatus.ready and !loading.\n if (\n diff.complete &&\n result.networkStatus === NetworkStatus.loading &&\n (fetchPolicy === \"cache-first\" || fetchPolicy === \"cache-only\")\n ) {\n result.networkStatus = NetworkStatus.ready;\n result.loading = false;\n }\n } else {\n result.partial = true;\n }\n\n if (\n __DEV__ &&\n !diff.complete &&\n !this.options.partialRefetch &&\n !result.loading &&\n !result.data &&\n !result.error\n ) {\n logMissingFieldErrors(diff.missing);\n }\n }\n\n if (saveAsLastResult) {\n this.updateLastResult(result);\n }\n\n return result;\n }\n\n // Compares newResult to the snapshot we took of this.lastResult when it was\n // first received.\n public isDifferentFromLastResult(\n newResult: ApolloQueryResult<TData>,\n variables?: TVariables\n ) {\n if (!this.last) {\n return true;\n }\n\n const resultIsDifferent =\n this.queryManager.getDocumentInfo(this.query).hasNonreactiveDirective ?\n !equalByQuery(this.query, this.last.result, newResult, this.variables)\n : !equal(this.last.result, newResult);\n\n return (\n resultIsDifferent || (variables && !equal(this.last.variables, variables))\n );\n }\n\n private getLast<K extends keyof Last<TData, TVariables>>(\n key: K,\n variablesMustMatch?: boolean\n ) {\n const last = this.last;\n if (\n last &&\n last[key] &&\n (!variablesMustMatch || equal(last.variables, this.variables))\n ) {\n return last[key];\n }\n }\n\n public getLastResult(\n variablesMustMatch?: boolean\n ): ApolloQueryResult<TData> | undefined {\n return this.getLast(\"result\", variablesMustMatch);\n }\n\n public getLastError(variablesMustMatch?: boolean): ApolloError | undefined {\n return this.getLast(\"error\", variablesMustMatch);\n }\n\n public resetLastResults(): void {\n delete this.last;\n this.isTornDown = false;\n }\n\n public resetQueryStoreErrors() {\n this.queryManager.resetErrors(this.queryId);\n }\n\n /**\n * Update the variables of this observable query, and fetch the new results.\n * This method should be preferred over `setVariables` in most use cases.\n *\n * @param variables - The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public refetch(\n variables?: Partial<TVariables>\n ): Promise<ApolloQueryResult<TData>> {\n const reobserveOptions: Partial<WatchQueryOptions<TVariables, TData>> = {\n // Always disable polling for refetches.\n pollInterval: 0,\n };\n\n // Unless the provided fetchPolicy always consults the network\n // (no-cache, network-only, or cache-and-network), override it with\n // network-only to force the refetch for this fetchQuery call.\n const { fetchPolicy } = this.options;\n if (fetchPolicy === \"cache-and-network\") {\n reobserveOptions.fetchPolicy = fetchPolicy;\n } else if (fetchPolicy === \"no-cache\") {\n reobserveOptions.fetchPolicy = \"no-cache\";\n } else {\n reobserveOptions.fetchPolicy = \"network-only\";\n }\n\n if (__DEV__ && variables && hasOwnProperty.call(variables, \"variables\")) {\n const queryDef = getQueryDefinition(this.query);\n const vars = queryDef.variableDefinitions;\n if (!vars || !vars.some((v) => v.variable.name.value === \"variables\")) {\n invariant.warn(\n `Called refetch(%o) for query %o, which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?`,\n variables,\n queryDef.name?.value || queryDef\n );\n }\n }\n\n if (variables && !equal(this.options.variables, variables)) {\n // Update the existing options with new variables\n reobserveOptions.variables = this.options.variables = {\n ...this.options.variables,\n ...variables,\n } as TVariables;\n }\n\n this.queryInfo.resetLastWrite();\n return this.reobserve(reobserveOptions, NetworkStatus.refetch);\n }\n\n public fetchMore<\n TFetchData = TData,\n TFetchVars extends OperationVariables = TVariables,\n >(\n fetchMoreOptions: FetchMoreQueryOptions<TFetchVars, TFetchData> & {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult: TFetchData;\n variables: TFetchVars;\n }\n ) => TData;\n }\n ): Promise<ApolloQueryResult<TFetchData>> {\n const combinedOptions = {\n ...(fetchMoreOptions.query ? fetchMoreOptions : (\n {\n ...this.options,\n query: this.options.query,\n ...fetchMoreOptions,\n variables: {\n ...this.options.variables,\n ...fetchMoreOptions.variables,\n },\n }\n )),\n // The fetchMore request goes immediately to the network and does\n // not automatically write its result to the cache (hence no-cache\n // instead of network-only), because we allow the caller of\n // fetchMore to provide an updateQuery callback that determines how\n // the data gets written to the cache.\n fetchPolicy: \"no-cache\",\n } as WatchQueryOptions<TFetchVars, TFetchData>;\n\n combinedOptions.query = this.transformDocument(combinedOptions.query);\n\n const qid = this.queryManager.generateQueryId();\n\n // If a temporary query is passed to `fetchMore`, we don't want to store\n // it as the last query result since it may be an optimized query for\n // pagination. We will however run the transforms on the original document\n // as well as the document passed in `fetchMoreOptions` to ensure the cache\n // uses the most up-to-date document which may rely on runtime conditionals.\n this.lastQuery =\n fetchMoreOptions.query ?\n this.transformDocument(this.options.query)\n : combinedOptions.query;\n\n // Simulate a loading result for the original query with\n // result.networkStatus === NetworkStatus.fetchMore.\n const { queryInfo } = this;\n const originalNetworkStatus = queryInfo.networkStatus;\n queryInfo.networkStatus = NetworkStatus.fetchMore;\n if (combinedOptions.notifyOnNetworkStatusChange) {\n this.observe();\n }\n\n const updatedQuerySet = new Set<DocumentNode>();\n\n return this.queryManager\n .fetchQuery(qid, combinedOptions, NetworkStatus.fetchMore)\n .then((fetchMoreResult) => {\n this.queryManager.removeQuery(qid);\n\n if (queryInfo.networkStatus === NetworkStatus.fetchMore) {\n queryInfo.networkStatus = originalNetworkStatus;\n }\n\n // Performing this cache update inside a cache.batch transaction ensures\n // any affected cache.watch watchers are notified at most once about any\n // updates. Most watchers will be using the QueryInfo class, which\n // responds to notifications by calling reobserveCacheFirst to deliver\n // fetchMore cache results back to this ObservableQuery.\n this.queryManager.cache.batch({\n update: (cache) => {\n const { updateQuery } = fetchMoreOptions;\n if (updateQuery) {\n cache.updateQuery(\n {\n query: this.query,\n variables: this.variables,\n returnPartialData: true,\n optimistic: false,\n },\n (previous) =>\n updateQuery(previous!, {\n fetchMoreResult: fetchMoreResult.data,\n variables: combinedOptions.variables as TFetchVars,\n })\n );\n } else {\n // If we're using a field policy instead of updateQuery, the only\n // thing we need to do is write the new data to the cache using\n // combinedOptions.variables (instead of this.variables, which is\n // what this.updateQuery uses, because it works by abusing the\n // original field value, keyed by the original variables).\n cache.writeQuery({\n query: combinedOptions.query,\n variables: combinedOptions.variables,\n data: fetchMoreResult.data,\n });\n }\n },\n\n onWatchUpdated: (watch) => {\n // Record the DocumentNode associated with any watched query whose\n // data were updated by the cache writes above.\n updatedQuerySet.add(watch.query);\n },\n });\n\n return fetchMoreResult;\n })\n .finally(() => {\n // In case the cache writes above did not generate a broadcast\n // notification (which would have been intercepted by onWatchUpdated),\n // likely because the written data were the same as what was already in\n // the cache, we still want fetchMore to deliver its final loading:false\n // result with the unchanged data.\n if (!updatedQuerySet.has(this.query)) {\n reobserveCacheFirst(this);\n }\n });\n }\n\n // XXX the subscription variables are separate from the query variables.\n // if you want to update subscription variables, right now you have to do that separately,\n // and you can only do it by stopping the subscription and then subscribing again with new variables.\n public subscribeToMore<\n TSubscriptionData = TData,\n TSubscriptionVariables extends OperationVariables = TVariables,\n >(\n options: SubscribeToMoreOptions<\n TData,\n TSubscriptionVariables,\n TSubscriptionData\n >\n ) {\n const subscription = this.queryManager\n .startGraphQLSubscription({\n query: options.document,\n variables: options.variables,\n context: options.context,\n })\n .subscribe({\n next: (subscriptionData: { data: TSubscriptionData }) => {\n const { updateQuery } = options;\n if (updateQuery) {\n this.updateQuery<TSubscriptionVariables>(\n (previous, { variables }) =>\n updateQuery(previous, {\n subscriptionData,\n variables,\n })\n );\n }\n },\n error: (err: any) => {\n if (options.onError) {\n options.onError(err);\n return;\n }\n invariant.error(\"Unhandled GraphQL subscription error\", err);\n },\n });\n\n this.subscriptions.add(subscription);\n\n return () => {\n if (this.subscriptions.delete(subscription)) {\n subscription.unsubscribe();\n }\n };\n }\n\n public setOptions(\n newOptions: Partial<WatchQueryOptions<TVariables, TData>>\n ): Promise<ApolloQueryResult<TData>> {\n return this.reobserve(newOptions);\n }\n\n public silentSetOptions(\n newOptions: Partial<WatchQueryOptions<TVariables, TData>>\n ) {\n const mergedOptions = compact(this.options, newOptions || {});\n assign(this.options, mergedOptions);\n }\n\n /**\n * Update the variables of this observable query, and fetch the new results\n * if they've changed. Most users should prefer `refetch` instead of\n * `setVariables` in order to to be properly notified of results even when\n * they come from the cache.\n *\n * Note: the `next` callback will *not* fire if the variables have not changed\n * or if the result is coming from cache.\n *\n * Note: the promise will return the old results immediately if the variables\n * have not changed.\n *\n * Note: the promise will return null immediately if the query is not active\n * (there are no subscribers).\n *\n * @param variables - The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public setVariables(\n variables: TVariables\n ): Promise<ApolloQueryResult<TData> | void> {\n if (equal(this.variables, variables)) {\n // If we have no observers, then we don't actually want to make a network\n // request. As soon as someone observes the query, the request will kick\n // off. For now, we just store any changes. (See #1077)\n return this.observers.size ? this.result() : Promise.resolve();\n }\n\n this.options.variables = variables;\n\n // See comment above\n if (!this.observers.size) {\n return Promise.resolve();\n }\n\n return this.reobserve(\n {\n // Reset options.fetchPolicy to its original value.\n fetchPolicy: this.options.initialFetchPolicy,\n variables,\n },\n NetworkStatus.setVariables\n );\n }\n\n public updateQuery<TVars extends OperationVariables = TVariables>(\n mapFn: (\n previousQueryResult: TData,\n options: Pick<WatchQueryOptions<TVars, TData>, \"variables\">\n ) => TData\n ): void {\n const { queryManager } = this;\n const { result } = queryManager.cache.diff<TData>({\n query: this.options.query,\n variables: this.variables,\n returnPartialData: true,\n optimistic: false,\n });\n\n const newResult = mapFn(result!, {\n variables: (this as any).variables,\n });\n\n if (newResult) {\n queryManager.cache.writeQuery({\n query: this.options.query,\n data: newResult,\n variables: this.variables,\n });\n\n queryManager.broadcastQueries();\n }\n }\n\n public startPolling(pollInterval: number) {\n this.options.pollInterval = pollInterval;\n this.updatePolling();\n }\n\n public stopPolling() {\n this.options.pollInterval = 0;\n this.updatePolling();\n }\n\n // Update options.fetchPolicy according to options.nextFetchPolicy.\n private applyNextFetchPolicy(\n reason: NextFetchPolicyContext<TData, TVariables>[\"reason\"],\n // It's possible to use this method to apply options.nextFetchPolicy to\n // options.fetchPolicy even if options !== this.options, though that happens\n // most often when the options are temporary, used for only one request and\n // then thrown away, so nextFetchPolicy may not end up mattering.\n options: WatchQueryOptions<TVariables, TData>\n ) {\n if (options.nextFetchPolicy) {\n const { fetchPolicy = \"cache-first\", initialFetchPolicy = fetchPolicy } =\n options;\n\n if (fetchPolicy === \"standby\") {\n // Do nothing, leaving options.fetchPolicy unchanged.\n } else if (typeof options.nextFetchPolicy === \"function\") {\n // When someone chooses \"cache-and-network\" or \"network-only\" as their\n // initial FetchPolicy, they often do not want future cache updates to\n // trigger unconditional network requests, which is what repeatedly\n // applying the \"cache-and-network\" or \"network-only\" policies would\n // seem to imply. Instead, when the cache reports an update after the\n // initial network request, it may be desirable for subsequent network\n // requests to be triggered only if the cache result is incomplete. To\n // that end, the options.nextFetchPolicy option provides an easy way to\n // update options.fetchPolicy after the initial network request, without\n // having to call observableQuery.setOptions.\n options.fetchPolicy = options.nextFetchPolicy(fetchPolicy, {\n reason,\n options,\n observable: this,\n initialFetchPolicy,\n });\n } else if (reason === \"variables-changed\") {\n options.fetchPolicy = initialFetchPolicy;\n } else {\n options.fetchPolicy = options.nextFetchPolicy;\n }\n }\n\n return options.fetchPolicy;\n }\n\n private fetch(\n options: WatchQueryOptions<TVariables, TData>,\n newNetworkStatus?: NetworkStatus,\n query?: DocumentNode\n ) {\n // TODO Make sure we update the networkStatus (and infer fetchVariables)\n // before actually committing to the fetch.\n this.queryManager.setObservableQuery(this);\n return this.queryManager[\"fetchConcastWithInfo\"](\n this.queryId,\n options,\n newNetworkStatus,\n query\n );\n }\n\n // Turns polling on or off based on this.options.pollInterval.\n private updatePolling() {\n // Avoid polling in SSR mode\n if (this.queryManager.ssrMode) {\n return;\n }\n\n const {\n pollingInfo,\n options: { pollInterval },\n } = this;\n\n if (!pollInterval) {\n if (pollingInfo) {\n clearTimeout(pollingInfo.timeout);\n delete this.pollingInfo;\n }\n return;\n }\n\n if (pollingInfo && pollingInfo.interval === pollInterval) {\n return;\n }\n\n invariant(\n pollInterval,\n \"Attempted to start a polling query without a polling interval.\"\n );\n\n const info = pollingInfo || (this.pollingInfo = {} as any);\n info.interval = pollInterval;\n\n const maybeFetch = () => {\n if (this.pollingInfo) {\n if (\n !isNetworkRequestInFlight(this.queryInfo.networkStatus) &&\n !this.options.skipPollAttempt?.()\n ) {\n this.reobserve(\n {\n // Most fetchPolicy options don't make sense to use in a polling context, as\n // users wouldn't want to be polling the cache directly. However, network-only and\n // no-cache are both useful for when the user wants to control whether or not the\n // polled results are written to the cache.\n fetchPolicy:\n this.options.initialFetchPolicy === \"no-cache\" ?\n \"no-cache\"\n : \"network-only\",\n },\n NetworkStatus.poll\n ).then(poll, poll);\n } else {\n poll();\n }\n }\n };\n\n const poll = () => {\n const info = this.pollingInfo;\n if (info) {\n clearTimeout(info.timeout);\n info.timeout = setTimeout(maybeFetch, info.interval);\n }\n };\n\n poll();\n }\n\n private updateLastResult(\n newResult: ApolloQueryResult<TData>,\n variables = this.variables\n ) {\n let error: ApolloError | undefined = this.getLastError();\n // Preserve this.last.error unless the variables have changed.\n if (error && this.last && !equal(variables, this.last.variables)) {\n error = void 0;\n }\n return (this.last = {\n result:\n this.queryManager.assumeImmutableResults ?\n newResult\n : cloneDeep(newResult),\n variables,\n ...(error ? { error } : null),\n });\n }\n\n public reobserveAsConcast(\n newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,\n newNetworkStatus?: NetworkStatus\n ): Concast<ApolloQueryResult<TData>> {\n this.isTornDown = false;\n\n const useDisposableConcast =\n // Refetching uses a disposable Concast to allow refetches using different\n // options/variables, without permanently altering the options of the\n // original ObservableQuery.\n newNetworkStatus === NetworkStatus.refetch ||\n // The fetchMore method does not actually call the reobserve method, but,\n // if it did, it would definitely use a disposable Concast.\n newNetworkStatus === NetworkStatus.fetchMore ||\n // Polling uses a disposable Concast so the polling options (which force\n // fetchPolicy to be \"network-only\" or \"no-cache\") won't override the original options.\n newNetworkStatus === NetworkStatus.poll;\n\n // Save the old variables, since Object.assign may modify them below.\n const oldVariables = this.options.variables;\n const oldFetchPolicy = this.options.fetchPolicy;\n\n const mergedOptions = compact(this.options, newOptions || {});\n const options =\n useDisposableConcast ?\n // Disposable Concast fetches receive a shallow copy of this.options\n // (merged with newOptions), leaving this.options unmodified.\n mergedOptions\n : assign(this.options, mergedOptions);\n\n // Don't update options.query with the transformed query to avoid\n // overwriting this.options.query when we aren't using a disposable concast.\n // We want to ensure we can re-run the custom document transforms the next\n // time a request is made against the original query.\n const query = this.transformDocument(options.query);\n\n this.lastQuery = query;\n\n if (!useDisposableConcast) {\n // We can skip calling updatePolling if we're not changing this.options.\n this.updatePolling();\n\n // Reset options.fetchPolicy to its original value when variables change,\n // unless a new fetchPolicy was provided by newOptions.\n if (\n newOptions &&\n newOptions.variables &&\n !equal(newOptions.variables, oldVariables) &&\n // Don't mess with the fetchPolicy if it's currently \"standby\".\n options.fetchPolicy !== \"standby\" &&\n // If we're changing the fetchPolicy anyway, don't try to change it here\n // using applyNextFetchPolicy. The explicit options.fetchPolicy wins.\n options.fetchPolicy === oldFetchPolicy\n ) {\n this.applyNextFetchPolicy(\"variables-changed\", options);\n if (newNetworkStatus === void 0) {\n newNetworkStatus = NetworkStatus.setVariables;\n }\n }\n }\n\n this.waitForOwnResult &&= skipCacheDataFor(options.fetchPolicy);\n const finishWaitingForOwnResult = () => {\n if (this.concast === concast) {\n this.waitForOwnResult = false;\n }\n };\n\n const variables = options.variables && { ...options.variables };\n const { concast, fromLink } = this.fetch(options, newNetworkStatus, query);\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: (result) => {\n finishWaitingForOwnResult();\n this.reportResult(result, variables);\n },\n error: (error) => {\n finishWaitingForOwnResult();\n this.reportError(error, variables);\n },\n };\n\n if (!useDisposableConcast && (fromLink || !this.concast)) {\n // We use the {add,remove}Observer methods directly to avoid wrapping\n // observer with an unnecessary SubscriptionObserver object.\n if (this.concast && this.observer) {\n this.concast.removeObserver(this.observer);\n }\n\n this.concast = concast;\n this.observer = observer;\n }\n\n concast.addObserver(observer);\n\n return concast;\n }\n\n public reobserve(\n newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,\n newNetworkStatus?: NetworkStatus\n ): Promise<ApolloQueryResult<TData>> {\n return this.reobserveAsConcast(newOptions, newNetworkStatus)\n .promise as TODO;\n }\n\n public resubscribeAfterError(\n onNext: (value: ApolloQueryResult<TData>) => void,\n onError?: (error: any) => void,\n onComplete?: () => void\n ): ObservableSubscription;\n\n public resubscribeAfterError(\n observer: Observer<ApolloQueryResult<TData>>\n ): ObservableSubscription;\n\n public resubscribeAfterError(...args: [any, any?, any?]) {\n // If `lastError` is set in the current when the subscription is re-created,\n // the subscription will immediately receive the error, which will\n // cause it to terminate again. To avoid this, we first clear\n // the last error/result from the `observableQuery` before re-starting\n // the subscription, and restore the last value afterwards so that the\n // subscription has a chance to stay open.\n const last = this.last;\n this.resetLastResults();\n\n const subscription = this.subscribe(...args);\n this.last = last;\n\n return subscription;\n }\n\n // (Re)deliver the current result to this.observers without applying fetch\n // policies or making network requests.\n private observe() {\n this.reportResult(\n // Passing false is important so that this.getCurrentResult doesn't\n // save the fetchMore result as this.lastResult, causing it to be\n // ignored due to the this.isDifferentFromLastResult check in\n // this.reportResult.\n this.getCurrentResult(false),\n this.variables\n );\n }\n\n private reportResult(\n result: ApolloQueryResult<TData>,\n variables: TVariables | undefined\n ) {\n const lastError = this.getLastError();\n const isDifferent = this.isDifferentFromLastResult(result, variables);\n // Update the last result even when isDifferentFromLastResult returns false,\n // because the query may be using the @nonreactive directive, and we want to\n // save the the latest version of any nonreactive subtrees (in case\n // getCurrentResult is called), even though we skip broadcasting changes.\n if (lastError || !result.partial || this.options.returnPartialData) {\n this.updateLastResult(result, variables);\n }\n if (lastError || isDifferent) {\n iterateObserversSafely(this.observers, \"next\", result);\n }\n }\n\n private reportError(error: ApolloError, variables: TVariables | undefined) {\n // Since we don't get the current result on errors, only the error, we\n // must mirror the updates that occur in QueryStore.markQueryError here\n const errorResult = {\n ...this.getLastResult(),\n error,\n errors: error.graphQLErrors,\n networkStatus: NetworkStatus.error,\n loading: false,\n } as ApolloQueryResult<TData>;\n\n this.updateLastResult(errorResult, variables);\n\n iterateObserversSafely(this.observers, \"error\", (this.last!.error = error));\n }\n\n public hasObservers() {\n return this.observers.size > 0;\n }\n\n private tearDownQuery() {\n if (this.isTornDown) return;\n if (this.concast && this.observer) {\n this.concast.removeObserver(this.observer);\n delete this.concast;\n delete this.observer;\n }\n\n this.stopPolling();\n // stop all active GraphQL subscriptions\n this.subscriptions.forEach((sub) => sub.unsubscribe());\n this.subscriptions.clear();\n this.queryManager.stopQuery(this.queryId);\n this.observers.clear();\n this.isTornDown = true;\n }\n\n private transformDocument(document: DocumentNode) {\n return this.queryManager.transform(document);\n }\n}\n\n// Necessary because the ObservableQuery constructor has a different\n// signature than the Observable constructor.\nfixObservableSubclass(ObservableQuery);\n\n// Reobserve with fetchPolicy effectively set to \"cache-first\", triggering\n// delivery of any new data from the cache, possibly falling back to the network\n// if any cache data are missing. This allows _complete_ cache results to be\n// delivered without also kicking off unnecessary network requests when\n// this.options.fetchPolicy is \"cache-and-network\" or \"network-only\". When\n// this.options.fetchPolicy is any other policy (\"cache-first\", \"cache-only\",\n// \"standby\", or \"no-cache\"), we call this.reobserve() as usual.\nexport function reobserveCacheFirst<TData, TVars extends OperationVariables>(\n obsQuery: ObservableQuery<TData, TVars>\n) {\n const { fetchPolicy, nextFetchPolicy } = obsQuery.options;\n\n if (fetchPolicy === \"cache-and-network\" || fetchPolicy === \"network-only\") {\n return obsQuery.reobserve({\n fetchPolicy: \"cache-first\",\n // Use a temporary nextFetchPolicy function that replaces itself with the\n // previous nextFetchPolicy value and returns the original fetchPolicy.\n nextFetchPolicy(\n this: WatchQueryOptions<TVars, TData>,\n currentFetchPolicy: WatchQueryFetchPolicy,\n context: NextFetchPolicyContext<TData, TVars>\n ) {\n // Replace this nextFetchPolicy function in the options object with the\n // original this.options.nextFetchPolicy value.\n this.nextFetchPolicy = nextFetchPolicy;\n // If the original nextFetchPolicy value was a function, give it a\n // chance to decide what happens here.\n if (typeof this.nextFetchPolicy === \"function\") {\n return this.nextFetchPolicy(currentFetchPolicy, context);\n }\n // Otherwise go back to the original this.options.fetchPolicy.\n return fetchPolicy!;\n },\n });\n }\n\n return obsQuery.reobserve();\n}\n\nfunction defaultSubscriptionObserverErrorCallback(error: ApolloError) {\n invariant.error(\"Unhandled error\", error.message, error.stack);\n}\n\nexport function logMissingFieldErrors(\n missing: MissingFieldError[] | MissingTree | undefined\n) {\n if (__DEV__ && missing) {\n invariant.debug(`Missing cache result fields: %o`, missing);\n }\n}\n\nfunction skipCacheDataFor(\n fetchPolicy?: WatchQueryFetchPolicy /* `undefined` would mean `\"cache-first\"` */\n) {\n return (\n fetchPolicy === \"network-only\" ||\n fetchPolicy === \"no-cache\" ||\n fetchPolicy === \"standby\"\n );\n}\n"]}
@@ -29,20 +29,21 @@ export declare class QueryInfo {
29
29
  document: DocumentNode;
30
30
  variables: Record<string, any> | undefined;
31
31
  networkStatus?: NetworkStatus;
32
- observableQuery?: ObservableQuery<any>;
32
+ observableQuery?: ObservableQuery<any, any>;
33
33
  lastRequestId?: number;
34
34
  }): this;
35
35
  private dirty;
36
36
  private notifyTimeout?;
37
37
  reset(): void;
38
+ resetDiff(): void;
38
39
  getDiff(): Cache.DiffResult<any>;
39
40
  private lastDiff?;
40
41
  private updateLastDiff;
41
42
  private getDiffOptions;
42
43
  setDiff(diff: Cache.DiffResult<any> | null): void;
43
- readonly observableQuery: ObservableQuery<any> | null;
44
+ readonly observableQuery: ObservableQuery<any, any> | null;
44
45
  private oqListener?;
45
- setObservableQuery(oq: ObservableQuery<any> | null): void;
46
+ setObservableQuery(oq: ObservableQuery<any, any> | null): void;
46
47
  notify(): void;
47
48
  private shouldNotify;
48
49
  stop(): void;
package/core/QueryInfo.js CHANGED
@@ -9,8 +9,15 @@ var destructiveMethodCounts = new (canUseWeakMap ? WeakMap : Map)();
9
9
  function wrapDestructiveCacheMethod(cache, methodName) {
10
10
  var original = cache[methodName];
11
11
  if (typeof original === "function") {
12
+ // @ts-expect-error this is just too generic to be typed correctly
12
13
  cache[methodName] = function () {
13
- destructiveMethodCounts.set(cache, (destructiveMethodCounts.get(cache) + 1) % 1e15);
14
+ destructiveMethodCounts.set(cache,
15
+ // The %1e15 allows the count to wrap around to 0 safely every
16
+ // quadrillion evictions, so there's no risk of overflow. To be
17
+ // clear, this is more of a pedantic principle than something
18
+ // that matters in any conceivable practical scenario.
19
+ (destructiveMethodCounts.get(cache) + 1) % 1e15);
20
+ // @ts-expect-error this is just too generic to be typed correctly
14
21
  return original.apply(this, arguments);
15
22
  };
16
23
  }
@@ -21,7 +28,19 @@ function cancelNotifyTimeout(info) {
21
28
  info["notifyTimeout"] = void 0;
22
29
  }
23
30
  }
24
- var QueryInfo = (function () {
31
+ // A QueryInfo object represents a single query managed by the
32
+ // QueryManager, which tracks all QueryInfo objects by queryId in its
33
+ // this.queries Map. QueryInfo objects store the latest results and errors
34
+ // for the given query, and are responsible for reporting those results to
35
+ // the corresponding ObservableQuery, via the QueryInfo.notify method.
36
+ // Results are reported asynchronously whenever setDiff marks the
37
+ // QueryInfo object as dirty, though a call to the QueryManager's
38
+ // broadcastQueries method may trigger the notification before it happens
39
+ // automatically. This class used to be a simple interface type without
40
+ // any field privacy or meaningful methods, which is why it still has so
41
+ // many public fields. The effort to lock down and simplify the QueryInfo
42
+ // interface is ongoing, and further improvements are welcome.
43
+ var QueryInfo = /** @class */ (function () {
25
44
  function QueryInfo(queryManager, queryId) {
26
45
  if (queryId === void 0) { queryId = queryManager.generateQueryId(); }
27
46
  this.queryId = queryId;
@@ -32,6 +51,11 @@ var QueryInfo = (function () {
32
51
  this.dirty = false;
33
52
  this.observableQuery = null;
34
53
  var cache = (this.cache = queryManager.cache);
54
+ // Track how often cache.evict is called, since we want eviction to
55
+ // override the feud-stopping logic in the markResult method, by
56
+ // causing shouldWrite to return true. Wrapping the cache.evict method
57
+ // is a bit of a hack, but it saves us from having to make eviction
58
+ // counting an official part of the ApolloCache API.
35
59
  if (!destructiveMethodCounts.has(cache)) {
36
60
  destructiveMethodCounts.set(cache, 0);
37
61
  wrapDestructiveCacheMethod(cache, "evict");
@@ -68,6 +92,9 @@ var QueryInfo = (function () {
68
92
  cancelNotifyTimeout(this);
69
93
  this.dirty = false;
70
94
  };
95
+ QueryInfo.prototype.resetDiff = function () {
96
+ this.lastDiff = void 0;
97
+ };
71
98
  QueryInfo.prototype.getDiff = function () {
72
99
  var options = this.getDiffOptions();
73
100
  if (this.lastDiff && equal(options, this.lastDiff.options)) {
@@ -83,12 +110,13 @@ var QueryInfo = (function () {
83
110
  return diff;
84
111
  };
85
112
  QueryInfo.prototype.updateLastDiff = function (diff, options) {
86
- this.lastDiff = diff
87
- ? {
88
- diff: diff,
89
- options: options || this.getDiffOptions(),
90
- }
91
- : void 0;
113
+ this.lastDiff =
114
+ diff ?
115
+ {
116
+ diff: diff,
117
+ options: options || this.getDiffOptions(),
118
+ }
119
+ : void 0;
92
120
  };
93
121
  QueryInfo.prototype.getDiffOptions = function (variables) {
94
122
  var _a;
@@ -125,9 +153,22 @@ var QueryInfo = (function () {
125
153
  this.listeners.add((this.oqListener = function () {
126
154
  var diff = _this.getDiff();
127
155
  if (diff.fromOptimisticTransaction) {
156
+ // If this diff came from an optimistic transaction, deliver the
157
+ // current cache data to the ObservableQuery, but don't perform a
158
+ // reobservation, since oq.reobserveCacheFirst might make a network
159
+ // request, and we never want to trigger network requests in the
160
+ // middle of optimistic updates.
128
161
  oq["observe"]();
129
162
  }
130
163
  else {
164
+ // Otherwise, make the ObservableQuery "reobserve" the latest data
165
+ // using a temporary fetch policy of "cache-first", so complete cache
166
+ // results have a chance to be delivered without triggering additional
167
+ // network requests, even when options.fetchPolicy is "network-only"
168
+ // or "cache-and-network". All other fetch policies are preserved by
169
+ // this method, and are handled by calling oq.reobserve(). If this
170
+ // reobservation is spurious, isDifferentFromLastResult still has a
171
+ // chance to catch it before delivery to ObservableQuery subscribers.
131
172
  reobserveCacheFirst(oq);
132
173
  }
133
174
  }));
@@ -159,14 +200,19 @@ var QueryInfo = (function () {
159
200
  QueryInfo.prototype.stop = function () {
160
201
  if (!this.stopped) {
161
202
  this.stopped = true;
203
+ // Cancel the pending notify timeout
162
204
  this.reset();
163
205
  this.cancel();
206
+ // Revert back to the no-op version of cancel inherited from
207
+ // QueryInfo.prototype.
164
208
  this.cancel = QueryInfo.prototype.cancel;
165
209
  var oq = this.observableQuery;
166
210
  if (oq)
167
211
  oq.stopPolling();
168
212
  }
169
213
  };
214
+ // This method is a no-op by default, until/unless overridden by the
215
+ // updateWatch method.
170
216
  QueryInfo.prototype.cancel = function () { };
171
217
  QueryInfo.prototype.updateWatch = function (variables) {
172
218
  var _this = this;
@@ -187,6 +233,9 @@ var QueryInfo = (function () {
187
233
  QueryInfo.prototype.shouldWrite = function (result, variables) {
188
234
  var lastWrite = this.lastWrite;
189
235
  return !(lastWrite &&
236
+ // If cache.evict has been called since the last time we wrote this
237
+ // data into the cache, there's a chance writing this result into
238
+ // the cache will repair what was evicted.
190
239
  lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&
191
240
  equal(variables, lastWrite.variables) &&
192
241
  equal(result.data, lastWrite.result.data));
@@ -195,13 +244,18 @@ var QueryInfo = (function () {
195
244
  var _this = this;
196
245
  result = __assign({}, result);
197
246
  var merger = new DeepMerger();
198
- var graphQLErrors = isNonEmptyArray(result.errors)
199
- ? result.errors.slice(0)
200
- : [];
247
+ var graphQLErrors = isNonEmptyArray(result.errors) ? result.errors.slice(0) : [];
248
+ // Cancel the pending notify timeout (if it exists) to prevent extraneous network
249
+ // requests. To allow future notify timeouts, diff and dirty are reset as well.
201
250
  this.reset();
202
251
  if ("incremental" in result && isNonEmptyArray(result.incremental)) {
203
252
  var mergedData = mergeIncrementalData(this.getDiff().result, result);
204
253
  result.data = mergedData;
254
+ // Detect the first chunk of a deferred query and merge it with existing
255
+ // cache data. This ensures a `cache-first` fetch policy that returns
256
+ // partial cache data or a `cache-and-network` fetch policy that already
257
+ // has full data in the cache does not complain when trying to merge the
258
+ // initial deferred server data with existing cache data.
205
259
  }
206
260
  else if ("hasNext" in result && result.hasNext) {
207
261
  var diff = this.getDiff();
@@ -211,33 +265,88 @@ var QueryInfo = (function () {
211
265
  if (options.fetchPolicy === "no-cache") {
212
266
  this.updateLastDiff({ result: result.data, complete: true }, this.getDiffOptions(options.variables));
213
267
  }
214
- else if (cacheWriteBehavior !== 0) {
268
+ else if (cacheWriteBehavior !== 0 /* CacheWriteBehavior.FORBID */) {
215
269
  if (shouldWriteResult(result, options.errorPolicy)) {
270
+ // Using a transaction here so we have a chance to read the result
271
+ // back from the cache before the watch callback fires as a result
272
+ // of writeQuery, so we can store the new diff quietly and ignore
273
+ // it when we receive it redundantly from the watch callback.
216
274
  this.cache.performTransaction(function (cache) {
217
275
  if (_this.shouldWrite(result, options.variables)) {
218
276
  cache.writeQuery({
219
277
  query: document,
220
278
  data: result.data,
221
279
  variables: options.variables,
222
- overwrite: cacheWriteBehavior === 1,
280
+ overwrite: cacheWriteBehavior === 1 /* CacheWriteBehavior.OVERWRITE */,
223
281
  });
224
282
  _this.lastWrite = {
283
+ // Make a shallow defensive copy of the result object, in case we
284
+ // later later modify result.data in place, since we don't want
285
+ // that mutation affecting the saved lastWrite.result.data.
225
286
  result: __assign({}, result),
226
287
  variables: options.variables,
227
288
  dmCount: destructiveMethodCounts.get(_this.cache),
228
289
  };
229
290
  }
230
291
  else {
292
+ // If result is the same as the last result we received from
293
+ // the network (and the variables match too), avoid writing
294
+ // result into the cache again. The wisdom of skipping this
295
+ // cache write is far from obvious, since any cache write
296
+ // could be the one that puts the cache back into a desired
297
+ // state, fixing corruption or missing data. However, if we
298
+ // always write every network result into the cache, we enable
299
+ // feuds between queries competing to update the same data in
300
+ // incompatible ways, which can lead to an endless cycle of
301
+ // cache broadcasts and useless network requests. As with any
302
+ // feud, eventually one side must step back from the brink,
303
+ // letting the other side(s) have the last word(s). There may
304
+ // be other points where we could break this cycle, such as
305
+ // silencing the broadcast for cache.writeQuery (not a good
306
+ // idea, since it just delays the feud a bit) or somehow
307
+ // avoiding the network request that just happened (also bad,
308
+ // because the server could return useful new data). All
309
+ // options considered, skipping this cache write seems to be
310
+ // the least damaging place to break the cycle, because it
311
+ // reflects the intuition that we recently wrote this exact
312
+ // result into the cache, so the cache *should* already/still
313
+ // contain this data. If some other query has clobbered that
314
+ // data in the meantime, that's too bad, but there will be no
315
+ // winners if every query blindly reverts to its own version
316
+ // of the data. This approach also gives the network a chance
317
+ // to return new data, which will be written into the cache as
318
+ // usual, notifying only those queries that are directly
319
+ // affected by the cache updates, as usual. In the future, an
320
+ // even more sophisticated cache could perhaps prevent or
321
+ // mitigate the clobbering somehow, but that would make this
322
+ // particular cache write even less important, and thus
323
+ // skipping it would be even safer than it is today.
231
324
  if (_this.lastDiff && _this.lastDiff.diff.complete) {
325
+ // Reuse data from the last good (complete) diff that we
326
+ // received, when possible.
232
327
  result.data = _this.lastDiff.diff.result;
233
328
  return;
234
329
  }
330
+ // If the previous this.diff was incomplete, fall through to
331
+ // re-reading the latest data with cache.diff, below.
235
332
  }
236
333
  var diffOptions = _this.getDiffOptions(options.variables);
237
334
  var diff = cache.diff(diffOptions);
335
+ // In case the QueryManager stops this QueryInfo before its
336
+ // results are delivered, it's important to avoid restarting the
337
+ // cache watch when markResult is called. We also avoid updating
338
+ // the watch if we are writing a result that doesn't match the current
339
+ // variables to avoid race conditions from broadcasting the wrong
340
+ // result.
238
341
  if (!_this.stopped && equal(_this.variables, options.variables)) {
342
+ // Any time we're about to update this.diff, we need to make
343
+ // sure we've started watching the cache.
239
344
  _this.updateWatch(options.variables);
240
345
  }
346
+ // If we're allowed to write to the cache, update result.data to be
347
+ // the result as re-read from the cache, rather than the raw network
348
+ // result. Set without setDiff to avoid triggering a notify call,
349
+ // since we have other ways of notifying for this result.
241
350
  _this.updateLastDiff(diff, diffOptions);
242
351
  result.data = diff.result;
243
352
  });