@apollo/client 4.0.0-alpha.13 → 4.0.0-alpha.15

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 (671) hide show
  1. package/.changeset/beige-spiders-hope.md +5 -0
  2. package/.changeset/curvy-flies-accept.md +5 -0
  3. package/.changeset/few-crabs-move.md +6 -0
  4. package/.changeset/funny-boats-wink.md +35 -0
  5. package/.changeset/gold-oranges-double.md +5 -0
  6. package/.changeset/little-parrots-bow.md +14 -0
  7. package/.changeset/olive-cougars-ring.md +9 -0
  8. package/.changeset/poor-spiders-hunt.md +23 -0
  9. package/.changeset/pre.json +20 -0
  10. package/.changeset/selfish-spoons-approve.md +44 -0
  11. package/.changeset/serious-items-develop.md +17 -0
  12. package/.changeset/sixty-bats-cry.md +6 -0
  13. package/.changeset/slimy-ants-bake.md +5 -0
  14. package/.changeset/sour-colts-tell.md +5 -0
  15. package/.changeset/sour-guests-poke.md +5 -0
  16. package/.changeset/spotty-mugs-poke.md +5 -0
  17. package/.changeset/strange-walls-march.md +5 -0
  18. package/.changeset/strong-rivers-fry.md +34 -0
  19. package/.changeset/stupid-pumpkins-travel.md +13 -0
  20. package/.changeset/thirty-pens-jump.md +5 -0
  21. package/.changeset/wicked-kiwis-buy.md +5 -0
  22. package/CHANGELOG.md +213 -0
  23. package/__cjs/cache/core/cache.cjs +9 -7
  24. package/__cjs/cache/core/cache.cjs.map +1 -1
  25. package/__cjs/cache/core/cache.d.cts +9 -7
  26. package/__cjs/cache/inmemory/entityStore.cjs +3 -3
  27. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  28. package/__cjs/cache/inmemory/inMemoryCache.d.cts +9 -7
  29. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  30. package/__cjs/cache/inmemory/policies.cjs +4 -4
  31. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  32. package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
  33. package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
  34. package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
  35. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  36. package/__cjs/core/ApolloClient.cjs +23 -45
  37. package/__cjs/core/ApolloClient.cjs.map +1 -1
  38. package/__cjs/core/ApolloClient.d.cts +9 -21
  39. package/__cjs/core/ObservableQuery.cjs +564 -340
  40. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  41. package/__cjs/core/ObservableQuery.d.cts +95 -33
  42. package/__cjs/core/QueryInfo.cjs +109 -179
  43. package/__cjs/core/QueryInfo.cjs.map +1 -1
  44. package/__cjs/core/QueryInfo.d.cts +9 -14
  45. package/__cjs/core/QueryManager.cjs +168 -108
  46. package/__cjs/core/QueryManager.cjs.map +1 -1
  47. package/__cjs/core/QueryManager.d.cts +12 -8
  48. package/__cjs/core/index.cjs +2 -1
  49. package/__cjs/core/index.cjs.map +1 -1
  50. package/__cjs/core/index.d.cts +2 -3
  51. package/__cjs/core/types.d.cts +18 -6
  52. package/__cjs/errors/LinkError.cjs +5 -1
  53. package/__cjs/errors/LinkError.cjs.map +1 -1
  54. package/__cjs/errors/LinkError.d.cts +5 -1
  55. package/__cjs/errors/LocalStateError.cjs +27 -0
  56. package/__cjs/errors/LocalStateError.cjs.map +1 -0
  57. package/__cjs/errors/LocalStateError.d.cts +20 -0
  58. package/__cjs/errors/index.cjs +5 -1
  59. package/__cjs/errors/index.cjs.map +1 -1
  60. package/__cjs/errors/index.d.cts +2 -0
  61. package/__cjs/invariantErrorCodes.cjs +130 -57
  62. package/__cjs/link/core/ApolloLink.cjs +17 -11
  63. package/__cjs/link/core/ApolloLink.cjs.map +1 -1
  64. package/__cjs/link/core/ApolloLink.d.cts +15 -9
  65. package/__cjs/link/http/checkFetcher.cjs +1 -1
  66. package/__cjs/link/http/createHttpLink.cjs +1 -1
  67. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
  68. package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
  69. package/__cjs/link/persisted-queries/index.cjs +2 -2
  70. package/__cjs/link/utils/transformOperation.cjs +1 -1
  71. package/__cjs/link/utils/transformOperation.cjs.map +1 -1
  72. package/__cjs/link/utils/validateOperation.cjs +1 -1
  73. package/__cjs/local-state/LocalState.cjs +535 -0
  74. package/__cjs/local-state/LocalState.cjs.map +1 -0
  75. package/__cjs/local-state/LocalState.d.cts +89 -0
  76. package/__cjs/local-state/index.cjs +6 -0
  77. package/__cjs/local-state/index.cjs.map +1 -0
  78. package/__cjs/local-state/index.d.cts +2 -0
  79. package/__cjs/masking/maskFragment.cjs +5 -1
  80. package/__cjs/masking/maskFragment.cjs.map +1 -1
  81. package/__cjs/masking/maskFragment.d.cts +5 -1
  82. package/__cjs/masking/maskOperation.cjs +5 -1
  83. package/__cjs/masking/maskOperation.cjs.map +1 -1
  84. package/__cjs/masking/maskOperation.d.cts +5 -1
  85. package/__cjs/masking/utils.cjs +5 -1
  86. package/__cjs/masking/utils.cjs.map +1 -1
  87. package/__cjs/masking/utils.d.cts +5 -1
  88. package/__cjs/react/hooks/internal/wrapHook.cjs +36 -34
  89. package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
  90. package/__cjs/react/hooks/internal/wrapHook.d.cts +42 -38
  91. package/__cjs/react/hooks/useQuery.cjs +10 -25
  92. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  93. package/__cjs/react/hooks/useQuery.d.cts +0 -1
  94. package/__cjs/react/internal/cache/QueryReference.cjs +6 -9
  95. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  96. package/__cjs/react/internal/cache/QueryReference.d.cts +25 -7
  97. package/__cjs/react/ssr/prerenderStatic.cjs +7 -0
  98. package/__cjs/react/ssr/prerenderStatic.cjs.map +1 -1
  99. package/__cjs/react/ssr/useSSRQuery.cjs +11 -2
  100. package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
  101. package/__cjs/testing/core/mocking/mockLink.cjs +7 -9
  102. package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
  103. package/__cjs/testing/core/mocking/mockLink.d.cts +29 -22
  104. package/__cjs/testing/core/mocking/mockSubscriptionLink.cjs +0 -4
  105. package/__cjs/testing/core/mocking/mockSubscriptionLink.cjs.map +1 -1
  106. package/__cjs/testing/core/mocking/mockSubscriptionLink.d.cts +7 -6
  107. package/__cjs/testing/core/types/deprecated.cjs +3 -0
  108. package/__cjs/testing/core/types/deprecated.cjs.map +1 -0
  109. package/__cjs/testing/core/types/deprecated.d.cts +10 -0
  110. package/__cjs/testing/index.cjs +6 -13
  111. package/__cjs/testing/index.cjs.map +1 -1
  112. package/__cjs/testing/index.d.cts +3 -2
  113. package/__cjs/testing/internal/ObservableStream.cjs +13 -1
  114. package/__cjs/testing/internal/ObservableStream.cjs.map +1 -1
  115. package/__cjs/testing/internal/ObservableStream.d.cts +12 -1
  116. package/__cjs/testing/internal/disposables/withCleanup.cjs +5 -1
  117. package/__cjs/testing/internal/disposables/withCleanup.cjs.map +1 -1
  118. package/__cjs/testing/internal/disposables/withCleanup.d.cts +5 -1
  119. package/__cjs/testing/internal/index.cjs +3 -1
  120. package/__cjs/testing/internal/index.cjs.map +1 -1
  121. package/__cjs/testing/internal/index.d.cts +1 -0
  122. package/__cjs/testing/internal/scenarios/index.cjs +4 -4
  123. package/__cjs/testing/internal/scenarios/index.cjs.map +1 -1
  124. package/__cjs/testing/internal/scenarios/index.d.cts +8 -8
  125. package/__cjs/testing/{core → internal}/wait.cjs +0 -4
  126. package/__cjs/testing/internal/wait.cjs.map +1 -0
  127. package/__cjs/testing/{core → internal}/wait.d.cts +0 -1
  128. package/__cjs/testing/matchers/index.cjs +2 -2
  129. package/__cjs/testing/matchers/index.cjs.map +1 -1
  130. package/__cjs/testing/matchers/toEmitTypedValue.cjs +1 -1
  131. package/__cjs/testing/matchers/toEmitTypedValue.cjs.map +1 -1
  132. package/__cjs/testing/matchers/toEmitTypedValue.d.cts +6 -1
  133. package/__cjs/testing/matchers/toRerenderWithSimilarSnapshot.cjs +31 -18
  134. package/__cjs/testing/matchers/toRerenderWithSimilarSnapshot.cjs.map +1 -1
  135. package/__cjs/testing/matchers/toRerenderWithSimilarSnapshot.d.cts +13 -6
  136. package/__cjs/testing/matchers/toStrictEqualTyped.cjs +1 -1
  137. package/__cjs/testing/matchers/toStrictEqualTyped.cjs.map +1 -1
  138. package/__cjs/testing/matchers/toStrictEqualTyped.d.cts +4 -0
  139. package/__cjs/testing/matchers/utils/getSerializableProperties.cjs +14 -2
  140. package/__cjs/testing/matchers/utils/getSerializableProperties.cjs.map +1 -1
  141. package/__cjs/testing/react/MockedProvider.cjs +4 -4
  142. package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
  143. package/__cjs/testing/react/MockedProvider.d.cts +4 -5
  144. package/__cjs/utilities/graphql/DocumentTransform.cjs +10 -6
  145. package/__cjs/utilities/graphql/DocumentTransform.cjs.map +1 -1
  146. package/__cjs/utilities/graphql/DocumentTransform.d.cts +10 -6
  147. package/__cjs/utilities/internal/DeepMerger.cjs +5 -1
  148. package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -1
  149. package/__cjs/utilities/internal/DeepMerger.d.cts +5 -1
  150. package/__cjs/utilities/internal/argumentsObjectFromField.cjs +5 -1
  151. package/__cjs/utilities/internal/argumentsObjectFromField.cjs.map +1 -1
  152. package/__cjs/utilities/internal/argumentsObjectFromField.d.cts +5 -1
  153. package/__cjs/utilities/internal/caches.cjs +24 -20
  154. package/__cjs/utilities/internal/caches.cjs.map +1 -1
  155. package/__cjs/utilities/internal/caches.d.cts +32 -24
  156. package/__cjs/utilities/internal/canUseDOM.cjs +5 -1
  157. package/__cjs/utilities/internal/canUseDOM.cjs.map +1 -1
  158. package/__cjs/utilities/internal/canUseDOM.d.cts +5 -1
  159. package/__cjs/utilities/internal/checkDocument.cjs +6 -3
  160. package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
  161. package/__cjs/utilities/internal/checkDocument.d.cts +6 -3
  162. package/__cjs/utilities/internal/cloneDeep.cjs +6 -4
  163. package/__cjs/utilities/internal/cloneDeep.cjs.map +1 -1
  164. package/__cjs/utilities/internal/cloneDeep.d.cts +6 -4
  165. package/__cjs/utilities/internal/compact.cjs +7 -5
  166. package/__cjs/utilities/internal/compact.cjs.map +1 -1
  167. package/__cjs/utilities/internal/compact.d.cts +7 -5
  168. package/__cjs/utilities/internal/createFragmentMap.cjs +7 -4
  169. package/__cjs/utilities/internal/createFragmentMap.cjs.map +1 -1
  170. package/__cjs/utilities/internal/createFragmentMap.d.cts +7 -4
  171. package/__cjs/utilities/internal/createFulfilledPromise.cjs +5 -1
  172. package/__cjs/utilities/internal/createFulfilledPromise.cjs.map +1 -1
  173. package/__cjs/utilities/internal/createFulfilledPromise.d.cts +5 -1
  174. package/__cjs/utilities/internal/createRejectedPromise.cjs +5 -1
  175. package/__cjs/utilities/internal/createRejectedPromise.cjs.map +1 -1
  176. package/__cjs/utilities/internal/createRejectedPromise.d.cts +5 -1
  177. package/__cjs/utilities/internal/dealias.cjs +21 -0
  178. package/__cjs/utilities/internal/dealias.cjs.map +1 -0
  179. package/__cjs/utilities/internal/dealias.d.cts +5 -0
  180. package/__cjs/utilities/internal/decoratePromise.cjs +5 -1
  181. package/__cjs/utilities/internal/decoratePromise.cjs.map +1 -1
  182. package/__cjs/utilities/internal/decoratePromise.d.cts +5 -1
  183. package/__cjs/utilities/internal/deepFreeze.cjs +5 -1
  184. package/__cjs/utilities/internal/deepFreeze.cjs.map +1 -1
  185. package/__cjs/utilities/internal/deepFreeze.d.cts +5 -1
  186. package/__cjs/utilities/internal/filterMap.cjs +31 -0
  187. package/__cjs/utilities/internal/filterMap.cjs.map +1 -0
  188. package/__cjs/utilities/internal/filterMap.d.cts +4 -0
  189. package/__cjs/utilities/internal/getDefaultValues.cjs +5 -1
  190. package/__cjs/utilities/internal/getDefaultValues.cjs.map +1 -1
  191. package/__cjs/utilities/internal/getDefaultValues.d.cts +5 -1
  192. package/__cjs/utilities/internal/getFragmentDefinition.cjs +5 -1
  193. package/__cjs/utilities/internal/getFragmentDefinition.cjs.map +1 -1
  194. package/__cjs/utilities/internal/getFragmentDefinition.d.cts +5 -1
  195. package/__cjs/utilities/internal/getFragmentDefinitions.cjs +5 -1
  196. package/__cjs/utilities/internal/getFragmentDefinitions.cjs.map +1 -1
  197. package/__cjs/utilities/internal/getFragmentDefinitions.d.cts +5 -1
  198. package/__cjs/utilities/internal/getFragmentFromSelection.cjs +5 -1
  199. package/__cjs/utilities/internal/getFragmentFromSelection.cjs.map +1 -1
  200. package/__cjs/utilities/internal/getFragmentFromSelection.d.cts +5 -1
  201. package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +25 -23
  202. package/__cjs/utilities/internal/getFragmentQueryDocument.cjs.map +1 -1
  203. package/__cjs/utilities/internal/getFragmentQueryDocument.d.cts +25 -23
  204. package/__cjs/utilities/internal/getGraphQLErrorsFromResult.cjs +5 -1
  205. package/__cjs/utilities/internal/getGraphQLErrorsFromResult.cjs.map +1 -1
  206. package/__cjs/utilities/internal/getGraphQLErrorsFromResult.d.cts +5 -1
  207. package/__cjs/utilities/internal/getMainDefinition.cjs +8 -6
  208. package/__cjs/utilities/internal/getMainDefinition.cjs.map +1 -1
  209. package/__cjs/utilities/internal/getMainDefinition.d.cts +8 -6
  210. package/__cjs/utilities/internal/getMemoryInternals.cjs +15 -9
  211. package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
  212. package/__cjs/utilities/internal/getMemoryInternals.d.cts +15 -9
  213. package/__cjs/utilities/internal/getOperationDefinition.cjs +5 -1
  214. package/__cjs/utilities/internal/getOperationDefinition.cjs.map +1 -1
  215. package/__cjs/utilities/internal/getOperationDefinition.d.cts +5 -1
  216. package/__cjs/utilities/internal/getOperationName.cjs +7 -5
  217. package/__cjs/utilities/internal/getOperationName.cjs.map +1 -1
  218. package/__cjs/utilities/internal/getOperationName.d.cts +6 -2
  219. package/__cjs/utilities/internal/getQueryDefinition.cjs +5 -1
  220. package/__cjs/utilities/internal/getQueryDefinition.cjs.map +1 -1
  221. package/__cjs/utilities/internal/getQueryDefinition.d.cts +5 -1
  222. package/__cjs/utilities/internal/getStoreKeyName.cjs +5 -1
  223. package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
  224. package/__cjs/utilities/internal/getStoreKeyName.d.cts +5 -1
  225. package/__cjs/utilities/internal/graphQLResultHasError.cjs +5 -1
  226. package/__cjs/utilities/internal/graphQLResultHasError.cjs.map +1 -1
  227. package/__cjs/utilities/internal/graphQLResultHasError.d.cts +5 -1
  228. package/__cjs/utilities/internal/hasDirectives.cjs +5 -1
  229. package/__cjs/utilities/internal/hasDirectives.cjs.map +1 -1
  230. package/__cjs/utilities/internal/hasDirectives.d.cts +5 -1
  231. package/__cjs/utilities/internal/hasForcedResolvers.cjs +23 -0
  232. package/__cjs/utilities/internal/hasForcedResolvers.cjs.map +1 -0
  233. package/__cjs/utilities/internal/hasForcedResolvers.d.cts +3 -0
  234. package/__cjs/utilities/internal/index.cjs +8 -4
  235. package/__cjs/utilities/internal/index.cjs.map +1 -1
  236. package/__cjs/utilities/internal/index.d.cts +3 -1
  237. package/__cjs/utilities/internal/isArray.cjs +6 -4
  238. package/__cjs/utilities/internal/isArray.cjs.map +1 -1
  239. package/__cjs/utilities/internal/isArray.d.cts +6 -4
  240. package/__cjs/utilities/internal/isDocumentNode.cjs +5 -1
  241. package/__cjs/utilities/internal/isDocumentNode.cjs.map +1 -1
  242. package/__cjs/utilities/internal/isDocumentNode.d.cts +5 -1
  243. package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.cjs +5 -1
  244. package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.cjs.map +1 -1
  245. package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.d.cts +5 -1
  246. package/__cjs/utilities/internal/isExecutionPatchIninitialResult.cjs +5 -1
  247. package/__cjs/utilities/internal/isExecutionPatchIninitialResult.cjs.map +1 -1
  248. package/__cjs/utilities/internal/isExecutionPatchIninitialResult.d.cts +5 -1
  249. package/__cjs/utilities/internal/isExecutionPatchResult.cjs +5 -1
  250. package/__cjs/utilities/internal/isExecutionPatchResult.cjs.map +1 -1
  251. package/__cjs/utilities/internal/isExecutionPatchResult.d.cts +5 -1
  252. package/__cjs/utilities/internal/isField.cjs +5 -1
  253. package/__cjs/utilities/internal/isField.cjs.map +1 -1
  254. package/__cjs/utilities/internal/isField.d.cts +5 -1
  255. package/__cjs/utilities/internal/isNonEmptyArray.cjs +5 -1
  256. package/__cjs/utilities/internal/isNonEmptyArray.cjs.map +1 -1
  257. package/__cjs/utilities/internal/isNonEmptyArray.d.cts +5 -1
  258. package/__cjs/utilities/internal/isNonNullObject.cjs +5 -1
  259. package/__cjs/utilities/internal/isNonNullObject.cjs.map +1 -1
  260. package/__cjs/utilities/internal/isNonNullObject.d.cts +5 -1
  261. package/__cjs/utilities/internal/isPlainObject.cjs +5 -1
  262. package/__cjs/utilities/internal/isPlainObject.cjs.map +1 -1
  263. package/__cjs/utilities/internal/isPlainObject.d.cts +5 -1
  264. package/__cjs/utilities/internal/makeReference.cjs +5 -1
  265. package/__cjs/utilities/internal/makeReference.cjs.map +1 -1
  266. package/__cjs/utilities/internal/makeReference.d.cts +5 -1
  267. package/__cjs/utilities/internal/makeUniqueId.cjs +7 -5
  268. package/__cjs/utilities/internal/makeUniqueId.cjs.map +1 -1
  269. package/__cjs/utilities/internal/makeUniqueId.d.cts +7 -5
  270. package/__cjs/utilities/internal/maybeDeepFreeze.cjs +5 -1
  271. package/__cjs/utilities/internal/maybeDeepFreeze.cjs.map +1 -1
  272. package/__cjs/utilities/internal/maybeDeepFreeze.d.cts +5 -1
  273. package/__cjs/utilities/internal/mergeDeep.cjs +5 -1
  274. package/__cjs/utilities/internal/mergeDeep.cjs.map +1 -1
  275. package/__cjs/utilities/internal/mergeDeep.d.cts +5 -1
  276. package/__cjs/utilities/internal/mergeDeepArray.cjs +5 -1
  277. package/__cjs/utilities/internal/mergeDeepArray.cjs.map +1 -1
  278. package/__cjs/utilities/internal/mergeDeepArray.d.cts +5 -1
  279. package/__cjs/utilities/internal/mergeIncrementalData.cjs +5 -1
  280. package/__cjs/utilities/internal/mergeIncrementalData.cjs.map +1 -1
  281. package/__cjs/utilities/internal/mergeIncrementalData.d.cts +5 -1
  282. package/__cjs/utilities/internal/mergeOptions.cjs +5 -1
  283. package/__cjs/utilities/internal/mergeOptions.cjs.map +1 -1
  284. package/__cjs/utilities/internal/mergeOptions.d.cts +5 -1
  285. package/__cjs/utilities/internal/omitDeep.cjs +5 -1
  286. package/__cjs/utilities/internal/omitDeep.cjs.map +1 -1
  287. package/__cjs/utilities/internal/omitDeep.d.cts +5 -1
  288. package/__cjs/utilities/internal/onAnyEvent.cjs +5 -1
  289. package/__cjs/utilities/internal/onAnyEvent.cjs.map +1 -1
  290. package/__cjs/utilities/internal/onAnyEvent.d.cts +5 -1
  291. package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +5 -1
  292. package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs.map +1 -1
  293. package/__cjs/utilities/internal/removeDirectivesFromDocument.d.cts +5 -1
  294. package/__cjs/utilities/internal/resultKeyNameFromField.cjs +5 -1
  295. package/__cjs/utilities/internal/resultKeyNameFromField.cjs.map +1 -1
  296. package/__cjs/utilities/internal/resultKeyNameFromField.d.cts +5 -1
  297. package/__cjs/utilities/internal/shouldInclude.cjs +5 -1
  298. package/__cjs/utilities/internal/shouldInclude.cjs.map +1 -1
  299. package/__cjs/utilities/internal/shouldInclude.d.cts +5 -1
  300. package/__cjs/utilities/internal/storeKeyNameFromField.cjs +5 -1
  301. package/__cjs/utilities/internal/storeKeyNameFromField.cjs.map +1 -1
  302. package/__cjs/utilities/internal/storeKeyNameFromField.d.cts +5 -1
  303. package/__cjs/utilities/internal/stringifyForDisplay.cjs +5 -1
  304. package/__cjs/utilities/internal/stringifyForDisplay.cjs.map +1 -1
  305. package/__cjs/utilities/internal/stringifyForDisplay.d.cts +5 -1
  306. package/__cjs/utilities/internal/toQueryResult.cjs +5 -1
  307. package/__cjs/utilities/internal/toQueryResult.cjs.map +1 -1
  308. package/__cjs/utilities/internal/toQueryResult.d.cts +5 -1
  309. package/__cjs/utilities/internal/types/DecoratedPromise.d.cts +5 -1
  310. package/__cjs/utilities/internal/types/DeepOmit.d.cts +5 -1
  311. package/__cjs/utilities/internal/types/DeepPartial.d.cts +5 -1
  312. package/__cjs/utilities/internal/types/FragmentMap.d.cts +6 -4
  313. package/__cjs/utilities/internal/types/FragmentMapFunction.d.cts +5 -1
  314. package/__cjs/utilities/internal/types/FulfilledPromise.d.cts +5 -1
  315. package/__cjs/utilities/internal/types/IsAny.d.cts +5 -1
  316. package/__cjs/utilities/internal/types/PendingPromise.d.cts +5 -1
  317. package/__cjs/utilities/internal/types/Prettify.d.cts +5 -1
  318. package/__cjs/utilities/internal/types/Primitive.d.cts +5 -1
  319. package/__cjs/utilities/internal/types/RejectedPromise.d.cts +5 -1
  320. package/__cjs/utilities/internal/types/RemoveIndexSignature.d.cts +5 -1
  321. package/__cjs/utilities/internal/types/VariablesOption.d.cts +5 -1
  322. package/__cjs/utilities/internal/valueToObjectRepresentation.cjs +5 -1
  323. package/__cjs/utilities/internal/valueToObjectRepresentation.cjs.map +1 -1
  324. package/__cjs/utilities/internal/valueToObjectRepresentation.d.cts +5 -1
  325. package/__cjs/version.cjs +1 -1
  326. package/cache/core/cache.d.ts +9 -7
  327. package/cache/core/cache.js +9 -7
  328. package/cache/core/cache.js.map +1 -1
  329. package/cache/inmemory/entityStore.js +3 -3
  330. package/cache/inmemory/inMemoryCache.d.ts +9 -7
  331. package/cache/inmemory/inMemoryCache.js.map +1 -1
  332. package/cache/inmemory/key-extractor.js +1 -1
  333. package/cache/inmemory/policies.js +4 -4
  334. package/cache/inmemory/policies.js.map +1 -1
  335. package/cache/inmemory/readFromStore.js +2 -2
  336. package/cache/inmemory/readFromStore.js.map +1 -1
  337. package/cache/inmemory/writeToStore.js +4 -4
  338. package/cache/inmemory/writeToStore.js.map +1 -1
  339. package/core/ApolloClient.d.ts +9 -21
  340. package/core/ApolloClient.js +23 -45
  341. package/core/ApolloClient.js.map +1 -1
  342. package/core/ObservableQuery.d.ts +95 -33
  343. package/core/ObservableQuery.js +569 -345
  344. package/core/ObservableQuery.js.map +1 -1
  345. package/core/QueryInfo.d.ts +9 -14
  346. package/core/QueryInfo.js +109 -179
  347. package/core/QueryInfo.js.map +1 -1
  348. package/core/QueryManager.d.ts +12 -8
  349. package/core/QueryManager.js +151 -110
  350. package/core/QueryManager.js.map +1 -1
  351. package/core/index.d.ts +2 -3
  352. package/core/index.js +1 -1
  353. package/core/index.js.map +1 -1
  354. package/core/types.d.ts +18 -6
  355. package/errors/LinkError.d.ts +5 -1
  356. package/errors/LinkError.js +5 -1
  357. package/errors/LinkError.js.map +1 -1
  358. package/errors/LocalStateError.d.ts +20 -0
  359. package/errors/LocalStateError.js +23 -0
  360. package/errors/LocalStateError.js.map +1 -0
  361. package/errors/index.d.ts +2 -0
  362. package/errors/index.js +2 -0
  363. package/errors/index.js.map +1 -1
  364. package/invariantErrorCodes.js +130 -57
  365. package/legacyEntryPoints/local-state/index.d.ts +1 -0
  366. package/legacyEntryPoints/local-state/index.js +1 -0
  367. package/legacyEntryPoints/local-state/local-state.cjs +1 -0
  368. package/legacyEntryPoints/local-state/local-state.d.cts +1 -0
  369. package/link/core/ApolloLink.d.ts +15 -9
  370. package/link/core/ApolloLink.js +17 -11
  371. package/link/core/ApolloLink.js.map +1 -1
  372. package/link/http/checkFetcher.js +1 -1
  373. package/link/http/createHttpLink.js +1 -1
  374. package/link/http/parseAndCheckHttpResponse.js +1 -1
  375. package/link/http/serializeFetchParameter.js +1 -1
  376. package/link/persisted-queries/index.js +2 -2
  377. package/link/utils/transformOperation.js +1 -1
  378. package/link/utils/transformOperation.js.map +1 -1
  379. package/link/utils/validateOperation.js +1 -1
  380. package/local-state/LocalState.d.ts +89 -0
  381. package/local-state/LocalState.js +527 -0
  382. package/local-state/LocalState.js.map +1 -0
  383. package/local-state/index.d.ts +2 -0
  384. package/local-state/index.js +2 -0
  385. package/local-state/index.js.map +1 -0
  386. package/masking/maskFragment.d.ts +5 -1
  387. package/masking/maskFragment.js +5 -1
  388. package/masking/maskFragment.js.map +1 -1
  389. package/masking/maskOperation.d.ts +5 -1
  390. package/masking/maskOperation.js +5 -1
  391. package/masking/maskOperation.js.map +1 -1
  392. package/masking/utils.d.ts +5 -1
  393. package/masking/utils.js +5 -1
  394. package/masking/utils.js.map +1 -1
  395. package/package.json +7 -155
  396. package/react/hooks/internal/wrapHook.d.ts +42 -38
  397. package/react/hooks/internal/wrapHook.js +36 -34
  398. package/react/hooks/internal/wrapHook.js.map +1 -1
  399. package/react/hooks/useQuery.d.ts +0 -1
  400. package/react/hooks/useQuery.js +10 -25
  401. package/react/hooks/useQuery.js.map +1 -1
  402. package/react/internal/cache/QueryReference.d.ts +25 -7
  403. package/react/internal/cache/QueryReference.js +6 -9
  404. package/react/internal/cache/QueryReference.js.map +1 -1
  405. package/react/ssr/prerenderStatic.js +7 -0
  406. package/react/ssr/prerenderStatic.js.map +1 -1
  407. package/react/ssr/useSSRQuery.js +11 -2
  408. package/react/ssr/useSSRQuery.js.map +1 -1
  409. package/testing/core/mocking/mockLink.d.ts +29 -22
  410. package/testing/core/mocking/mockLink.js +9 -10
  411. package/testing/core/mocking/mockLink.js.map +1 -1
  412. package/testing/core/mocking/mockSubscriptionLink.d.ts +7 -6
  413. package/testing/core/mocking/mockSubscriptionLink.js +0 -3
  414. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  415. package/testing/core/types/deprecated.d.ts +10 -0
  416. package/testing/core/types/deprecated.js +2 -0
  417. package/testing/core/types/deprecated.js.map +1 -0
  418. package/testing/index.d.ts +3 -2
  419. package/testing/index.js +2 -1
  420. package/testing/index.js.map +1 -1
  421. package/testing/internal/ObservableStream.d.ts +12 -1
  422. package/testing/internal/ObservableStream.js +13 -1
  423. package/testing/internal/ObservableStream.js.map +1 -1
  424. package/testing/internal/disposables/withCleanup.d.ts +5 -1
  425. package/testing/internal/disposables/withCleanup.js +5 -1
  426. package/testing/internal/disposables/withCleanup.js.map +1 -1
  427. package/testing/internal/index.d.ts +1 -0
  428. package/testing/internal/index.js +2 -1
  429. package/testing/internal/index.js.map +1 -1
  430. package/testing/internal/scenarios/index.d.ts +8 -8
  431. package/testing/internal/scenarios/index.js +4 -4
  432. package/testing/internal/scenarios/index.js.map +1 -1
  433. package/testing/{core → internal}/wait.d.ts +0 -1
  434. package/testing/{core → internal}/wait.js +0 -3
  435. package/testing/internal/wait.js.map +1 -0
  436. package/testing/matchers/index.js +2 -2
  437. package/testing/matchers/index.js.map +1 -1
  438. package/testing/matchers/toEmitTypedValue.d.ts +6 -1
  439. package/testing/matchers/toEmitTypedValue.js +1 -1
  440. package/testing/matchers/toEmitTypedValue.js.map +1 -1
  441. package/testing/matchers/toRerenderWithSimilarSnapshot.d.ts +13 -6
  442. package/testing/matchers/toRerenderWithSimilarSnapshot.js +30 -15
  443. package/testing/matchers/toRerenderWithSimilarSnapshot.js.map +1 -1
  444. package/testing/matchers/toStrictEqualTyped.d.ts +4 -0
  445. package/testing/matchers/toStrictEqualTyped.js +1 -1
  446. package/testing/matchers/toStrictEqualTyped.js.map +1 -1
  447. package/testing/matchers/utils/getSerializableProperties.js +14 -2
  448. package/testing/matchers/utils/getSerializableProperties.js.map +1 -1
  449. package/testing/react/MockedProvider.d.ts +4 -5
  450. package/testing/react/MockedProvider.js +3 -3
  451. package/testing/react/MockedProvider.js.map +1 -1
  452. package/utilities/graphql/DocumentTransform.d.ts +10 -6
  453. package/utilities/graphql/DocumentTransform.js +10 -6
  454. package/utilities/graphql/DocumentTransform.js.map +1 -1
  455. package/utilities/internal/DeepMerger.d.ts +5 -1
  456. package/utilities/internal/DeepMerger.js +5 -1
  457. package/utilities/internal/DeepMerger.js.map +1 -1
  458. package/utilities/internal/argumentsObjectFromField.d.ts +5 -1
  459. package/utilities/internal/argumentsObjectFromField.js +5 -1
  460. package/utilities/internal/argumentsObjectFromField.js.map +1 -1
  461. package/utilities/internal/caches.d.ts +32 -24
  462. package/utilities/internal/caches.js +24 -20
  463. package/utilities/internal/caches.js.map +1 -1
  464. package/utilities/internal/canUseDOM.d.ts +5 -1
  465. package/utilities/internal/canUseDOM.js +5 -1
  466. package/utilities/internal/canUseDOM.js.map +1 -1
  467. package/utilities/internal/checkDocument.d.ts +6 -3
  468. package/utilities/internal/checkDocument.js +6 -3
  469. package/utilities/internal/checkDocument.js.map +1 -1
  470. package/utilities/internal/cloneDeep.d.ts +6 -4
  471. package/utilities/internal/cloneDeep.js +6 -4
  472. package/utilities/internal/cloneDeep.js.map +1 -1
  473. package/utilities/internal/compact.d.ts +7 -5
  474. package/utilities/internal/compact.js +7 -5
  475. package/utilities/internal/compact.js.map +1 -1
  476. package/utilities/internal/createFragmentMap.d.ts +7 -4
  477. package/utilities/internal/createFragmentMap.js +7 -4
  478. package/utilities/internal/createFragmentMap.js.map +1 -1
  479. package/utilities/internal/createFulfilledPromise.d.ts +5 -1
  480. package/utilities/internal/createFulfilledPromise.js +5 -1
  481. package/utilities/internal/createFulfilledPromise.js.map +1 -1
  482. package/utilities/internal/createRejectedPromise.d.ts +5 -1
  483. package/utilities/internal/createRejectedPromise.js +5 -1
  484. package/utilities/internal/createRejectedPromise.js.map +1 -1
  485. package/utilities/internal/dealias.d.ts +5 -0
  486. package/utilities/internal/dealias.js +18 -0
  487. package/utilities/internal/dealias.js.map +1 -0
  488. package/utilities/internal/decoratePromise.d.ts +5 -1
  489. package/utilities/internal/decoratePromise.js +5 -1
  490. package/utilities/internal/decoratePromise.js.map +1 -1
  491. package/utilities/internal/deepFreeze.d.ts +5 -1
  492. package/utilities/internal/deepFreeze.js +5 -1
  493. package/utilities/internal/deepFreeze.js.map +1 -1
  494. package/utilities/internal/filterMap.d.ts +4 -0
  495. package/utilities/internal/filterMap.js +28 -0
  496. package/utilities/internal/filterMap.js.map +1 -0
  497. package/utilities/internal/getDefaultValues.d.ts +5 -1
  498. package/utilities/internal/getDefaultValues.js +5 -1
  499. package/utilities/internal/getDefaultValues.js.map +1 -1
  500. package/utilities/internal/getFragmentDefinition.d.ts +5 -1
  501. package/utilities/internal/getFragmentDefinition.js +5 -1
  502. package/utilities/internal/getFragmentDefinition.js.map +1 -1
  503. package/utilities/internal/getFragmentDefinitions.d.ts +5 -1
  504. package/utilities/internal/getFragmentDefinitions.js +5 -1
  505. package/utilities/internal/getFragmentDefinitions.js.map +1 -1
  506. package/utilities/internal/getFragmentFromSelection.d.ts +5 -1
  507. package/utilities/internal/getFragmentFromSelection.js +5 -1
  508. package/utilities/internal/getFragmentFromSelection.js.map +1 -1
  509. package/utilities/internal/getFragmentQueryDocument.d.ts +25 -23
  510. package/utilities/internal/getFragmentQueryDocument.js +25 -23
  511. package/utilities/internal/getFragmentQueryDocument.js.map +1 -1
  512. package/utilities/internal/getGraphQLErrorsFromResult.d.ts +5 -1
  513. package/utilities/internal/getGraphQLErrorsFromResult.js +5 -1
  514. package/utilities/internal/getGraphQLErrorsFromResult.js.map +1 -1
  515. package/utilities/internal/getMainDefinition.d.ts +8 -6
  516. package/utilities/internal/getMainDefinition.js +8 -6
  517. package/utilities/internal/getMainDefinition.js.map +1 -1
  518. package/utilities/internal/getMemoryInternals.d.ts +15 -9
  519. package/utilities/internal/getMemoryInternals.js +15 -9
  520. package/utilities/internal/getMemoryInternals.js.map +1 -1
  521. package/utilities/internal/getOperationDefinition.d.ts +5 -1
  522. package/utilities/internal/getOperationDefinition.js +5 -1
  523. package/utilities/internal/getOperationDefinition.js.map +1 -1
  524. package/utilities/internal/getOperationName.d.ts +6 -2
  525. package/utilities/internal/getOperationName.js +7 -5
  526. package/utilities/internal/getOperationName.js.map +1 -1
  527. package/utilities/internal/getQueryDefinition.d.ts +5 -1
  528. package/utilities/internal/getQueryDefinition.js +5 -1
  529. package/utilities/internal/getQueryDefinition.js.map +1 -1
  530. package/utilities/internal/getStoreKeyName.d.ts +5 -1
  531. package/utilities/internal/getStoreKeyName.js +5 -1
  532. package/utilities/internal/getStoreKeyName.js.map +1 -1
  533. package/utilities/internal/globals/global.js +2 -2
  534. package/utilities/internal/globals/global.js.map +1 -1
  535. package/utilities/internal/graphQLResultHasError.d.ts +5 -1
  536. package/utilities/internal/graphQLResultHasError.js +5 -1
  537. package/utilities/internal/graphQLResultHasError.js.map +1 -1
  538. package/utilities/internal/hasDirectives.d.ts +5 -1
  539. package/utilities/internal/hasDirectives.js +5 -1
  540. package/utilities/internal/hasDirectives.js.map +1 -1
  541. package/utilities/internal/hasForcedResolvers.d.ts +3 -0
  542. package/utilities/internal/hasForcedResolvers.js +20 -0
  543. package/utilities/internal/hasForcedResolvers.js.map +1 -0
  544. package/utilities/internal/index.d.ts +3 -1
  545. package/utilities/internal/index.js +3 -1
  546. package/utilities/internal/index.js.map +1 -1
  547. package/utilities/internal/isArray.d.ts +6 -4
  548. package/utilities/internal/isArray.js +6 -4
  549. package/utilities/internal/isArray.js.map +1 -1
  550. package/utilities/internal/isDocumentNode.d.ts +5 -1
  551. package/utilities/internal/isDocumentNode.js +5 -1
  552. package/utilities/internal/isDocumentNode.js.map +1 -1
  553. package/utilities/internal/isExecutionPatchIncrementalResult.d.ts +5 -1
  554. package/utilities/internal/isExecutionPatchIncrementalResult.js +5 -1
  555. package/utilities/internal/isExecutionPatchIncrementalResult.js.map +1 -1
  556. package/utilities/internal/isExecutionPatchIninitialResult.d.ts +5 -1
  557. package/utilities/internal/isExecutionPatchIninitialResult.js +5 -1
  558. package/utilities/internal/isExecutionPatchIninitialResult.js.map +1 -1
  559. package/utilities/internal/isExecutionPatchResult.d.ts +5 -1
  560. package/utilities/internal/isExecutionPatchResult.js +5 -1
  561. package/utilities/internal/isExecutionPatchResult.js.map +1 -1
  562. package/utilities/internal/isField.d.ts +5 -1
  563. package/utilities/internal/isField.js +5 -1
  564. package/utilities/internal/isField.js.map +1 -1
  565. package/utilities/internal/isNonEmptyArray.d.ts +5 -1
  566. package/utilities/internal/isNonEmptyArray.js +5 -1
  567. package/utilities/internal/isNonEmptyArray.js.map +1 -1
  568. package/utilities/internal/isNonNullObject.d.ts +5 -1
  569. package/utilities/internal/isNonNullObject.js +5 -1
  570. package/utilities/internal/isNonNullObject.js.map +1 -1
  571. package/utilities/internal/isPlainObject.d.ts +5 -1
  572. package/utilities/internal/isPlainObject.js +5 -1
  573. package/utilities/internal/isPlainObject.js.map +1 -1
  574. package/utilities/internal/makeReference.d.ts +5 -1
  575. package/utilities/internal/makeReference.js +5 -1
  576. package/utilities/internal/makeReference.js.map +1 -1
  577. package/utilities/internal/makeUniqueId.d.ts +7 -5
  578. package/utilities/internal/makeUniqueId.js +7 -5
  579. package/utilities/internal/makeUniqueId.js.map +1 -1
  580. package/utilities/internal/maybeDeepFreeze.d.ts +5 -1
  581. package/utilities/internal/maybeDeepFreeze.js +5 -1
  582. package/utilities/internal/maybeDeepFreeze.js.map +1 -1
  583. package/utilities/internal/mergeDeep.d.ts +5 -1
  584. package/utilities/internal/mergeDeep.js +5 -1
  585. package/utilities/internal/mergeDeep.js.map +1 -1
  586. package/utilities/internal/mergeDeepArray.d.ts +5 -1
  587. package/utilities/internal/mergeDeepArray.js +5 -1
  588. package/utilities/internal/mergeDeepArray.js.map +1 -1
  589. package/utilities/internal/mergeIncrementalData.d.ts +5 -1
  590. package/utilities/internal/mergeIncrementalData.js +5 -1
  591. package/utilities/internal/mergeIncrementalData.js.map +1 -1
  592. package/utilities/internal/mergeOptions.d.ts +5 -1
  593. package/utilities/internal/mergeOptions.js +5 -1
  594. package/utilities/internal/mergeOptions.js.map +1 -1
  595. package/utilities/internal/omitDeep.d.ts +5 -1
  596. package/utilities/internal/omitDeep.js +5 -1
  597. package/utilities/internal/omitDeep.js.map +1 -1
  598. package/utilities/internal/onAnyEvent.d.ts +5 -1
  599. package/utilities/internal/onAnyEvent.js +5 -1
  600. package/utilities/internal/onAnyEvent.js.map +1 -1
  601. package/utilities/internal/removeDirectivesFromDocument.d.ts +5 -1
  602. package/utilities/internal/removeDirectivesFromDocument.js +5 -1
  603. package/utilities/internal/removeDirectivesFromDocument.js.map +1 -1
  604. package/utilities/internal/resultKeyNameFromField.d.ts +5 -1
  605. package/utilities/internal/resultKeyNameFromField.js +5 -1
  606. package/utilities/internal/resultKeyNameFromField.js.map +1 -1
  607. package/utilities/internal/shouldInclude.d.ts +5 -1
  608. package/utilities/internal/shouldInclude.js +5 -1
  609. package/utilities/internal/shouldInclude.js.map +1 -1
  610. package/utilities/internal/storeKeyNameFromField.d.ts +5 -1
  611. package/utilities/internal/storeKeyNameFromField.js +5 -1
  612. package/utilities/internal/storeKeyNameFromField.js.map +1 -1
  613. package/utilities/internal/stringifyForDisplay.d.ts +5 -1
  614. package/utilities/internal/stringifyForDisplay.js +5 -1
  615. package/utilities/internal/stringifyForDisplay.js.map +1 -1
  616. package/utilities/internal/toQueryResult.d.ts +5 -1
  617. package/utilities/internal/toQueryResult.js +5 -1
  618. package/utilities/internal/toQueryResult.js.map +1 -1
  619. package/utilities/internal/types/DecoratedPromise.d.ts +5 -1
  620. package/utilities/internal/types/DeepOmit.d.ts +5 -1
  621. package/utilities/internal/types/DeepPartial.d.ts +5 -1
  622. package/utilities/internal/types/FragmentMap.d.ts +6 -4
  623. package/utilities/internal/types/FragmentMapFunction.d.ts +5 -1
  624. package/utilities/internal/types/FulfilledPromise.d.ts +5 -1
  625. package/utilities/internal/types/IsAny.d.ts +5 -1
  626. package/utilities/internal/types/PendingPromise.d.ts +5 -1
  627. package/utilities/internal/types/Prettify.d.ts +5 -1
  628. package/utilities/internal/types/Primitive.d.ts +5 -1
  629. package/utilities/internal/types/RejectedPromise.d.ts +5 -1
  630. package/utilities/internal/types/RemoveIndexSignature.d.ts +5 -1
  631. package/utilities/internal/types/VariablesOption.d.ts +5 -1
  632. package/utilities/internal/valueToObjectRepresentation.d.ts +5 -1
  633. package/utilities/internal/valueToObjectRepresentation.js +5 -1
  634. package/utilities/internal/valueToObjectRepresentation.js.map +1 -1
  635. package/version.js +1 -1
  636. package/__cjs/core/LocalState.cjs +0 -355
  637. package/__cjs/core/LocalState.cjs.map +0 -1
  638. package/__cjs/core/LocalState.d.cts +0 -53
  639. package/__cjs/testing/core/index.cjs +0 -20
  640. package/__cjs/testing/core/index.cjs.map +0 -1
  641. package/__cjs/testing/core/index.d.cts +0 -7
  642. package/__cjs/testing/core/mocking/mockClient.cjs +0 -17
  643. package/__cjs/testing/core/mocking/mockClient.cjs.map +0 -1
  644. package/__cjs/testing/core/mocking/mockClient.d.cts +0 -4
  645. package/__cjs/testing/core/wait.cjs.map +0 -1
  646. package/__cjs/testing/core/withConsoleSpy.cjs +0 -33
  647. package/__cjs/testing/core/withConsoleSpy.cjs.map +0 -1
  648. package/__cjs/testing/core/withConsoleSpy.d.cts +0 -7
  649. package/__cjs/utilities/internal/removeClientSetsFromDocument.cjs +0 -21
  650. package/__cjs/utilities/internal/removeClientSetsFromDocument.cjs.map +0 -1
  651. package/__cjs/utilities/internal/removeClientSetsFromDocument.d.cts +0 -8
  652. package/core/LocalState.d.ts +0 -53
  653. package/core/LocalState.js +0 -351
  654. package/core/LocalState.js.map +0 -1
  655. package/legacyEntryPoints/testing/core/core.cjs +0 -1
  656. package/legacyEntryPoints/testing/core/core.d.cts +0 -1
  657. package/legacyEntryPoints/testing/core/index.d.ts +0 -1
  658. package/legacyEntryPoints/testing/core/index.js +0 -1
  659. package/testing/core/index.d.ts +0 -7
  660. package/testing/core/index.js +0 -6
  661. package/testing/core/index.js.map +0 -1
  662. package/testing/core/mocking/mockClient.d.ts +0 -4
  663. package/testing/core/mocking/mockClient.js +0 -14
  664. package/testing/core/mocking/mockClient.js.map +0 -1
  665. package/testing/core/wait.js.map +0 -1
  666. package/testing/core/withConsoleSpy.d.ts +0 -7
  667. package/testing/core/withConsoleSpy.js +0 -28
  668. package/testing/core/withConsoleSpy.js.map +0 -1
  669. package/utilities/internal/removeClientSetsFromDocument.d.ts +0 -8
  670. package/utilities/internal/removeClientSetsFromDocument.js +0 -18
  671. package/utilities/internal/removeClientSetsFromDocument.js.map +0 -1
@@ -1,22 +1,35 @@
1
1
  import { equal } from "@wry/equality";
2
2
  import { Slot } from "optimism";
3
- import { BehaviorSubject, filter, lastValueFrom, tap } from "rxjs";
3
+ import { BehaviorSubject, lastValueFrom, Observable, Subject, tap } from "rxjs";
4
4
  import { __DEV__ } from "@apollo/client/utilities/environment";
5
- import { cloneDeep, compact, getOperationDefinition, getQueryDefinition, preventUnhandledRejection, toQueryResult, } from "@apollo/client/utilities/internal";
5
+ import { compact, filterMap, getOperationDefinition, getQueryDefinition, preventUnhandledRejection, toQueryResult, } from "@apollo/client/utilities/internal";
6
6
  import { invariant } from "@apollo/client/utilities/invariant";
7
7
  import { equalByQuery } from "./equalByQuery.js";
8
8
  import { isNetworkRequestInFlight, NetworkStatus } from "./networkStatus.js";
9
9
  const { assign, hasOwnProperty } = Object;
10
10
  const newNetworkStatusSymbol = Symbol();
11
- const uninitialized = {};
11
+ const uninitialized = {
12
+ loading: true,
13
+ networkStatus: NetworkStatus.loading,
14
+ data: undefined,
15
+ partial: true,
16
+ };
17
+ const empty = {
18
+ loading: false,
19
+ networkStatus: NetworkStatus.ready,
20
+ data: undefined,
21
+ partial: true,
22
+ };
12
23
  export class ObservableQuery {
13
24
  /**
14
- * @internal
15
- * A slot used by the `useQuery` hook to indicate that `client.watchQuery`
16
- * should not register the query immediately, but instead wait for the query to
17
- * be started registered with the `QueryManager` when `useSyncExternalStore`
18
- * actively subscribes to it.
19
- */
25
+ * @internal
26
+ * A slot used by the `useQuery` hook to indicate that `client.watchQuery`
27
+ * should not register the query immediately, but instead wait for the query to
28
+ * be started registered with the `QueryManager` when `useSyncExternalStore`
29
+ * actively subscribes to it.
30
+ *
31
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
32
+ */
20
33
  static inactiveOnCreation = new Slot();
21
34
  options;
22
35
  queryId;
@@ -34,23 +47,58 @@ export class ObservableQuery {
34
47
  get variables() {
35
48
  return this.options.variables;
36
49
  }
50
+ unsubscribeFromCache;
51
+ input;
37
52
  subject;
38
53
  observable;
39
54
  isTornDown;
40
55
  queryManager;
41
56
  subscriptions = new Set();
42
- waitForOwnResult;
43
- last;
57
+ /**
58
+ * If an `ObservableQuery` is created with a `network-only` fetch policy,
59
+ * it should actually start receiving cache updates, but not before it has
60
+ * received the first result from the network.
61
+ */
62
+ waitForNetworkResult;
44
63
  lastQuery;
45
64
  queryInfo;
46
65
  linkSubscription;
47
- linkObservable;
48
66
  pollingInfo;
49
- networkStatus;
67
+ get networkStatus() {
68
+ return this.subject.getValue().result.networkStatus;
69
+ }
50
70
  constructor({ queryManager, queryInfo, options, }) {
51
- this.networkStatus = NetworkStatus.loading;
52
71
  let startedInactive = ObservableQuery.inactiveOnCreation.getValue();
53
- this.subject = new BehaviorSubject(uninitialized);
72
+ // related classes
73
+ this.queryInfo = queryInfo;
74
+ this.queryManager = queryManager;
75
+ // active state
76
+ this.waitForNetworkResult = options.fetchPolicy === "network-only";
77
+ this.isTornDown = false;
78
+ this.subscribeToMore = this.subscribeToMore.bind(this);
79
+ this.maskResult = this.maskResult.bind(this);
80
+ const { watchQuery: { fetchPolicy: defaultFetchPolicy = "cache-first" } = {}, } = queryManager.defaultOptions;
81
+ const { fetchPolicy = defaultFetchPolicy,
82
+ // Make sure we don't store "standby" as the initialFetchPolicy.
83
+ initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
84
+ this.lastQuery = options.query;
85
+ this.options = {
86
+ ...options,
87
+ // Remember the initial options.fetchPolicy so we can revert back to this
88
+ // policy when variables change. This information can also be specified
89
+ // (or overridden) by providing options.initialFetchPolicy explicitly.
90
+ initialFetchPolicy,
91
+ // This ensures this.options.fetchPolicy always has a string value, in
92
+ // case options.fetchPolicy was not provided.
93
+ fetchPolicy,
94
+ variables: this.getVariablesWithDefaults(options.variables),
95
+ };
96
+ this.subject = new BehaviorSubject({
97
+ query: this.query,
98
+ variables: this.variables,
99
+ result: uninitialized,
100
+ meta: {},
101
+ });
54
102
  this.observable = this.subject.pipe(tap({
55
103
  subscribe: () => {
56
104
  if (startedInactive) {
@@ -58,22 +106,6 @@ export class ObservableQuery {
58
106
  startedInactive = false;
59
107
  }
60
108
  if (!this.subject.observed) {
61
- if (this.subject.value === uninitialized) {
62
- // Emitting a value in the `subscribe` callback of `tap` gives
63
- // the subject a chance to save this initial result without
64
- // emitting the placeholder value since this callback is executed
65
- // before `tap` subscribes to the source observable (the subject).
66
- // `reobserve` also has the chance to update this value if it
67
- // synchronously emits one (usually due to reporting a cache
68
- // value).
69
- //
70
- // We don't initialize the `BehaviorSubject` with
71
- // `getInitialResult` because its possible the cache might have
72
- // updated between when the `ObservableQuery` was instantiated and
73
- // when it is subscribed to. Updating the value here ensures we
74
- // report the most up-to-date result from the cache.
75
- this.subject.next(this.getInitialResult());
76
- }
77
109
  this.reobserve();
78
110
  // TODO: See if we can rework updatePolling to better handle this.
79
111
  // reobserve calls updatePolling but this `subscribe` callback is
@@ -88,45 +120,53 @@ export class ObservableQuery {
88
120
  this.tearDownQuery();
89
121
  }
90
122
  },
91
- }), filter((result) => {
92
- return (this.options.fetchPolicy !== "standby" &&
93
- (this.options.notifyOnNetworkStatusChange ||
94
- !result.loading ||
95
- // data could be defined for cache-and-network fetch policies
96
- // when emitting the cache result while loading the network result
97
- !!result.data));
98
- }));
123
+ }), filterMap(({ query, variables, result: current, meta }, context) => {
124
+ const { shouldEmit } = meta;
125
+ if (current === uninitialized) {
126
+ // reset internal state after `ObservableQuery.reset()`
127
+ context.previous = undefined;
128
+ context.previousVariables = undefined;
129
+ }
130
+ if (this.options.fetchPolicy === "standby" ||
131
+ shouldEmit === 2 /* EmitBehavior.never */)
132
+ return;
133
+ if (shouldEmit === 1 /* EmitBehavior.force */)
134
+ return emit();
135
+ const { previous, previousVariables } = context;
136
+ if (previous) {
137
+ const documentInfo = this.queryManager.getDocumentInfo(query);
138
+ const dataMasking = this.queryManager.dataMasking;
139
+ const maskedQuery = dataMasking ? documentInfo.nonReactiveQuery : query;
140
+ const resultIsEqual = dataMasking || documentInfo.hasNonreactiveDirective ?
141
+ equalByQuery(maskedQuery, previous, current, variables)
142
+ : equal(previous, current);
143
+ if (resultIsEqual && equal(previousVariables, variables)) {
144
+ return;
145
+ }
146
+ }
147
+ if (shouldEmit === 3 /* EmitBehavior.networkStatusChange */ &&
148
+ (!this.options.notifyOnNetworkStatusChange ||
149
+ equal(previous, current))) {
150
+ return;
151
+ }
152
+ return emit();
153
+ function emit() {
154
+ context.previous = current;
155
+ context.previousVariables = variables;
156
+ return current;
157
+ }
158
+ }, () => ({})));
99
159
  this["@@observable"] = () => this;
100
160
  if (Symbol.observable) {
101
161
  this[Symbol.observable] = () => this;
102
162
  }
103
163
  this.pipe = this.observable.pipe.bind(this.observable);
104
164
  this.subscribe = this.observable.subscribe.bind(this.observable);
105
- // related classes
106
- this.queryInfo = queryInfo;
107
- this.queryManager = queryManager;
108
- // active state
109
- this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy);
110
- this.isTornDown = false;
111
- this.subscribe = this.subscribe.bind(this);
112
- this.subscribeToMore = this.subscribeToMore.bind(this);
113
- this.maskResult = this.maskResult.bind(this);
114
- const { watchQuery: { fetchPolicy: defaultFetchPolicy = "cache-first" } = {}, } = queryManager.defaultOptions;
115
- const { fetchPolicy = defaultFetchPolicy,
116
- // Make sure we don't store "standby" as the initialFetchPolicy.
117
- initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
118
- this.lastQuery = options.query;
119
- this.options = {
120
- ...options,
121
- // Remember the initial options.fetchPolicy so we can revert back to this
122
- // policy when variables change. This information can also be specified
123
- // (or overridden) by providing options.initialFetchPolicy explicitly.
124
- initialFetchPolicy,
125
- // This ensures this.options.fetchPolicy always has a string value, in
126
- // case options.fetchPolicy was not provided.
127
- fetchPolicy,
128
- variables: this.getVariablesWithDefaults(options.variables),
129
- };
165
+ this.input = new Subject();
166
+ // we want to feed many streams into `this.subject`, but none of them should
167
+ // be able to close `this.input`
168
+ this.input.complete = () => { };
169
+ this.input.pipe(this.operator).subscribe(this.subject);
130
170
  this.queryId = queryInfo.queryId || queryManager.generateQueryId();
131
171
  const opDef = getOperationDefinition(this.query);
132
172
  this.queryName = opDef && opDef.name && opDef.name.value;
@@ -138,14 +178,26 @@ export class ObservableQuery {
138
178
  pipe;
139
179
  [Symbol.observable];
140
180
  ["@@observable"];
141
- /** @internal */
181
+ /**
182
+ * @internal
183
+ *
184
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
185
+ */
142
186
  resetDiff() {
143
187
  this.queryInfo.resetDiff();
144
188
  }
145
- getInitialResult() {
189
+ getCacheDiff({ optimistic = true } = {}) {
190
+ return this.queryManager.cache.diff({
191
+ query: this.query,
192
+ variables: this.variables,
193
+ returnPartialData: true,
194
+ optimistic,
195
+ });
196
+ }
197
+ getInitialResult(initialFetchPolicy) {
146
198
  const fetchPolicy = this.queryManager.prioritizeCacheValues ?
147
199
  "cache-first"
148
- : this.options.fetchPolicy;
200
+ : initialFetchPolicy || this.options.fetchPolicy;
149
201
  const defaultResult = {
150
202
  data: undefined,
151
203
  loading: true,
@@ -153,7 +205,7 @@ export class ObservableQuery {
153
205
  partial: true,
154
206
  };
155
207
  const cacheResult = () => {
156
- const diff = this.queryInfo.getDiff();
208
+ const diff = this.getCacheDiff();
157
209
  return this.maskResult({
158
210
  data:
159
211
  // TODO: queryInfo.getDiff should handle this since cache.diff returns a
@@ -186,118 +238,97 @@ export class ObservableQuery {
186
238
  return defaultResult;
187
239
  }
188
240
  }
189
- getCurrentFullResult(saveAsLastResult = true) {
190
- // Use the last result as long as the variables match this.variables.
191
- const lastResult = this.getLastResult(true);
192
- const networkStatus = this.networkStatus;
193
- const result = {
194
- data: undefined,
195
- partial: true,
196
- ...lastResult,
197
- loading: isNetworkRequestInFlight(networkStatus),
198
- networkStatus,
199
- };
200
- let { fetchPolicy = "cache-first" } = this.options;
201
- const { prioritizeCacheValues } = this.queryManager;
202
- if (prioritizeCacheValues) {
203
- fetchPolicy = "cache-first";
204
- }
205
- if (
206
- // These fetch policies should never deliver data from the cache, unless
207
- // redelivering a previously delivered result.
208
- skipCacheDataFor(fetchPolicy) ||
209
- // If this.options.query has @client(always: true) fields, we cannot
210
- // trust diff.result, since it was read from the cache without running
211
- // local resolvers (and it's too late to run resolvers now, since we must
212
- // return a result synchronously).
213
- this.queryManager.getDocumentInfo(this.query).hasForcedResolvers) {
214
- // Fall through.
215
- }
216
- else if (this.waitForOwnResult && !prioritizeCacheValues) {
217
- // This would usually be a part of `QueryInfo.getDiff()`.
218
- // which we skip in the waitForOwnResult case since we are not
219
- // interested in the diff.
220
- this.queryInfo["updateWatch"]();
241
+ resubscribeCache() {
242
+ const { variables, fetchPolicy } = this.options;
243
+ const query = this.query;
244
+ const shouldUnsubscribe = fetchPolicy === "standby" ||
245
+ fetchPolicy === "no-cache" ||
246
+ this.waitForNetworkResult;
247
+ const shouldResubscribe = !isEqualQuery({ query, variables }, this.unsubscribeFromCache) &&
248
+ !this.waitForNetworkResult;
249
+ if (shouldUnsubscribe || shouldResubscribe) {
250
+ this.unsubscribeFromCache?.();
221
251
  }
222
- else {
223
- const diff = this.queryInfo.getDiff();
224
- result.partial = !diff.complete;
225
- if (diff.complete || this.options.returnPartialData) {
226
- result.data = diff.result;
227
- }
228
- if (result.data === null) {
229
- result.data = void 0;
230
- }
231
- if (diff.complete) {
232
- // If the diff is complete, and we're using a FetchPolicy that
233
- // terminates after a complete cache read, we can assume the next result
234
- // we receive will have NetworkStatus.ready and !loading.
235
- if (diff.complete &&
236
- result.networkStatus === NetworkStatus.loading &&
237
- (fetchPolicy === "cache-first" || fetchPolicy === "cache-only")) {
238
- result.networkStatus = NetworkStatus.ready;
239
- result.loading = false;
252
+ if (shouldUnsubscribe || !shouldResubscribe) {
253
+ return;
254
+ }
255
+ const watch = {
256
+ query,
257
+ variables,
258
+ optimistic: true,
259
+ watcher: this,
260
+ callback: (diff) => {
261
+ const info = this.queryManager.getDocumentInfo(query);
262
+ if (info.hasClientExports || info.hasForcedResolvers) {
263
+ // If this is not set to something different than `diff`, we will
264
+ // not be notified about future cache changes with an equal `diff`.
265
+ // That would be the case if we are working with client-only fields
266
+ // that are forced or with `exports` fields that might change, causing
267
+ // local resovlers to return a new result.
268
+ // This is based on an implementation detail of `InMemoryCache`, which
269
+ // is not optimal - but the only alternative to this would be to
270
+ // resubscribe to the cache asynchonouly, which would bear the risk of
271
+ // missing further synchronous updates.
272
+ watch.lastDiff = undefined;
240
273
  }
241
- }
242
- // We need to check for both both `error` and `errors` field because there
243
- // are cases where sometimes `error` is set, but not `errors` and
244
- // vice-versa. This will be updated in the next major version when
245
- // `errors` is deprecated in favor of `error`.
246
- if (result.networkStatus === NetworkStatus.ready && result.error) {
247
- result.networkStatus = NetworkStatus.error;
248
- }
249
- if (__DEV__ &&
250
- !diff.complete &&
251
- !result.loading &&
252
- !result.data &&
253
- !result.error) {
254
- logMissingFieldErrors(diff.missing);
255
- }
274
+ if (watch.lastOwnDiff === diff) {
275
+ // skip cache updates that were caused by our own writes
276
+ return;
277
+ }
278
+ const { result: previousResult } = this.subject.getValue();
279
+ if (!diff.complete &&
280
+ // If we are trying to deliver an incomplete cache result, we avoid
281
+ // reporting it if the query has errored, otherwise we let the broadcast try
282
+ // and repair the partial result by refetching the query. This check avoids
283
+ // a situation where a query that errors and another succeeds with
284
+ // overlapping data does not report the partial data result to the errored
285
+ // query.
286
+ //
287
+ // See https://github.com/apollographql/apollo-client/issues/11400 for more
288
+ // information on this issue.
289
+ (previousResult.error ||
290
+ // Prevent to schedule a notify directly after the `ObservableQuery`
291
+ // has been `reset` (which will set the `previousResult` to `uninitialized` or `empty`)
292
+ // as in those cases, `resetCache` will manually call `refetch` with more intentional timing.
293
+ previousResult === uninitialized ||
294
+ previousResult === empty)) {
295
+ return;
296
+ }
297
+ if (!equal(previousResult.data, diff.result)) {
298
+ this.scheduleNotify();
299
+ }
300
+ },
301
+ };
302
+ const cancelWatch = this.queryManager.cache.watch(watch);
303
+ this.unsubscribeFromCache = Object.assign(() => {
304
+ this.unsubscribeFromCache = undefined;
305
+ cancelWatch();
306
+ }, { query, variables });
307
+ }
308
+ stableLastResult;
309
+ getCurrentResult() {
310
+ const { result: current } = this.subject.getValue();
311
+ let value = (
312
+ // if the `current` result is in an error state, we will always return that
313
+ // error state, even if we have no observers
314
+ (current.networkStatus === NetworkStatus.error ||
315
+ // if we have observers, we are watching the cache and
316
+ // this.subject.getValue() will always be up to date
317
+ this.hasObservers() || // if we are using a `no-cache` fetch policy in which case this
318
+ // `ObservableQuery` cannot have been updated from the outside - in
319
+ // that case, we prefer to keep the current value
320
+ this.options.fetchPolicy === "no-cache")) ?
321
+ current
322
+ // otherwise, the `current` value might be outdated due to missed
323
+ // external updates - calculate it again
324
+ : this.getInitialResult();
325
+ if (value === uninitialized) {
326
+ value = this.getInitialResult();
256
327
  }
257
- if (saveAsLastResult) {
258
- this.updateLastResult(result);
259
- }
260
- return result;
261
- }
262
- getCurrentResult(saveAsLastResult = true) {
263
- return this.maskResult(this.getCurrentFullResult(saveAsLastResult));
264
- }
265
- // Compares newResult to the snapshot we took of this.lastResult when it was
266
- // first received.
267
- isDifferentFromLastResult(newResult, variables) {
268
- if (!this.last) {
269
- return true;
270
- }
271
- const documentInfo = this.queryManager.getDocumentInfo(this.query);
272
- const dataMasking = this.queryManager.dataMasking;
273
- const query = dataMasking ? documentInfo.nonReactiveQuery : this.query;
274
- const resultIsDifferent = dataMasking || documentInfo.hasNonreactiveDirective ?
275
- !equalByQuery(query, this.last.result, newResult, this.variables)
276
- : !equal(this.last.result, newResult);
277
- return (resultIsDifferent || (variables && !equal(this.last.variables, variables)));
278
- }
279
- getLast(key, variablesMustMatch) {
280
- const last = this.last;
281
- if (last &&
282
- last[key] &&
283
- (!variablesMustMatch || equal(last.variables, this.variables))) {
284
- return last[key];
285
- }
286
- }
287
- // TODO: Consider deprecating this function
288
- getLastResult(variablesMustMatch) {
289
- return this.getLast("result", variablesMustMatch);
290
- }
291
- // TODO: Consider deprecating this function
292
- getLastError(variablesMustMatch) {
293
- return this.getLast("error", variablesMustMatch);
294
- }
295
- // TODO: Consider deprecating this function
296
- resetLastResults() {
297
- delete this.last;
298
- // TODO: This will need to be removed when tearing down an ObservableQuery
299
- // since the observable will terminate.
300
- this.isTornDown = false;
328
+ if (!equal(this.stableLastResult, value)) {
329
+ this.stableLastResult = value;
330
+ }
331
+ return this.stableLastResult;
301
332
  }
302
333
  /**
303
334
  * Update the variables of this observable query, and fetch the new results.
@@ -325,7 +356,7 @@ export class ObservableQuery {
325
356
  const queryDef = getQueryDefinition(this.query);
326
357
  const vars = queryDef.variableDefinitions;
327
358
  if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
328
- __DEV__ && invariant.warn(69, variables, queryDef.name?.value || queryDef);
359
+ __DEV__ && invariant.warn(77, variables, queryDef.name?.value || queryDef);
329
360
  }
330
361
  }
331
362
  if (variables && !equal(this.variables, variables)) {
@@ -372,26 +403,27 @@ export class ObservableQuery {
372
403
  fetchMoreOptions.query ?
373
404
  this.transformDocument(this.options.query)
374
405
  : combinedOptions.query;
375
- // Simulate a loading result for the original query with
376
- // result.networkStatus === NetworkStatus.fetchMore.
377
- const originalNetworkStatus = this.networkStatus;
378
- this.networkStatus = NetworkStatus.fetchMore;
379
- if (combinedOptions.notifyOnNetworkStatusChange) {
380
- this.observe();
381
- }
382
- const updatedQuerySet = new Set();
406
+ let wasUpdated = false;
383
407
  const updateQuery = fetchMoreOptions?.updateQuery;
384
408
  const isCached = this.options.fetchPolicy !== "no-cache";
385
409
  if (!isCached) {
386
- invariant(updateQuery, 70);
410
+ invariant(updateQuery, 78);
387
411
  }
412
+ const { finalize, pushNotification } = this.pushOperation(NetworkStatus.fetchMore);
413
+ pushNotification({
414
+ source: "newNetworkStatus",
415
+ kind: "N",
416
+ value: {},
417
+ }, { shouldEmit: 3 /* EmitBehavior.networkStatusChange */ });
388
418
  return this.queryManager
389
419
  .fetchQuery(qid, combinedOptions, NetworkStatus.fetchMore)
390
420
  .then((fetchMoreResult) => {
391
421
  this.queryManager.removeQuery(qid);
392
- if (this.networkStatus === NetworkStatus.fetchMore) {
393
- this.networkStatus = originalNetworkStatus;
394
- }
422
+ // disable the `fetchMore` override that is currently active
423
+ // the next updates caused by this should not be `fetchMore` anymore,
424
+ // but `ready` or whatever other calculated loading state is currently
425
+ // appropriate
426
+ finalize();
395
427
  if (isCached) {
396
428
  // Performing this cache update inside a cache.batch transaction ensures
397
429
  // any affected cache.watch watchers are notified at most once about any
@@ -426,9 +458,9 @@ export class ObservableQuery {
426
458
  }
427
459
  },
428
460
  onWatchUpdated: (watch) => {
429
- // Record the DocumentNode associated with any watched query whose
430
- // data were updated by the cache writes above.
431
- updatedQuerySet.add(watch.query);
461
+ if (watch.watcher === this) {
462
+ wasUpdated = true;
463
+ }
432
464
  },
433
465
  });
434
466
  }
@@ -447,28 +479,40 @@ export class ObservableQuery {
447
479
  // adjustment to the types on `updateQuery` since that function
448
480
  // expects that the first argument always contains previous result
449
481
  // data, but not `undefined`.
450
- const lastResult = this.getLast("result");
482
+ const lastResult = this.getCurrentResult();
451
483
  const data = updateQuery(lastResult.data, {
452
484
  fetchMoreResult: fetchMoreResult.data,
453
485
  variables: combinedOptions.variables,
454
486
  });
455
- this.reportResult({
456
- ...lastResult,
457
- networkStatus: originalNetworkStatus,
458
- loading: isNetworkRequestInFlight(originalNetworkStatus),
459
- data: data,
460
- }, this.variables);
487
+ // was reportResult
488
+ pushNotification({
489
+ kind: "N",
490
+ value: {
491
+ ...lastResult,
492
+ networkStatus: NetworkStatus.ready,
493
+ // will be overwritten anyways, just here for types sake
494
+ loading: false,
495
+ data: data,
496
+ },
497
+ source: "network",
498
+ });
461
499
  }
462
500
  return this.maskResult(fetchMoreResult);
463
501
  })
464
502
  .finally(() => {
503
+ // call `finalize` a second time in case the `.then` case above was not reached
504
+ finalize();
465
505
  // In case the cache writes above did not generate a broadcast
466
506
  // notification (which would have been intercepted by onWatchUpdated),
467
507
  // likely because the written data were the same as what was already in
468
508
  // the cache, we still want fetchMore to deliver its final loading:false
469
509
  // result with the unchanged data.
470
- if (isCached && !updatedQuerySet.has(this.query)) {
471
- this.reobserveCacheFirst();
510
+ if (isCached && !wasUpdated) {
511
+ pushNotification({
512
+ kind: "N",
513
+ source: "newNetworkStatus",
514
+ value: {},
515
+ }, { shouldEmit: 1 /* EmitBehavior.force */ });
472
516
  }
473
517
  });
474
518
  }
@@ -496,7 +540,7 @@ export class ObservableQuery {
496
540
  onError(error);
497
541
  }
498
542
  else {
499
- __DEV__ && invariant.error(71, error);
543
+ __DEV__ && invariant.error(79, error);
500
544
  }
501
545
  return;
502
546
  }
@@ -515,7 +559,11 @@ export class ObservableQuery {
515
559
  }
516
560
  };
517
561
  }
518
- /** @internal */
562
+ /**
563
+ * @internal
564
+ *
565
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
566
+ */
519
567
  silentSetOptions(newOptions) {
520
568
  const mergedOptions = compact(this.options, newOptions || {});
521
569
  assign(this.options, mergedOptions);
@@ -544,12 +592,12 @@ export class ObservableQuery {
544
592
  // If we have no observers, then we don't actually want to make a network
545
593
  // request. As soon as someone observes the query, the request will kick
546
594
  // off. For now, we just store any changes. (See #1077)
547
- return toQueryResult(this.subject.getValue());
595
+ return toQueryResult(this.getCurrentResult());
548
596
  }
549
597
  this.options.variables = variables;
550
598
  // See comment above
551
599
  if (!this.hasObservers()) {
552
- return toQueryResult(this.subject.getValue());
600
+ return toQueryResult(this.getCurrentResult());
553
601
  }
554
602
  return this.reobserve({
555
603
  // Reset options.fetchPolicy to its original value.
@@ -565,12 +613,7 @@ export class ObservableQuery {
565
613
  */
566
614
  updateQuery(mapFn) {
567
615
  const { queryManager } = this;
568
- const { result, complete } = queryManager.cache.diff({
569
- query: this.options.query,
570
- variables: this.variables,
571
- returnPartialData: true,
572
- optimistic: false,
573
- });
616
+ const { result, complete } = this.getCacheDiff({ optimistic: false });
574
617
  const newResult = mapFn(result, {
575
618
  variables: this.variables,
576
619
  complete: !!complete,
@@ -633,12 +676,95 @@ export class ObservableQuery {
633
676
  }
634
677
  return options.fetchPolicy;
635
678
  }
636
- fetch(options, newNetworkStatus, emitLoadingState, query) {
679
+ fetch(options, networkStatus, fetchQuery) {
637
680
  // TODO Make sure we update the networkStatus (and infer fetchVariables)
638
681
  // before actually committing to the fetch.
682
+ const initialFetchPolicy = this.options.fetchPolicy;
639
683
  const queryInfo = this.queryManager.getOrCreateQuery(this.queryId);
640
684
  queryInfo.setObservableQuery(this);
641
- return this.queryManager.fetchObservableWithInfo(queryInfo, options, newNetworkStatus, query, emitLoadingState);
685
+ options.context ??= {};
686
+ let synchronouslyEmitted = false;
687
+ const onCacheHit = () => {
688
+ synchronouslyEmitted = true;
689
+ };
690
+ const fetchQueryOperator = // we cannot use `tap` here, since it allows only for a "before subscription"
691
+
692
+ // hook with `subscribe` and we care for "directly before and after subscription"
693
+ (source) => new Observable((subscriber) => {
694
+ try {
695
+ return source.subscribe({
696
+ next(value) {
697
+ synchronouslyEmitted = true;
698
+ subscriber.next(value);
699
+ },
700
+ error: (error) => subscriber.error(error),
701
+ complete: () => subscriber.complete(),
702
+ });
703
+ }
704
+ finally {
705
+ if (!synchronouslyEmitted && this.activeOperations.has(operation)) {
706
+ operation.override = networkStatus;
707
+ this.input.next({
708
+ kind: "N",
709
+ source: "newNetworkStatus",
710
+ value: {
711
+ resetError: true,
712
+ },
713
+ query,
714
+ variables,
715
+ meta: {
716
+ shouldEmit: 3 /* EmitBehavior.networkStatusChange */,
717
+ /*
718
+ * The moment this notification is emitted, `nextFetchPolicy`
719
+ * might already have switched from a `network-only` to a
720
+ * `cache-something` policy, so we want to ensure that the
721
+ * loading state emit doesn't accidentally read from the cache
722
+ * in those cases.
723
+ */
724
+ fetchPolicy: initialFetchPolicy,
725
+ },
726
+ });
727
+ }
728
+ }
729
+ });
730
+ const { observable, fromLink } = this.queryManager.fetchObservableWithInfo(queryInfo, options, { networkStatus, query: fetchQuery, onCacheHit, fetchQueryOperator });
731
+ // track query and variables from the start of the operation
732
+ const { query, variables } = this;
733
+ const operation = {
734
+ abort: () => subscription.unsubscribe(),
735
+ query,
736
+ variables,
737
+ };
738
+ this.activeOperations.add(operation);
739
+ let forceFirstValueEmit = networkStatus == NetworkStatus.refetch ||
740
+ networkStatus == NetworkStatus.setVariables;
741
+ const subscription = observable
742
+ .pipe(tap({
743
+ next: (notification) => {
744
+ if (notification.source === "newNetworkStatus" ||
745
+ (notification.kind === "N" && notification.value.loading)) {
746
+ operation.override = networkStatus;
747
+ }
748
+ else {
749
+ delete operation.override;
750
+ }
751
+ },
752
+ finalize: () => this.activeOperations.delete(operation),
753
+ }))
754
+ .subscribe({
755
+ next: (value) => {
756
+ const meta = {};
757
+ if (forceFirstValueEmit &&
758
+ value.kind === "N" &&
759
+ "loading" in value.value &&
760
+ !value.value.loading) {
761
+ forceFirstValueEmit = false;
762
+ meta.shouldEmit = 1 /* EmitBehavior.force */;
763
+ }
764
+ this.input.next({ ...value, query, variables, meta });
765
+ },
766
+ });
767
+ return { fromLink, subscription, observable };
642
768
  }
643
769
  // Turns polling on or off based on this.options.pollInterval.
644
770
  updatePolling() {
@@ -654,7 +780,7 @@ export class ObservableQuery {
654
780
  if (pollingInfo && pollingInfo.interval === pollInterval) {
655
781
  return;
656
782
  }
657
- invariant(pollInterval, 72);
783
+ invariant(pollInterval, 80);
658
784
  const info = pollingInfo || (this.pollingInfo = {});
659
785
  info.interval = pollInterval;
660
786
  const maybeFetch = () => {
@@ -693,20 +819,6 @@ export class ObservableQuery {
693
819
  delete this.pollingInfo;
694
820
  }
695
821
  }
696
- updateLastResult(newResult, variables = this.variables) {
697
- let error = this.getLastError();
698
- // Preserve this.last.error unless the variables have changed.
699
- if (error && this.last && !equal(variables, this.last.variables)) {
700
- error = void 0;
701
- }
702
- return (this.last = {
703
- result: this.queryManager.assumeImmutableResults ?
704
- newResult
705
- : cloneDeep(newResult),
706
- variables,
707
- ...(error ? { error } : null),
708
- });
709
- }
710
822
  /**
711
823
  * Reevaluate the query, optionally against new options. New options will be
712
824
  * merged with the current options when given.
@@ -721,12 +833,9 @@ export class ObservableQuery {
721
833
  }
722
834
  const useDisposableObservable =
723
835
  // Refetching uses a disposable Observable to allow refetches using different
724
- // options/variables, without permanently altering the options of the
836
+ // options, without permanently altering the options of the
725
837
  // original ObservableQuery.
726
838
  newNetworkStatus === NetworkStatus.refetch ||
727
- // The fetchMore method does not actually call the reobserve method, but,
728
- // if it did, it would definitely use a disposable Observable.
729
- newNetworkStatus === NetworkStatus.fetchMore ||
730
839
  // Polling uses a disposable Observable so the polling options (which force
731
840
  // fetchPolicy to be "network-only" or "no-cache") won't override the original options.
732
841
  newNetworkStatus === NetworkStatus.poll;
@@ -795,47 +904,27 @@ export class ObservableQuery {
795
904
  if (options.fetchPolicy === "standby") {
796
905
  this.cancelPolling();
797
906
  }
798
- this.networkStatus = newNetworkStatus;
799
- this.waitForOwnResult &&= skipCacheDataFor(options.fetchPolicy);
800
- const finishWaitingForOwnResult = () => {
801
- if (this.linkObservable === observable) {
802
- this.waitForOwnResult = false;
803
- }
804
- };
805
- const variables = { ...options.variables };
806
- const { notifyOnNetworkStatusChange = true } = options;
807
- const { observable, fromLink } = this.fetch(options, newNetworkStatus, notifyOnNetworkStatusChange &&
808
- oldNetworkStatus !== newNetworkStatus &&
809
- isNetworkRequestInFlight(newNetworkStatus), query);
810
- const observer = {
811
- next: (result) => {
812
- if (equal(this.variables, variables)) {
813
- finishWaitingForOwnResult();
814
- this.reportResult(result, variables);
815
- }
816
- },
817
- error: (error) => {
818
- if (equal(this.variables, variables)) {
819
- finishWaitingForOwnResult();
820
- this.reportError(error, variables);
821
- }
822
- },
823
- };
907
+ this.resubscribeCache();
908
+ const { subscription, observable, fromLink } = this.fetch(options, newNetworkStatus, query);
824
909
  if (!useDisposableObservable && (fromLink || !this.linkSubscription)) {
825
910
  if (this.linkSubscription) {
826
911
  this.linkSubscription.unsubscribe();
827
912
  }
828
- this.linkObservable = observable;
829
- this.linkSubscription = observable.subscribe(observer);
830
- }
831
- else {
832
- observable.subscribe(observer);
913
+ this.linkSubscription = subscription;
833
914
  }
834
915
  return preventUnhandledRejection(
835
916
  // Note: lastValueFrom will create a separate subscription to the
836
917
  // observable which means that terminating this ObservableQuery will not
837
918
  // cancel the request from the link chain.
838
- lastValueFrom(observable, {
919
+ lastValueFrom(observable.pipe(filterMap((value) => {
920
+ switch (value.kind) {
921
+ case "E":
922
+ throw value.error;
923
+ case "N":
924
+ if (value.source !== "newNetworkStatus")
925
+ return value.value;
926
+ }
927
+ })), {
839
928
  // This default value should only be used when using a `fetchPolicy` of
840
929
  // `standby` since that fetch policy completes without emitting a
841
930
  // result. Since we are converting this to a QueryResult type, we
@@ -843,54 +932,16 @@ export class ObservableQuery {
843
932
  defaultValue: { data: undefined },
844
933
  }).then((result) => toQueryResult(this.maskResult(result))));
845
934
  }
846
- // (Re)deliver the current result to this.observers without applying fetch
847
- // policies or making network requests.
848
- observe() {
849
- this.reportResult(
850
- // Passing false is important so that this.getCurrentResult doesn't
851
- // save the fetchMore result as this.lastResult, causing it to be
852
- // ignored due to the this.isDifferentFromLastResult check in
853
- // this.reportResult.
854
- this.getCurrentFullResult(false), this.variables);
855
- }
856
- reportResult(result, variables) {
857
- const lastError = this.getLastError();
858
- const isDifferent = this.isDifferentFromLastResult(result, variables);
859
- // Update the last result even when isDifferentFromLastResult returns false,
860
- // because the query may be using the @nonreactive directive, and we want to
861
- // save the the latest version of any nonreactive subtrees (in case
862
- // getCurrentResult is called), even though we skip broadcasting changes.
863
- this.updateLastResult(result, variables);
864
- this.networkStatus = result.networkStatus;
865
- if (lastError || isDifferent) {
866
- this.subject.next(this.maskResult(result));
867
- }
868
- }
869
- reportError(error, variables) {
870
- // Since we don't get the current result on errors, only the error, we
871
- // must mirror the updates that occur in QueryStore.markQueryError here
872
- const errorResult = {
873
- data: undefined,
874
- partial: true,
875
- ...this.getLastResult(),
876
- error,
877
- networkStatus: NetworkStatus.error,
878
- loading: false,
879
- };
880
- this.updateLastResult(errorResult, variables);
881
- this.networkStatus = NetworkStatus.error;
882
- this.last.error = error;
883
- this.subject.next(errorResult);
884
- }
885
935
  hasObservers() {
886
936
  return this.subject.observed;
887
937
  }
888
938
  tearDownQuery() {
889
939
  if (this.isTornDown)
890
940
  return;
891
- if (this.linkObservable && this.linkSubscription) {
941
+ this.resetNotifications();
942
+ this.unsubscribeFromCache?.();
943
+ if (this.linkSubscription) {
892
944
  this.linkSubscription.unsubscribe();
893
- delete this.linkObservable;
894
945
  delete this.linkSubscription;
895
946
  }
896
947
  this.stopPolling();
@@ -899,6 +950,7 @@ export class ObservableQuery {
899
950
  this.subscriptions.clear();
900
951
  this.queryManager.removeQuery(this.queryId);
901
952
  this.isTornDown = true;
953
+ this.abortActiveOperations();
902
954
  }
903
955
  transformDocument(document) {
904
956
  return this.queryManager.transform(document);
@@ -918,57 +970,231 @@ export class ObservableQuery {
918
970
  }
919
971
  dirty = false;
920
972
  notifyTimeout;
921
- /** @internal */
973
+ /**
974
+ * @internal
975
+ *
976
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
977
+ */
922
978
  resetNotifications() {
923
- this.cancelNotifyTimeout();
924
- this.dirty = false;
925
- }
926
- cancelNotifyTimeout() {
927
979
  if (this.notifyTimeout) {
928
980
  clearTimeout(this.notifyTimeout);
929
981
  this.notifyTimeout = void 0;
930
982
  }
983
+ this.dirty = false;
931
984
  }
932
- /** @internal */
985
+ /**
986
+ * @internal
987
+ *
988
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
989
+ */
933
990
  scheduleNotify() {
934
991
  if (this.dirty)
935
992
  return;
936
993
  this.dirty = true;
937
994
  if (!this.notifyTimeout) {
938
- this.notifyTimeout = setTimeout(() => this.notify(), 0);
995
+ this.notifyTimeout = setTimeout(() => this.notify(true), 0);
939
996
  }
940
997
  }
941
- /** @internal */
942
- notify() {
943
- this.cancelNotifyTimeout();
944
- if (this.dirty) {
945
- if (this.options.fetchPolicy == "cache-only" ||
998
+ /**
999
+ * @internal
1000
+ *
1001
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
1002
+ */
1003
+ notify(scheduled = false) {
1004
+ if (!scheduled) {
1005
+ // For queries with client exports or forced resolvers, we don't want to
1006
+ // synchronously reobserve the cache on broadcast,
1007
+ // but actually wait for the `scheduleNotify` timeout triggered by the
1008
+ // `cache.watch` callback from `resubscribeCache`.
1009
+ const info = this.queryManager.getDocumentInfo(this.query);
1010
+ if (info.hasClientExports || info.hasForcedResolvers) {
1011
+ return;
1012
+ }
1013
+ }
1014
+ const { dirty } = this;
1015
+ this.resetNotifications();
1016
+ if (dirty &&
1017
+ (this.options.fetchPolicy == "cache-only" ||
946
1018
  this.options.fetchPolicy == "cache-and-network" ||
947
- !isNetworkRequestInFlight(this.networkStatus)) {
948
- const diff = this.queryInfo.getDiff();
949
- if (diff.fromOptimisticTransaction) {
950
- // If this diff came from an optimistic transaction, deliver the
951
- // current cache data to the ObservableQuery, but don't perform a
952
- // reobservation, since oq.reobserveCacheFirst might make a network
953
- // request, and we never want to trigger network requests in the
954
- // middle of optimistic updates.
955
- this.observe();
956
- }
957
- else {
958
- // Otherwise, make the ObservableQuery "reobserve" the latest data
959
- // using a temporary fetch policy of "cache-first", so complete cache
960
- // results have a chance to be delivered without triggering additional
961
- // network requests, even when options.fetchPolicy is "network-only"
962
- // or "cache-and-network". All other fetch policies are preserved by
963
- // this method, and are handled by calling oq.reobserve(). If this
964
- // reobservation is spurious, isDifferentFromLastResult still has a
965
- // chance to catch it before delivery to ObservableQuery subscribers.
966
- this.reobserveCacheFirst();
967
- }
1019
+ !this.activeOperations.size)) {
1020
+ const diff = this.getCacheDiff();
1021
+ if (
1022
+ // `fromOptimisticTransaction` is not avaiable through the `cache.diff`
1023
+ // code path, so we need to check it this way
1024
+ equal(diff.result, this.getCacheDiff({ optimistic: false }).result)) {
1025
+ //If this diff did not come from an optimistic transaction
1026
+ // make the ObservableQuery "reobserve" the latest data
1027
+ // using a temporary fetch policy of "cache-first", so complete cache
1028
+ // results have a chance to be delivered without triggering additional
1029
+ // network requests, even when options.fetchPolicy is "network-only"
1030
+ // or "cache-and-network". All other fetch policies are preserved by
1031
+ // this method, and are handled by calling oq.reobserve(). If this
1032
+ // reobservation is spurious, distinctUntilChanged still has a
1033
+ // chance to catch it before delivery to ObservableQuery subscribers.
1034
+ this.reobserveCacheFirst();
1035
+ }
1036
+ else {
1037
+ // If this diff came from an optimistic transaction, deliver the
1038
+ // current cache data to the ObservableQuery, but don't perform a
1039
+ // reobservation, since oq.reobserveCacheFirst might make a network
1040
+ // request, and we never want to trigger network requests in the
1041
+ // middle of optimistic updates.
1042
+ this.input.next({
1043
+ kind: "N",
1044
+ value: {
1045
+ data: diff.result,
1046
+ networkStatus: NetworkStatus.ready,
1047
+ loading: false,
1048
+ error: undefined,
1049
+ partial: !diff.complete,
1050
+ },
1051
+ source: "cache",
1052
+ query: this.query,
1053
+ variables: this.variables,
1054
+ meta: {},
1055
+ });
968
1056
  }
969
1057
  }
970
- this.dirty = false;
971
1058
  }
1059
+ activeOperations = new Set();
1060
+ pushOperation(networkStatus) {
1061
+ let aborted = false;
1062
+ // track query and variables from the start of the operation
1063
+ const { query, variables } = this;
1064
+ const finalize = () => {
1065
+ this.activeOperations.delete(operation);
1066
+ };
1067
+ const operation = {
1068
+ override: networkStatus,
1069
+ abort: () => {
1070
+ aborted = true;
1071
+ finalize();
1072
+ },
1073
+ query,
1074
+ variables,
1075
+ };
1076
+ this.activeOperations.add(operation);
1077
+ return {
1078
+ finalize,
1079
+ pushNotification: (notification, additionalMeta) => {
1080
+ if (!aborted) {
1081
+ this.input.next({
1082
+ ...notification,
1083
+ query,
1084
+ variables,
1085
+ meta: { ...additionalMeta },
1086
+ });
1087
+ }
1088
+ },
1089
+ };
1090
+ }
1091
+ calculateNetworkStatus(baseNetworkStatus) {
1092
+ // in the future, this could be more complex logic, e.g. "refetch" and
1093
+ // "fetchMore" having priority over "polling" or "loading" network statuses
1094
+ // as for now we just take the "latest" operation that is still active,
1095
+ // as that lines up best with previous behavior[]
1096
+ const operation = Array.from(this.activeOperations.values()).findLast((operation) => isEqualQuery(operation, this) && operation.override !== undefined);
1097
+ return operation?.override ?? baseNetworkStatus;
1098
+ }
1099
+ abortActiveOperations() {
1100
+ this.activeOperations.forEach((operation) => operation.abort());
1101
+ }
1102
+ /**
1103
+ * @internal
1104
+ * Called from `clearStore`.
1105
+ * * resets the query to its initial state
1106
+ * * cancels all active operations and their subscriptions
1107
+ *
1108
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
1109
+ */
1110
+ reset() {
1111
+ // exception for cache-only queries - we reset them into a "ready" state
1112
+ // as we won't trigger a refetch for them
1113
+ const resetToEmpty = this.options.fetchPolicy === "cache-only";
1114
+ this.setResult(resetToEmpty ? empty : uninitialized, {
1115
+ shouldEmit: resetToEmpty ? 1 /* EmitBehavior.force */ : 2 /* EmitBehavior.never */,
1116
+ });
1117
+ this.abortActiveOperations();
1118
+ }
1119
+ /**
1120
+ * @internal
1121
+ *
1122
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
1123
+ */
1124
+ setResult(result, additionalMeta) {
1125
+ this.input.next({
1126
+ source: "setResult",
1127
+ kind: "N",
1128
+ value: result,
1129
+ query: this.query,
1130
+ variables: this.variables,
1131
+ meta: { ...additionalMeta },
1132
+ });
1133
+ }
1134
+ operator = filterMap((notification) => {
1135
+ const { query, variables, meta } = notification;
1136
+ if (notification.source === "setResult") {
1137
+ return { query, variables, result: notification.value, meta };
1138
+ }
1139
+ if (notification.kind === "C" || !isEqualQuery(notification, this)) {
1140
+ return;
1141
+ }
1142
+ let result;
1143
+ const previous = this.subject.getValue();
1144
+ if (notification.source === "cache") {
1145
+ result = notification.value;
1146
+ if (result.networkStatus === NetworkStatus.ready &&
1147
+ result.partial &&
1148
+ (!this.options.returnPartialData ||
1149
+ previous.result.networkStatus === NetworkStatus.error) &&
1150
+ this.options.fetchPolicy !== "cache-only") {
1151
+ return;
1152
+ }
1153
+ }
1154
+ else if (notification.source === "network") {
1155
+ if (this.waitForNetworkResult) {
1156
+ this.waitForNetworkResult = false;
1157
+ this.resubscribeCache();
1158
+ }
1159
+ result =
1160
+ notification.kind === "E" ?
1161
+ {
1162
+ data: undefined,
1163
+ partial: true,
1164
+ ...(isEqualQuery(previous, notification) ? previous.result : {}),
1165
+ error: notification.error,
1166
+ networkStatus: NetworkStatus.error,
1167
+ loading: false,
1168
+ }
1169
+ : notification.value;
1170
+ if (result.error) {
1171
+ meta.shouldEmit = 1 /* EmitBehavior.force */;
1172
+ }
1173
+ }
1174
+ else if (notification.source === "newNetworkStatus") {
1175
+ const baseResult = isEqualQuery(previous, notification) ?
1176
+ previous.result
1177
+ : this.getInitialResult(meta.fetchPolicy);
1178
+ const { resetError } = notification.value;
1179
+ const error = resetError ? undefined : baseResult.error;
1180
+ const networkStatus = error ? NetworkStatus.error : NetworkStatus.ready;
1181
+ result = {
1182
+ ...baseResult,
1183
+ error,
1184
+ networkStatus,
1185
+ };
1186
+ }
1187
+ // every code path until here should have either returned or set a result,
1188
+ // but typescript needs a little help
1189
+ invariant(result);
1190
+ // normalize result shape
1191
+ if (!result.error)
1192
+ delete result.error;
1193
+ result.networkStatus = this.calculateNetworkStatus(result.networkStatus);
1194
+ result.loading = isNetworkRequestInFlight(result.networkStatus);
1195
+ result = this.maskResult(result);
1196
+ return { query, variables, result, meta };
1197
+ });
972
1198
  // Reobserve with fetchPolicy effectively set to "cache-first", triggering
973
1199
  // delivery of any new data from the cache, possibly falling back to the network
974
1200
  // if any cache data are missing. This allows _complete_ cache results to be
@@ -1005,12 +1231,10 @@ export class ObservableQuery {
1005
1231
  }
1006
1232
  export function logMissingFieldErrors(missing) {
1007
1233
  if (__DEV__ && missing) {
1008
- __DEV__ && invariant.debug(73, missing);
1234
+ __DEV__ && invariant.debug(81, missing);
1009
1235
  }
1010
1236
  }
1011
- function skipCacheDataFor(fetchPolicy /* `undefined` would mean `"cache-first"` */) {
1012
- return (fetchPolicy === "network-only" ||
1013
- fetchPolicy === "no-cache" ||
1014
- fetchPolicy === "standby");
1237
+ function isEqualQuery(a, b) {
1238
+ return !!(a && b && a.query === b.query && equal(a.variables, b.variables));
1015
1239
  }
1016
1240
  //# sourceMappingURL=ObservableQuery.js.map