@apollo/client 4.0.0-alpha.1 → 4.0.0-alpha.11

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 (893) hide show
  1. package/.changeset/afraid-grapes-call.md +5 -0
  2. package/.changeset/afraid-moons-arrive.md +5 -0
  3. package/.changeset/beige-mirrors-talk.md +15 -0
  4. package/.changeset/cool-kiwis-hunt.md +15 -0
  5. package/.changeset/cuddly-spiders-tie.md +5 -0
  6. package/.changeset/dirty-eagles-poke.md +5 -0
  7. package/.changeset/early-eggs-develop.md +22 -0
  8. package/.changeset/eighty-squids-fix.md +15 -0
  9. package/.changeset/eleven-kangaroos-jump.md +5 -0
  10. package/.changeset/forty-shrimps-fry.md +5 -0
  11. package/.changeset/forty-tomatoes-punch.md +5 -0
  12. package/.changeset/four-countries-clean.md +24 -0
  13. package/.changeset/four-ghosts-watch.md +5 -0
  14. package/.changeset/funny-jeans-invent.md +16 -0
  15. package/.changeset/funny-terms-deny.md +5 -0
  16. package/.changeset/fuzzy-tips-sit.md +5 -0
  17. package/.changeset/gentle-badgers-train.md +5 -0
  18. package/.changeset/gentle-waves-cough.md +5 -0
  19. package/.changeset/giant-apes-thank.md +5 -0
  20. package/.changeset/giant-bags-share.md +5 -0
  21. package/.changeset/gorgeous-chefs-tap.md +5 -0
  22. package/.changeset/great-roses-jog.md +15 -0
  23. package/.changeset/grumpy-vans-type.md +5 -0
  24. package/.changeset/hip-vans-act.md +5 -0
  25. package/.changeset/hungry-bikes-cough.md +5 -0
  26. package/.changeset/itchy-chefs-run.md +23 -0
  27. package/.changeset/khaki-keys-deliver.md +5 -0
  28. package/.changeset/khaki-spies-work.md +11 -0
  29. package/.changeset/large-plants-know.md +5 -0
  30. package/.changeset/light-apes-rescue.md +5 -0
  31. package/.changeset/little-spoons-kick.md +7 -0
  32. package/.changeset/loud-cows-raise.md +7 -0
  33. package/.changeset/lucky-sheep-explain.md +34 -0
  34. package/.changeset/many-buses-allow.md +5 -0
  35. package/.changeset/mean-lizards-think.md +5 -0
  36. package/.changeset/nervous-fireants-bow.md +5 -0
  37. package/.changeset/nervous-goats-allow.md +5 -0
  38. package/.changeset/nice-dots-matter.md +5 -0
  39. package/.changeset/ninety-bags-bake.md +17 -0
  40. package/.changeset/odd-chicken-hide.md +17 -0
  41. package/.changeset/odd-lemons-relax.md +5 -0
  42. package/.changeset/orange-suits-laugh.md +5 -0
  43. package/.changeset/perfect-ducks-reflect.md +12 -0
  44. package/.changeset/perfect-vans-give.md +7 -0
  45. package/.changeset/poor-eels-punch.md +5 -0
  46. package/.changeset/pre.json +70 -0
  47. package/.changeset/purple-bears-flash.md +5 -0
  48. package/.changeset/real-teachers-peel.md +5 -0
  49. package/.changeset/serious-moons-juggle.md +5 -0
  50. package/.changeset/seven-dragons-repair.md +14 -0
  51. package/.changeset/seven-schools-carry.md +5 -0
  52. package/.changeset/shaggy-pugs-add.md +52 -0
  53. package/.changeset/short-months-complain.md +5 -0
  54. package/.changeset/slimy-chicken-melt.md +5 -0
  55. package/.changeset/slimy-maps-press.md +5 -0
  56. package/.changeset/small-buttons-rhyme.md +5 -0
  57. package/.changeset/small-poems-rest.md +5 -0
  58. package/.changeset/swift-rivers-share.md +13 -0
  59. package/.changeset/tall-bikes-develop.md +5 -0
  60. package/.changeset/tame-points-work.md +11 -0
  61. package/.changeset/tender-swans-flash.md +16 -0
  62. package/.changeset/thick-books-grin.md +5 -0
  63. package/.changeset/thin-peas-hear.md +16 -0
  64. package/.changeset/tidy-pandas-punch.md +5 -0
  65. package/.changeset/tough-rockets-allow.md +5 -0
  66. package/.changeset/tricky-tables-shave.md +5 -0
  67. package/.changeset/unlucky-kiwis-sell.md +5 -0
  68. package/.changeset/warm-ties-sit.md +7 -0
  69. package/.changeset/wicked-forks-double.md +33 -0
  70. package/.changeset/young-phones-fold.md +5 -0
  71. package/.changeset/young-snails-grin.md +5 -0
  72. package/CHANGELOG.md +535 -0
  73. package/__cjs/cache/core/cache.cjs +2 -2
  74. package/__cjs/cache/core/cache.cjs.map +1 -1
  75. package/__cjs/cache/core/cache.d.cts +18 -18
  76. package/__cjs/cache/core/types/Cache.cjs.map +1 -1
  77. package/__cjs/cache/core/types/Cache.d.cts +9 -16
  78. package/__cjs/cache/core/types/DataProxy.d.cts +8 -23
  79. package/__cjs/cache/core/types/common.cjs +1 -0
  80. package/__cjs/cache/core/types/common.cjs.map +1 -1
  81. package/__cjs/cache/index.cjs +4 -4
  82. package/__cjs/cache/index.cjs.map +1 -1
  83. package/__cjs/cache/index.d.cts +3 -3
  84. package/__cjs/cache/inmemory/entityStore.cjs +9 -8
  85. package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
  86. package/__cjs/cache/inmemory/entityStore.d.cts +3 -2
  87. package/__cjs/cache/inmemory/fragmentRegistry.cjs +3 -3
  88. package/__cjs/cache/inmemory/fragmentRegistry.cjs.map +1 -1
  89. package/__cjs/cache/inmemory/helpers.cjs +0 -8
  90. package/__cjs/cache/inmemory/helpers.cjs.map +1 -1
  91. package/__cjs/cache/inmemory/helpers.d.cts +3 -4
  92. package/__cjs/cache/inmemory/inMemoryCache.cjs +4 -12
  93. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  94. package/__cjs/cache/inmemory/inMemoryCache.d.cts +8 -9
  95. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  96. package/__cjs/cache/inmemory/policies.cjs +9 -9
  97. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  98. package/__cjs/cache/inmemory/policies.d.cts +1 -1
  99. package/__cjs/cache/inmemory/reactiveVars.cjs.map +1 -1
  100. package/__cjs/cache/inmemory/reactiveVars.d.cts +7 -7
  101. package/__cjs/cache/inmemory/readFromStore.cjs +14 -56
  102. package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
  103. package/__cjs/cache/inmemory/readFromStore.d.cts +1 -6
  104. package/__cjs/cache/inmemory/types.d.cts +3 -17
  105. package/__cjs/cache/inmemory/writeToStore.cjs +8 -8
  106. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  107. package/__cjs/cache/inmemory/writeToStore.d.cts +2 -2
  108. package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs +6 -4
  109. package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs.map +1 -1
  110. package/__cjs/config/jest/areCombinedProtocolErrorsEqual.cjs +3 -3
  111. package/__cjs/config/jest/areCombinedProtocolErrorsEqual.cjs.map +1 -1
  112. package/__cjs/config/jest/areMissingFieldErrorsEqual.cjs +2 -3
  113. package/__cjs/config/jest/areMissingFieldErrorsEqual.cjs.map +1 -1
  114. package/__cjs/config/jest/areServerErrorsEqual.cjs +22 -0
  115. package/__cjs/config/jest/areServerErrorsEqual.cjs.map +1 -0
  116. package/__cjs/config/jest/areServerErrorsEqual.d.cts +3 -0
  117. package/__cjs/config/jest/resolver.cjs +11 -0
  118. package/__cjs/config/jest/resolver.cjs.map +1 -1
  119. package/__cjs/config/jest/setup.cjs +18 -1
  120. package/__cjs/config/jest/setup.cjs.map +1 -1
  121. package/__cjs/core/ApolloClient.cjs +37 -21
  122. package/__cjs/core/ApolloClient.cjs.map +1 -1
  123. package/__cjs/core/ApolloClient.d.cts +37 -27
  124. package/__cjs/core/LocalState.cjs +2 -3
  125. package/__cjs/core/LocalState.cjs.map +1 -1
  126. package/__cjs/core/LocalState.d.cts +7 -8
  127. package/__cjs/core/ObservableQuery.cjs +267 -103
  128. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  129. package/__cjs/core/ObservableQuery.d.cts +156 -17
  130. package/__cjs/core/QueryInfo.cjs +12 -86
  131. package/__cjs/core/QueryInfo.cjs.map +1 -1
  132. package/__cjs/core/QueryInfo.d.cts +2 -11
  133. package/__cjs/core/QueryManager.cjs +173 -128
  134. package/__cjs/core/QueryManager.cjs.map +1 -1
  135. package/__cjs/core/QueryManager.d.cts +51 -32
  136. package/__cjs/core/index.cjs +42 -21
  137. package/__cjs/core/index.cjs.map +1 -1
  138. package/__cjs/core/index.d.cts +12 -11
  139. package/__cjs/core/types.d.cts +65 -7
  140. package/__cjs/core/watchQueryOptions.d.cts +32 -119
  141. package/__cjs/errors/CombinedGraphQLErrors.cjs +30 -11
  142. package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
  143. package/__cjs/errors/CombinedGraphQLErrors.d.cts +21 -2
  144. package/__cjs/errors/CombinedProtocolErrors.cjs +13 -6
  145. package/__cjs/errors/CombinedProtocolErrors.cjs.map +1 -1
  146. package/__cjs/errors/CombinedProtocolErrors.d.cts +9 -0
  147. package/__cjs/errors/LinkError.cjs +20 -0
  148. package/__cjs/errors/LinkError.cjs.map +1 -0
  149. package/__cjs/errors/LinkError.d.cts +14 -0
  150. package/__cjs/errors/ServerError.cjs +6 -0
  151. package/__cjs/errors/ServerError.cjs.map +1 -1
  152. package/__cjs/errors/ServerError.d.cts +2 -0
  153. package/__cjs/errors/ServerParseError.cjs +6 -0
  154. package/__cjs/errors/ServerParseError.cjs.map +1 -1
  155. package/__cjs/errors/ServerParseError.d.cts +2 -0
  156. package/__cjs/errors/UnconventionalError.cjs +6 -0
  157. package/__cjs/errors/UnconventionalError.cjs.map +1 -1
  158. package/__cjs/errors/UnconventionalError.d.cts +2 -0
  159. package/__cjs/errors/index.cjs +19 -4
  160. package/__cjs/errors/index.cjs.map +1 -1
  161. package/__cjs/errors/index.d.cts +2 -3
  162. package/__cjs/errors/isErrorLike.cjs +12 -0
  163. package/__cjs/errors/isErrorLike.cjs.map +1 -0
  164. package/__cjs/errors/isErrorLike.d.cts +3 -0
  165. package/__cjs/errors/utils.cjs +18 -0
  166. package/__cjs/errors/utils.cjs.map +1 -0
  167. package/__cjs/errors/utils.d.cts +3 -0
  168. package/__cjs/invariantErrorCodes.cjs +131 -138
  169. package/__cjs/link/batch/index.cjs +4 -2
  170. package/__cjs/link/batch/index.cjs.map +1 -1
  171. package/__cjs/link/batch/index.d.cts +2 -1
  172. package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
  173. package/__cjs/link/batch-http/batchHttpLink.d.cts +3 -2
  174. package/__cjs/link/batch-http/index.cjs +3 -2
  175. package/__cjs/link/batch-http/index.cjs.map +1 -1
  176. package/__cjs/link/batch-http/index.d.cts +1 -1
  177. package/__cjs/link/context/index.cjs.map +1 -1
  178. package/__cjs/link/context/index.d.cts +2 -3
  179. package/__cjs/link/core/ApolloLink.cjs +4 -22
  180. package/__cjs/link/core/ApolloLink.cjs.map +1 -1
  181. package/__cjs/link/core/ApolloLink.d.cts +3 -5
  182. package/__cjs/link/core/index.cjs.map +1 -1
  183. package/__cjs/link/core/index.d.cts +1 -1
  184. package/__cjs/link/core/types.d.cts +15 -4
  185. package/__cjs/link/error/index.cjs +13 -28
  186. package/__cjs/link/error/index.cjs.map +1 -1
  187. package/__cjs/link/error/index.d.cts +4 -15
  188. package/__cjs/link/http/HttpLink.cjs.map +1 -1
  189. package/__cjs/link/http/HttpLink.d.cts +128 -3
  190. package/__cjs/link/http/checkFetcher.cjs +1 -1
  191. package/__cjs/link/http/createHttpLink.cjs +1 -1
  192. package/__cjs/link/http/createHttpLink.cjs.map +1 -1
  193. package/__cjs/link/http/createHttpLink.d.cts +3 -2
  194. package/__cjs/link/http/index.cjs.map +1 -1
  195. package/__cjs/link/http/index.d.cts +0 -1
  196. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
  197. package/__cjs/link/http/rewriteURIForGET.cjs.map +1 -1
  198. package/__cjs/link/http/rewriteURIForGET.d.cts +2 -2
  199. package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
  200. package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +7 -82
  201. package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
  202. package/__cjs/link/persisted-queries/index.cjs +3 -3
  203. package/__cjs/link/persisted-queries/index.cjs.map +1 -1
  204. package/__cjs/link/persisted-queries/index.d.cts +14 -3
  205. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +1 -1
  206. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
  207. package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +10 -1
  208. package/__cjs/link/retry/index.cjs +3 -2
  209. package/__cjs/link/retry/index.cjs.map +1 -1
  210. package/__cjs/link/retry/index.d.cts +1 -1
  211. package/__cjs/link/subscriptions/index.cjs +3 -1
  212. package/__cjs/link/subscriptions/index.cjs.map +1 -1
  213. package/__cjs/link/utils/createOperation.cjs +5 -1
  214. package/__cjs/link/utils/createOperation.cjs.map +1 -1
  215. package/__cjs/link/utils/createOperation.d.cts +2 -2
  216. package/__cjs/link/utils/validateOperation.cjs +1 -1
  217. package/__cjs/masking/maskDefinition.cjs +2 -2
  218. package/__cjs/masking/maskDefinition.cjs.map +1 -1
  219. package/__cjs/masking/maskDefinition.d.cts +1 -1
  220. package/__cjs/masking/maskFragment.cjs +2 -2
  221. package/__cjs/masking/maskFragment.cjs.map +1 -1
  222. package/__cjs/masking/maskFragment.d.cts +2 -2
  223. package/__cjs/masking/maskOperation.cjs +1 -1
  224. package/__cjs/masking/maskOperation.cjs.map +1 -1
  225. package/__cjs/masking/maskOperation.d.cts +2 -2
  226. package/__cjs/masking/utils.cjs +1 -1
  227. package/__cjs/react/context/ApolloConsumer.cjs +1 -1
  228. package/__cjs/react/context/ApolloConsumer.cjs.map +1 -1
  229. package/__cjs/react/context/ApolloConsumer.d.cts +7 -4
  230. package/__cjs/react/context/ApolloContext.cjs +1 -1
  231. package/__cjs/react/context/ApolloContext.cjs.map +1 -1
  232. package/__cjs/react/context/ApolloContext.d.cts +4 -4
  233. package/__cjs/react/context/ApolloProvider.cjs +1 -1
  234. package/__cjs/react/context/ApolloProvider.cjs.map +1 -1
  235. package/__cjs/react/context/ApolloProvider.d.cts +7 -5
  236. package/__cjs/react/hooks/internal/__use.d.cts +3 -1
  237. package/__cjs/react/hooks/internal/useIsomorphicLayoutEffect.d.cts +1 -1
  238. package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs +28 -0
  239. package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs.map +1 -0
  240. package/__cjs/react/hooks/internal/validateSuspenseHookOptions.d.cts +3 -0
  241. package/__cjs/react/hooks/internal/wrapHook.cjs +26 -5
  242. package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
  243. package/__cjs/react/hooks/internal/wrapHook.d.cts +7 -5
  244. package/__cjs/react/hooks/useApolloClient.cjs +2 -2
  245. package/__cjs/react/hooks/useApolloClient.cjs.map +1 -1
  246. package/__cjs/react/hooks/useApolloClient.d.cts +2 -2
  247. package/__cjs/react/hooks/useBackgroundQuery.cjs +2 -2
  248. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  249. package/__cjs/react/hooks/useBackgroundQuery.d.cts +143 -46
  250. package/__cjs/react/hooks/useFragment.cjs.map +1 -1
  251. package/__cjs/react/hooks/useFragment.d.cts +51 -26
  252. package/__cjs/react/hooks/useLazyQuery.cjs +31 -32
  253. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  254. package/__cjs/react/hooks/useLazyQuery.d.cts +278 -276
  255. package/__cjs/react/hooks/useLoadableQuery.cjs +21 -2
  256. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  257. package/__cjs/react/hooks/useLoadableQuery.d.cts +106 -34
  258. package/__cjs/react/hooks/useMutation.cjs +14 -21
  259. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  260. package/__cjs/react/hooks/useMutation.d.cts +231 -4
  261. package/__cjs/react/hooks/useQuery.cjs +87 -206
  262. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  263. package/__cjs/react/hooks/useQuery.d.cts +274 -4
  264. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  265. package/__cjs/react/hooks/useQueryRefHandlers.d.cts +23 -22
  266. package/__cjs/react/hooks/useReactiveVar.cjs.map +1 -1
  267. package/__cjs/react/hooks/useReactiveVar.d.cts +1 -1
  268. package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
  269. package/__cjs/react/hooks/useReadQuery.d.cts +27 -25
  270. package/__cjs/react/hooks/useSubscription.cjs +9 -60
  271. package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
  272. package/__cjs/react/hooks/useSubscription.d.cts +94 -3
  273. package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
  274. package/__cjs/react/hooks/useSuspenseFragment.d.cts +40 -38
  275. package/__cjs/react/hooks/useSuspenseQuery.cjs +7 -32
  276. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  277. package/__cjs/react/hooks/useSuspenseQuery.d.cts +199 -38
  278. package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
  279. package/__cjs/react/index.cjs +37 -11
  280. package/__cjs/react/index.cjs.map +1 -1
  281. package/__cjs/react/index.d.cts +22 -6
  282. package/__cjs/react/index.react-server.cjs +1 -5
  283. package/__cjs/react/index.react-server.cjs.map +1 -1
  284. package/__cjs/react/index.react-server.d.cts +0 -1
  285. package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
  286. package/__cjs/react/internal/cache/FragmentReference.d.cts +3 -3
  287. package/__cjs/react/internal/cache/QueryReference.cjs +3 -14
  288. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  289. package/__cjs/react/internal/cache/QueryReference.d.cts +7 -7
  290. package/__cjs/react/internal/cache/SuspenseCache.cjs.map +1 -1
  291. package/__cjs/react/internal/cache/SuspenseCache.d.cts +3 -3
  292. package/__cjs/react/internal/cache/getSuspenseCache.cjs.map +1 -1
  293. package/__cjs/react/internal/cache/getSuspenseCache.d.cts +4 -4
  294. package/__cjs/react/internal/index.cjs +3 -1
  295. package/__cjs/react/internal/index.cjs.map +1 -1
  296. package/__cjs/react/internal/index.d.cts +2 -0
  297. package/__cjs/react/internal/types.d.cts +9 -0
  298. package/__cjs/react/query-preloader/createQueryPreloader.cjs +1 -0
  299. package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
  300. package/__cjs/react/query-preloader/createQueryPreloader.d.cts +6 -45
  301. package/__cjs/react/ssr/getDataFromTree.cjs +24 -30
  302. package/__cjs/react/ssr/getDataFromTree.cjs.map +1 -1
  303. package/__cjs/react/ssr/getDataFromTree.d.cts +12 -1
  304. package/__cjs/react/ssr/index.cjs +3 -3
  305. package/__cjs/react/ssr/index.cjs.map +1 -1
  306. package/__cjs/react/ssr/index.d.cts +1 -1
  307. package/__cjs/react/ssr/prerenderStatic.cjs +151 -0
  308. package/__cjs/react/ssr/prerenderStatic.cjs.map +1 -0
  309. package/__cjs/react/ssr/prerenderStatic.d.cts +122 -0
  310. package/__cjs/react/ssr/renderToStringWithData.cjs +11 -5
  311. package/__cjs/react/ssr/renderToStringWithData.cjs.map +1 -1
  312. package/__cjs/react/ssr/renderToStringWithData.d.cts +5 -0
  313. package/__cjs/react/ssr/useSSRQuery.cjs +60 -0
  314. package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -0
  315. package/__cjs/react/ssr/useSSRQuery.d.cts +5 -0
  316. package/__cjs/{utilities/types/TODO.cjs → react/types/deprecated.cjs} +1 -1
  317. package/__cjs/react/types/deprecated.cjs.map +1 -0
  318. package/__cjs/react/types/deprecated.d.cts +75 -0
  319. package/__cjs/react/types/types.documentation.d.cts +6 -34
  320. package/__cjs/testing/core/index.cjs +6 -3
  321. package/__cjs/testing/core/index.cjs.map +1 -1
  322. package/__cjs/testing/core/index.d.cts +3 -3
  323. package/__cjs/testing/core/mocking/mockClient.cjs +3 -4
  324. package/__cjs/testing/core/mocking/mockClient.cjs.map +1 -1
  325. package/__cjs/testing/core/mocking/mockClient.d.cts +2 -3
  326. package/__cjs/testing/core/mocking/mockLink.cjs +118 -112
  327. package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
  328. package/__cjs/testing/core/mocking/mockLink.d.cts +26 -7
  329. package/__cjs/testing/experimental/createSchemaFetch.cjs +4 -4
  330. package/__cjs/testing/experimental/createSchemaFetch.cjs.map +1 -1
  331. package/__cjs/testing/experimental/createTestSchema.cjs.map +1 -1
  332. package/__cjs/testing/experimental/createTestSchema.d.cts +1 -1
  333. package/__cjs/testing/index.cjs +13 -2
  334. package/__cjs/testing/index.cjs.map +1 -1
  335. package/__cjs/testing/index.d.cts +2 -1
  336. package/__cjs/testing/internal/disposables/spyOnConsole.cjs +0 -1
  337. package/__cjs/testing/internal/disposables/spyOnConsole.cjs.map +1 -1
  338. package/__cjs/testing/internal/disposables/spyOnConsole.d.cts +0 -1
  339. package/__cjs/testing/internal/disposables/withProdMode.d.cts +1 -1
  340. package/__cjs/testing/internal/incremental.cjs.map +1 -1
  341. package/__cjs/testing/internal/incremental.d.cts +4 -3
  342. package/__cjs/testing/internal/index.cjs +17 -8
  343. package/__cjs/testing/internal/index.cjs.map +1 -1
  344. package/__cjs/testing/internal/index.d.cts +5 -3
  345. package/__cjs/testing/internal/link.cjs +16 -0
  346. package/__cjs/testing/internal/link.cjs.map +1 -0
  347. package/__cjs/testing/internal/link.d.cts +5 -0
  348. package/__cjs/testing/internal/renderHelpers.cjs.map +1 -1
  349. package/__cjs/testing/internal/renderHelpers.d.cts +3 -3
  350. package/__cjs/testing/internal/resetApolloContext.cjs +24 -0
  351. package/__cjs/testing/internal/resetApolloContext.cjs.map +1 -0
  352. package/__cjs/testing/internal/resetApolloContext.d.cts +10 -0
  353. package/__cjs/testing/internal/scenarios/index.cjs +9 -7
  354. package/__cjs/testing/internal/scenarios/index.cjs.map +1 -1
  355. package/__cjs/testing/internal/scenarios/index.d.cts +14 -5
  356. package/__cjs/testing/matchers/arrayWithLength.cjs +15 -0
  357. package/__cjs/testing/matchers/arrayWithLength.cjs.map +1 -0
  358. package/__cjs/testing/matchers/arrayWithLength.d.cts +3 -0
  359. package/__cjs/testing/matchers/index.cjs +6 -18
  360. package/__cjs/testing/matchers/index.cjs.map +1 -1
  361. package/__cjs/testing/matchers/isSameClient.cjs +19 -0
  362. package/__cjs/testing/matchers/isSameClient.cjs.map +1 -0
  363. package/__cjs/testing/matchers/isSameClient.d.cts +3 -0
  364. package/__cjs/testing/matchers/isSameObservableQuery.cjs +19 -0
  365. package/__cjs/testing/matchers/isSameObservableQuery.cjs.map +1 -0
  366. package/__cjs/testing/matchers/isSameObservableQuery.d.cts +3 -0
  367. package/__cjs/testing/matchers/toComplete.cjs.map +1 -1
  368. package/__cjs/testing/matchers/toEmitAnything.cjs.map +1 -1
  369. package/__cjs/testing/matchers/toEmitError.cjs.map +1 -1
  370. package/__cjs/testing/matchers/toEmitNext.cjs.map +1 -1
  371. package/__cjs/testing/matchers/{toEmitFetchResult.cjs → toEmitTypedValue.cjs} +9 -7
  372. package/__cjs/testing/matchers/toEmitTypedValue.cjs.map +1 -0
  373. package/__cjs/testing/matchers/{toEmitValueStrict.d.cts → toEmitTypedValue.d.cts} +2 -2
  374. package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.cjs +2 -2
  375. package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.cjs.map +1 -1
  376. package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.d.cts +1 -1
  377. package/__cjs/testing/matchers/toMatchDocument.cjs.map +1 -1
  378. package/__cjs/testing/matchers/toMatchDocument.d.cts +1 -1
  379. package/__cjs/testing/matchers/toStrictEqualTyped.cjs +32 -0
  380. package/__cjs/testing/matchers/toStrictEqualTyped.cjs.map +1 -0
  381. package/__cjs/testing/matchers/toStrictEqualTyped.d.cts +8 -0
  382. package/__cjs/testing/matchers/utils/getSerializableProperties.cjs +24 -0
  383. package/__cjs/testing/matchers/utils/getSerializableProperties.cjs.map +1 -0
  384. package/__cjs/testing/matchers/utils/getSerializableProperties.d.cts +4 -0
  385. package/__cjs/testing/react/MockedProvider.cjs +11 -7
  386. package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
  387. package/__cjs/testing/react/MockedProvider.d.cts +8 -6
  388. package/__cjs/utilities/caching/sizes.cjs +2 -2
  389. package/__cjs/utilities/caching/sizes.cjs.map +1 -1
  390. package/__cjs/utilities/caching/sizes.d.cts +2 -20
  391. package/__cjs/utilities/common/errorHandling.d.cts +1 -1
  392. package/__cjs/utilities/common/mergeOptions.cjs.map +1 -1
  393. package/__cjs/utilities/common/mergeOptions.d.cts +1 -1
  394. package/__cjs/utilities/graphql/getFromAST.cjs +15 -6
  395. package/__cjs/utilities/graphql/getFromAST.cjs.map +1 -1
  396. package/__cjs/utilities/graphql/getFromAST.d.cts +2 -2
  397. package/__cjs/utilities/graphql/operations.cjs.map +1 -1
  398. package/__cjs/utilities/graphql/operations.d.cts +1 -1
  399. package/__cjs/utilities/graphql/storeUtils.cjs +1 -1
  400. package/__cjs/utilities/graphql/transform.cjs +2 -2
  401. package/__cjs/utilities/index.cjs +39 -19
  402. package/__cjs/utilities/index.cjs.map +1 -1
  403. package/__cjs/utilities/index.d.cts +16 -15
  404. package/__cjs/utilities/internal/getMemoryInternals.cjs +0 -2
  405. package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
  406. package/__cjs/utilities/internal/getMemoryInternals.d.cts +1 -2
  407. package/__cjs/utilities/internal/index.cjs +3 -1
  408. package/__cjs/utilities/internal/index.cjs.map +1 -1
  409. package/__cjs/utilities/internal/index.d.cts +1 -0
  410. package/__cjs/utilities/internal/index.production.cjs +1 -0
  411. package/__cjs/utilities/internal/index.production.cjs.map +1 -1
  412. package/__cjs/utilities/internal/toQueryResult.cjs +13 -0
  413. package/__cjs/utilities/internal/toQueryResult.cjs.map +1 -0
  414. package/__cjs/utilities/internal/toQueryResult.d.cts +3 -0
  415. package/__cjs/utilities/invariant/index.development.cjs +1 -0
  416. package/__cjs/utilities/invariant/index.development.cjs.map +1 -1
  417. package/__cjs/utilities/subscriptions/relay/index.cjs +2 -2
  418. package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
  419. package/__cjs/utilities/subscriptions/relay/index.d.cts +1 -1
  420. package/__cjs/utilities/types/NoInfer.d.cts +1 -1
  421. package/__cjs/utilities/types/{OnlyRequiredProperties.cjs → VariablesOption.cjs} +1 -1
  422. package/__cjs/utilities/types/VariablesOption.cjs.map +1 -0
  423. package/__cjs/utilities/types/VariablesOption.d.cts +25 -0
  424. package/__cjs/version.cjs +1 -1
  425. package/__cjs/version.cjs.map +1 -1
  426. package/__cjs/version.d.cts +1 -1
  427. package/cache/core/cache.d.ts +18 -18
  428. package/cache/core/cache.js +1 -1
  429. package/cache/core/cache.js.map +1 -1
  430. package/cache/core/types/Cache.d.ts +9 -16
  431. package/cache/core/types/Cache.js.map +1 -1
  432. package/cache/core/types/DataProxy.d.ts +8 -23
  433. package/cache/core/types/common.js +1 -0
  434. package/cache/core/types/common.js.map +1 -1
  435. package/cache/index.d.ts +3 -3
  436. package/cache/index.js +1 -1
  437. package/cache/index.js.map +1 -1
  438. package/cache/inmemory/entityStore.d.ts +3 -2
  439. package/cache/inmemory/entityStore.js +9 -8
  440. package/cache/inmemory/entityStore.js.map +1 -1
  441. package/cache/inmemory/fragmentRegistry.js +1 -1
  442. package/cache/inmemory/fragmentRegistry.js.map +1 -1
  443. package/cache/inmemory/helpers.d.ts +0 -1
  444. package/cache/inmemory/helpers.js +0 -7
  445. package/cache/inmemory/helpers.js.map +1 -1
  446. package/cache/inmemory/inMemoryCache.d.ts +8 -9
  447. package/cache/inmemory/inMemoryCache.js +4 -12
  448. package/cache/inmemory/inMemoryCache.js.map +1 -1
  449. package/cache/inmemory/key-extractor.js +1 -1
  450. package/cache/inmemory/policies.d.ts +1 -1
  451. package/cache/inmemory/policies.js +9 -9
  452. package/cache/inmemory/policies.js.map +1 -1
  453. package/cache/inmemory/reactiveVars.d.ts +7 -7
  454. package/cache/inmemory/reactiveVars.js.map +1 -1
  455. package/cache/inmemory/readFromStore.d.ts +1 -6
  456. package/cache/inmemory/readFromStore.js +14 -56
  457. package/cache/inmemory/readFromStore.js.map +1 -1
  458. package/cache/inmemory/types.d.ts +3 -17
  459. package/cache/inmemory/writeToStore.d.ts +2 -2
  460. package/cache/inmemory/writeToStore.js +8 -8
  461. package/cache/inmemory/writeToStore.js.map +1 -1
  462. package/config/jest/areCombinedGraphQLErrorsEqual.js +6 -4
  463. package/config/jest/areCombinedGraphQLErrorsEqual.js.map +1 -1
  464. package/config/jest/areCombinedProtocolErrorsEqual.js +3 -3
  465. package/config/jest/areCombinedProtocolErrorsEqual.js.map +1 -1
  466. package/config/jest/areMissingFieldErrorsEqual.js +2 -3
  467. package/config/jest/areMissingFieldErrorsEqual.js.map +1 -1
  468. package/config/jest/areServerErrorsEqual.d.ts +3 -0
  469. package/config/jest/areServerErrorsEqual.js +18 -0
  470. package/config/jest/areServerErrorsEqual.js.map +1 -0
  471. package/config/jest/resolver.js +12 -1
  472. package/config/jest/resolver.js.map +1 -1
  473. package/config/jest/setup.js +19 -2
  474. package/config/jest/setup.js.map +1 -1
  475. package/core/ApolloClient.d.ts +37 -27
  476. package/core/ApolloClient.js +38 -22
  477. package/core/ApolloClient.js.map +1 -1
  478. package/core/LocalState.d.ts +5 -6
  479. package/core/LocalState.js +2 -3
  480. package/core/LocalState.js.map +1 -1
  481. package/core/ObservableQuery.d.ts +156 -17
  482. package/core/ObservableQuery.js +266 -101
  483. package/core/ObservableQuery.js.map +1 -1
  484. package/core/QueryInfo.d.ts +2 -11
  485. package/core/QueryInfo.js +12 -86
  486. package/core/QueryInfo.js.map +1 -1
  487. package/core/QueryManager.d.ts +38 -29
  488. package/core/QueryManager.js +176 -131
  489. package/core/QueryManager.js.map +1 -1
  490. package/core/index.d.ts +12 -11
  491. package/core/index.js +9 -6
  492. package/core/index.js.map +1 -1
  493. package/core/types.d.ts +65 -7
  494. package/core/watchQueryOptions.d.ts +32 -119
  495. package/errors/CombinedGraphQLErrors.d.ts +21 -2
  496. package/errors/CombinedGraphQLErrors.js +30 -11
  497. package/errors/CombinedGraphQLErrors.js.map +1 -1
  498. package/errors/CombinedProtocolErrors.d.ts +9 -0
  499. package/errors/CombinedProtocolErrors.js +13 -6
  500. package/errors/CombinedProtocolErrors.js.map +1 -1
  501. package/errors/LinkError.d.ts +14 -0
  502. package/errors/LinkError.js +16 -0
  503. package/errors/LinkError.js.map +1 -0
  504. package/errors/ServerError.d.ts +2 -0
  505. package/errors/ServerError.js +6 -0
  506. package/errors/ServerError.js.map +1 -1
  507. package/errors/ServerParseError.d.ts +2 -0
  508. package/errors/ServerParseError.js +6 -0
  509. package/errors/ServerParseError.js.map +1 -1
  510. package/errors/UnconventionalError.d.ts +2 -0
  511. package/errors/UnconventionalError.js +6 -0
  512. package/errors/UnconventionalError.js.map +1 -1
  513. package/errors/index.d.ts +2 -3
  514. package/errors/index.js +13 -1
  515. package/errors/index.js.map +1 -1
  516. package/errors/isErrorLike.d.ts +3 -0
  517. package/errors/isErrorLike.js +9 -0
  518. package/errors/isErrorLike.js.map +1 -0
  519. package/errors/utils.d.ts +3 -0
  520. package/errors/utils.js +14 -0
  521. package/errors/utils.js.map +1 -0
  522. package/invariantErrorCodes.js +131 -138
  523. package/legacyEntryPoints/testing/internal/index.d.ts +1 -0
  524. package/legacyEntryPoints/testing/internal/index.js +1 -0
  525. package/legacyEntryPoints/testing/internal/internal.cjs +1 -0
  526. package/legacyEntryPoints/testing/internal/internal.d.cts +1 -0
  527. package/link/batch/index.d.ts +2 -1
  528. package/link/batch/index.js +1 -1
  529. package/link/batch/index.js.map +1 -1
  530. package/link/batch-http/batchHttpLink.d.ts +3 -2
  531. package/link/batch-http/batchHttpLink.js.map +1 -1
  532. package/link/batch-http/index.d.ts +1 -1
  533. package/link/batch-http/index.js +1 -1
  534. package/link/batch-http/index.js.map +1 -1
  535. package/link/context/index.d.ts +2 -3
  536. package/link/context/index.js.map +1 -1
  537. package/link/core/ApolloLink.d.ts +3 -5
  538. package/link/core/ApolloLink.js +4 -22
  539. package/link/core/ApolloLink.js.map +1 -1
  540. package/link/core/index.d.ts +1 -1
  541. package/link/core/index.js.map +1 -1
  542. package/link/core/types.d.ts +15 -4
  543. package/link/error/index.d.ts +4 -15
  544. package/link/error/index.js +14 -29
  545. package/link/error/index.js.map +1 -1
  546. package/link/http/HttpLink.d.ts +128 -3
  547. package/link/http/HttpLink.js.map +1 -1
  548. package/link/http/checkFetcher.js +1 -1
  549. package/link/http/createHttpLink.d.ts +2 -2
  550. package/link/http/createHttpLink.js +1 -1
  551. package/link/http/createHttpLink.js.map +1 -1
  552. package/link/http/index.d.ts +0 -1
  553. package/link/http/index.js.map +1 -1
  554. package/link/http/parseAndCheckHttpResponse.js +1 -1
  555. package/link/http/rewriteURIForGET.d.ts +2 -2
  556. package/link/http/rewriteURIForGET.js.map +1 -1
  557. package/link/http/selectHttpOptionsAndBody.d.ts +7 -82
  558. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  559. package/link/http/serializeFetchParameter.js +1 -1
  560. package/link/persisted-queries/index.d.ts +2 -2
  561. package/link/persisted-queries/index.js +3 -3
  562. package/link/persisted-queries/index.js.map +1 -1
  563. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  564. package/link/retry/index.d.ts +1 -1
  565. package/link/retry/index.js +1 -1
  566. package/link/retry/index.js.map +1 -1
  567. package/link/subscriptions/index.js +3 -1
  568. package/link/subscriptions/index.js.map +1 -1
  569. package/link/utils/createOperation.d.ts +2 -2
  570. package/link/utils/createOperation.js +5 -1
  571. package/link/utils/createOperation.js.map +1 -1
  572. package/link/utils/validateOperation.js +1 -1
  573. package/masking/maskDefinition.d.ts +1 -1
  574. package/masking/maskDefinition.js +2 -2
  575. package/masking/maskDefinition.js.map +1 -1
  576. package/masking/maskFragment.d.ts +2 -2
  577. package/masking/maskFragment.js +2 -2
  578. package/masking/maskFragment.js.map +1 -1
  579. package/masking/maskOperation.d.ts +2 -2
  580. package/masking/maskOperation.js +1 -1
  581. package/masking/maskOperation.js.map +1 -1
  582. package/masking/utils.js +1 -1
  583. package/package.json +20 -40
  584. package/react/context/ApolloConsumer.d.ts +7 -4
  585. package/react/context/ApolloConsumer.js +1 -1
  586. package/react/context/ApolloConsumer.js.map +1 -1
  587. package/react/context/ApolloContext.d.ts +4 -4
  588. package/react/context/ApolloContext.js +1 -1
  589. package/react/context/ApolloContext.js.map +1 -1
  590. package/react/context/ApolloProvider.d.ts +7 -5
  591. package/react/context/ApolloProvider.js +1 -1
  592. package/react/context/ApolloProvider.js.map +1 -1
  593. package/react/hooks/internal/validateSuspenseHookOptions.d.ts +3 -0
  594. package/react/hooks/internal/validateSuspenseHookOptions.js +22 -0
  595. package/react/hooks/internal/validateSuspenseHookOptions.js.map +1 -0
  596. package/react/hooks/internal/wrapHook.d.ts +7 -5
  597. package/react/hooks/internal/wrapHook.js +24 -5
  598. package/react/hooks/internal/wrapHook.js.map +1 -1
  599. package/react/hooks/useApolloClient.d.ts +2 -2
  600. package/react/hooks/useApolloClient.js +1 -1
  601. package/react/hooks/useApolloClient.js.map +1 -1
  602. package/react/hooks/useBackgroundQuery.d.ts +143 -46
  603. package/react/hooks/useBackgroundQuery.js +2 -2
  604. package/react/hooks/useBackgroundQuery.js.map +1 -1
  605. package/react/hooks/useFragment.d.ts +51 -26
  606. package/react/hooks/useFragment.js.map +1 -1
  607. package/react/hooks/useLazyQuery.d.ts +278 -276
  608. package/react/hooks/useLazyQuery.js +30 -31
  609. package/react/hooks/useLazyQuery.js.map +1 -1
  610. package/react/hooks/useLoadableQuery.d.ts +106 -34
  611. package/react/hooks/useLoadableQuery.js +21 -2
  612. package/react/hooks/useLoadableQuery.js.map +1 -1
  613. package/react/hooks/useMutation.d.ts +231 -4
  614. package/react/hooks/useMutation.js +14 -21
  615. package/react/hooks/useMutation.js.map +1 -1
  616. package/react/hooks/useQuery.d.ts +274 -4
  617. package/react/hooks/useQuery.js +86 -205
  618. package/react/hooks/useQuery.js.map +1 -1
  619. package/react/hooks/useQueryRefHandlers.d.ts +23 -22
  620. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  621. package/react/hooks/useReactiveVar.d.ts +1 -1
  622. package/react/hooks/useReactiveVar.js.map +1 -1
  623. package/react/hooks/useReadQuery.d.ts +27 -25
  624. package/react/hooks/useReadQuery.js.map +1 -1
  625. package/react/hooks/useSubscription.d.ts +94 -9
  626. package/react/hooks/useSubscription.js +8 -56
  627. package/react/hooks/useSubscription.js.map +1 -1
  628. package/react/hooks/useSuspenseFragment.d.ts +40 -38
  629. package/react/hooks/useSuspenseFragment.js.map +1 -1
  630. package/react/hooks/useSuspenseQuery.d.ts +199 -38
  631. package/react/hooks/useSuspenseQuery.js +5 -26
  632. package/react/hooks/useSuspenseQuery.js.map +1 -1
  633. package/react/hooks/useSyncExternalStore.js +1 -1
  634. package/react/index.d.ts +22 -6
  635. package/react/index.js +18 -3
  636. package/react/index.js.map +1 -1
  637. package/react/index.react-server.d.ts +0 -1
  638. package/react/index.react-server.js +0 -1
  639. package/react/index.react-server.js.map +1 -1
  640. package/react/internal/cache/FragmentReference.d.ts +3 -3
  641. package/react/internal/cache/FragmentReference.js.map +1 -1
  642. package/react/internal/cache/QueryReference.d.ts +5 -5
  643. package/react/internal/cache/QueryReference.js +3 -14
  644. package/react/internal/cache/QueryReference.js.map +1 -1
  645. package/react/internal/cache/SuspenseCache.d.ts +3 -3
  646. package/react/internal/cache/SuspenseCache.js.map +1 -1
  647. package/react/internal/cache/getSuspenseCache.d.ts +3 -3
  648. package/react/internal/cache/getSuspenseCache.js.map +1 -1
  649. package/react/internal/index.d.ts +2 -0
  650. package/react/internal/index.js +2 -1
  651. package/react/internal/index.js.map +1 -1
  652. package/react/internal/types.d.ts +9 -0
  653. package/react/query-preloader/createQueryPreloader.d.ts +6 -45
  654. package/react/query-preloader/createQueryPreloader.js +1 -0
  655. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  656. package/react/ssr/getDataFromTree.d.ts +12 -1
  657. package/react/ssr/getDataFromTree.js +24 -29
  658. package/react/ssr/getDataFromTree.js.map +1 -1
  659. package/react/ssr/index.d.ts +1 -1
  660. package/react/ssr/index.js +1 -1
  661. package/react/ssr/index.js.map +1 -1
  662. package/react/ssr/prerenderStatic.d.ts +122 -0
  663. package/react/ssr/prerenderStatic.js +147 -0
  664. package/react/ssr/prerenderStatic.js.map +1 -0
  665. package/react/ssr/renderToStringWithData.d.ts +5 -0
  666. package/react/ssr/renderToStringWithData.js +11 -5
  667. package/react/ssr/renderToStringWithData.js.map +1 -1
  668. package/react/ssr/useSSRQuery.d.ts +5 -0
  669. package/react/ssr/useSSRQuery.js +56 -0
  670. package/react/ssr/useSSRQuery.js.map +1 -0
  671. package/react/types/deprecated.d.ts +75 -0
  672. package/react/types/deprecated.js +2 -0
  673. package/react/types/deprecated.js.map +1 -0
  674. package/react/types/types.documentation.d.ts +6 -34
  675. package/testing/core/index.d.ts +3 -3
  676. package/testing/core/index.js +2 -2
  677. package/testing/core/index.js.map +1 -1
  678. package/testing/core/mocking/mockClient.d.ts +2 -3
  679. package/testing/core/mocking/mockClient.js +2 -3
  680. package/testing/core/mocking/mockClient.js.map +1 -1
  681. package/testing/core/mocking/mockLink.d.ts +26 -7
  682. package/testing/core/mocking/mockLink.js +117 -113
  683. package/testing/core/mocking/mockLink.js.map +1 -1
  684. package/testing/experimental/createSchemaFetch.js +2 -2
  685. package/testing/experimental/createSchemaFetch.js.map +1 -1
  686. package/testing/experimental/createTestSchema.d.ts +1 -1
  687. package/testing/experimental/createTestSchema.js.map +1 -1
  688. package/testing/index.d.ts +2 -1
  689. package/testing/index.js +1 -1
  690. package/testing/index.js.map +1 -1
  691. package/testing/internal/disposables/spyOnConsole.d.ts +0 -1
  692. package/testing/internal/disposables/spyOnConsole.js +0 -1
  693. package/testing/internal/disposables/spyOnConsole.js.map +1 -1
  694. package/testing/internal/incremental.d.ts +1 -1
  695. package/testing/internal/incremental.js.map +1 -1
  696. package/testing/internal/index.d.ts +5 -3
  697. package/testing/internal/index.js +5 -3
  698. package/testing/internal/index.js.map +1 -1
  699. package/testing/internal/link.d.ts +5 -0
  700. package/testing/internal/link.js +12 -0
  701. package/testing/internal/link.js.map +1 -0
  702. package/testing/internal/renderHelpers.d.ts +3 -3
  703. package/testing/internal/renderHelpers.js.map +1 -1
  704. package/testing/internal/resetApolloContext.d.ts +10 -0
  705. package/testing/internal/resetApolloContext.js +20 -0
  706. package/testing/internal/resetApolloContext.js.map +1 -0
  707. package/testing/internal/scenarios/index.d.ts +6 -8
  708. package/testing/internal/scenarios/index.js +4 -2
  709. package/testing/internal/scenarios/index.js.map +1 -1
  710. package/testing/matchers/arrayWithLength.d.ts +3 -0
  711. package/testing/matchers/arrayWithLength.js +11 -0
  712. package/testing/matchers/arrayWithLength.js.map +1 -0
  713. package/testing/matchers/index.js +6 -18
  714. package/testing/matchers/index.js.map +1 -1
  715. package/testing/matchers/isSameClient.d.ts +3 -0
  716. package/testing/matchers/isSameClient.js +15 -0
  717. package/testing/matchers/isSameClient.js.map +1 -0
  718. package/testing/matchers/isSameObservableQuery.d.ts +3 -0
  719. package/testing/matchers/isSameObservableQuery.js +15 -0
  720. package/testing/matchers/isSameObservableQuery.js.map +1 -0
  721. package/testing/matchers/toComplete.js.map +1 -1
  722. package/testing/matchers/toEmitAnything.js.map +1 -1
  723. package/testing/matchers/toEmitError.js.map +1 -1
  724. package/testing/matchers/toEmitNext.js.map +1 -1
  725. package/testing/matchers/{toEmitValueStrict.d.ts → toEmitTypedValue.d.ts} +2 -2
  726. package/testing/matchers/{toEmitFetchResult.js → toEmitTypedValue.js} +7 -5
  727. package/testing/matchers/toEmitTypedValue.js.map +1 -0
  728. package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts +1 -1
  729. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js +1 -1
  730. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
  731. package/testing/matchers/toMatchDocument.d.ts +1 -1
  732. package/testing/matchers/toMatchDocument.js.map +1 -1
  733. package/testing/matchers/toStrictEqualTyped.d.ts +8 -0
  734. package/testing/matchers/toStrictEqualTyped.js +28 -0
  735. package/testing/matchers/toStrictEqualTyped.js.map +1 -0
  736. package/testing/matchers/utils/getSerializableProperties.d.ts +4 -0
  737. package/testing/matchers/utils/getSerializableProperties.js +21 -0
  738. package/testing/matchers/utils/getSerializableProperties.js.map +1 -0
  739. package/testing/react/MockedProvider.d.ts +8 -6
  740. package/testing/react/MockedProvider.js +8 -4
  741. package/testing/react/MockedProvider.js.map +1 -1
  742. package/utilities/caching/sizes.d.ts +2 -20
  743. package/utilities/caching/sizes.js +2 -2
  744. package/utilities/caching/sizes.js.map +1 -1
  745. package/utilities/common/mergeOptions.d.ts +1 -1
  746. package/utilities/common/mergeOptions.js.map +1 -1
  747. package/utilities/graphql/getFromAST.d.ts +2 -2
  748. package/utilities/graphql/getFromAST.js +15 -6
  749. package/utilities/graphql/getFromAST.js.map +1 -1
  750. package/utilities/graphql/operations.d.ts +1 -1
  751. package/utilities/graphql/operations.js.map +1 -1
  752. package/utilities/graphql/storeUtils.js +1 -1
  753. package/utilities/graphql/transform.js +2 -2
  754. package/utilities/index.d.ts +16 -15
  755. package/utilities/index.js +12 -12
  756. package/utilities/index.js.map +1 -1
  757. package/utilities/internal/getMemoryInternals.d.ts +0 -1
  758. package/utilities/internal/getMemoryInternals.js +0 -2
  759. package/utilities/internal/getMemoryInternals.js.map +1 -1
  760. package/utilities/internal/index.d.ts +1 -0
  761. package/utilities/internal/index.js +2 -1
  762. package/utilities/internal/index.js.map +1 -1
  763. package/utilities/internal/index.production.js +1 -0
  764. package/utilities/internal/index.production.js.map +1 -1
  765. package/utilities/internal/toQueryResult.d.ts +3 -0
  766. package/utilities/internal/toQueryResult.js +10 -0
  767. package/utilities/internal/toQueryResult.js.map +1 -0
  768. package/utilities/invariant/index.development.js +1 -0
  769. package/utilities/invariant/index.development.js.map +1 -1
  770. package/utilities/subscriptions/relay/index.d.ts +1 -1
  771. package/utilities/subscriptions/relay/index.js +1 -1
  772. package/utilities/subscriptions/relay/index.js.map +1 -1
  773. package/utilities/types/NoInfer.d.ts +1 -1
  774. package/utilities/types/VariablesOption.d.ts +25 -0
  775. package/utilities/types/VariablesOption.js +2 -0
  776. package/utilities/types/VariablesOption.js.map +1 -0
  777. package/version.d.ts +1 -1
  778. package/version.js +1 -1
  779. package/version.js.map +1 -1
  780. package/__cjs/cache/inmemory/object-canon.cjs +0 -180
  781. package/__cjs/cache/inmemory/object-canon.cjs.map +0 -1
  782. package/__cjs/cache/inmemory/object-canon.d.cts +0 -12
  783. package/__cjs/index.cjs +0 -8
  784. package/__cjs/index.cjs.map +0 -1
  785. package/__cjs/index.d.cts +0 -3
  786. package/__cjs/react/context/index.cjs +0 -10
  787. package/__cjs/react/context/index.cjs.map +0 -1
  788. package/__cjs/react/context/index.d.cts +0 -7
  789. package/__cjs/react/hooks/index.cjs +0 -27
  790. package/__cjs/react/hooks/index.cjs.map +0 -1
  791. package/__cjs/react/hooks/index.d.cts +0 -22
  792. package/__cjs/react/parser/index.cjs +0 -115
  793. package/__cjs/react/parser/index.cjs.map +0 -1
  794. package/__cjs/react/parser/index.d.cts +0 -18
  795. package/__cjs/react/ssr/RenderPromises.cjs +0 -104
  796. package/__cjs/react/ssr/RenderPromises.cjs.map +0 -1
  797. package/__cjs/react/ssr/RenderPromises.d.cts +0 -22
  798. package/__cjs/react/types/types.d.cts +0 -689
  799. package/__cjs/testing/matchers/toEmitApolloQueryResult.cjs +0 -40
  800. package/__cjs/testing/matchers/toEmitApolloQueryResult.cjs.map +0 -1
  801. package/__cjs/testing/matchers/toEmitApolloQueryResult.d.cts +0 -8
  802. package/__cjs/testing/matchers/toEmitFetchResult.cjs.map +0 -1
  803. package/__cjs/testing/matchers/toEmitFetchResult.d.cts +0 -8
  804. package/__cjs/testing/matchers/toEmitMatchedValue.cjs +0 -40
  805. package/__cjs/testing/matchers/toEmitMatchedValue.cjs.map +0 -1
  806. package/__cjs/testing/matchers/toEmitMatchedValue.d.cts +0 -7
  807. package/__cjs/testing/matchers/toEmitValue.cjs +0 -41
  808. package/__cjs/testing/matchers/toEmitValue.cjs.map +0 -1
  809. package/__cjs/testing/matchers/toEmitValue.d.cts +0 -4
  810. package/__cjs/testing/matchers/toEmitValueStrict.cjs +0 -46
  811. package/__cjs/testing/matchers/toEmitValueStrict.cjs.map +0 -1
  812. package/__cjs/testing/matchers/toEqualApolloQueryResult.cjs +0 -24
  813. package/__cjs/testing/matchers/toEqualApolloQueryResult.cjs.map +0 -1
  814. package/__cjs/testing/matchers/toEqualApolloQueryResult.d.cts +0 -6
  815. package/__cjs/testing/matchers/toEqualFetchResult.cjs +0 -24
  816. package/__cjs/testing/matchers/toEqualFetchResult.cjs.map +0 -1
  817. package/__cjs/testing/matchers/toEqualFetchResult.d.cts +0 -4
  818. package/__cjs/testing/matchers/toEqualLazyQueryResult.cjs +0 -40
  819. package/__cjs/testing/matchers/toEqualLazyQueryResult.cjs.map +0 -1
  820. package/__cjs/testing/matchers/toEqualLazyQueryResult.d.cts +0 -10
  821. package/__cjs/testing/matchers/toEqualQueryResult.cjs +0 -40
  822. package/__cjs/testing/matchers/toEqualQueryResult.cjs.map +0 -1
  823. package/__cjs/testing/matchers/toEqualQueryResult.d.cts +0 -9
  824. package/__cjs/utilities/types/OnlyRequiredProperties.cjs.map +0 -1
  825. package/__cjs/utilities/types/OnlyRequiredProperties.d.cts +0 -7
  826. package/__cjs/utilities/types/TODO.cjs.map +0 -1
  827. package/__cjs/utilities/types/TODO.d.cts +0 -3
  828. package/cache/inmemory/object-canon.d.ts +0 -12
  829. package/cache/inmemory/object-canon.js +0 -176
  830. package/cache/inmemory/object-canon.js.map +0 -1
  831. package/index.d.ts +0 -3
  832. package/index.js +0 -3
  833. package/index.js.map +0 -1
  834. package/legacyEntryPoints/react/context/context.cjs +0 -1
  835. package/legacyEntryPoints/react/context/context.d.cts +0 -1
  836. package/legacyEntryPoints/react/context/index.d.ts +0 -1
  837. package/legacyEntryPoints/react/context/index.js +0 -1
  838. package/legacyEntryPoints/react/hooks/hooks.cjs +0 -1
  839. package/legacyEntryPoints/react/hooks/hooks.d.cts +0 -1
  840. package/legacyEntryPoints/react/hooks/index.d.ts +0 -1
  841. package/legacyEntryPoints/react/hooks/index.js +0 -1
  842. package/legacyEntryPoints/react/parser/index.d.ts +0 -1
  843. package/legacyEntryPoints/react/parser/index.js +0 -1
  844. package/legacyEntryPoints/react/parser/parser.cjs +0 -1
  845. package/legacyEntryPoints/react/parser/parser.d.cts +0 -1
  846. package/react/context/index.d.ts +0 -7
  847. package/react/context/index.js +0 -4
  848. package/react/context/index.js.map +0 -1
  849. package/react/hooks/index.d.ts +0 -22
  850. package/react/hooks/index.js +0 -15
  851. package/react/hooks/index.js.map +0 -1
  852. package/react/parser/index.d.ts +0 -18
  853. package/react/parser/index.js +0 -109
  854. package/react/parser/index.js.map +0 -1
  855. package/react/ssr/RenderPromises.d.ts +0 -22
  856. package/react/ssr/RenderPromises.js +0 -100
  857. package/react/ssr/RenderPromises.js.map +0 -1
  858. package/react/types/types.d.ts +0 -689
  859. package/testing/matchers/toEmitApolloQueryResult.d.ts +0 -8
  860. package/testing/matchers/toEmitApolloQueryResult.js +0 -36
  861. package/testing/matchers/toEmitApolloQueryResult.js.map +0 -1
  862. package/testing/matchers/toEmitFetchResult.d.ts +0 -8
  863. package/testing/matchers/toEmitFetchResult.js.map +0 -1
  864. package/testing/matchers/toEmitMatchedValue.d.ts +0 -7
  865. package/testing/matchers/toEmitMatchedValue.js +0 -36
  866. package/testing/matchers/toEmitMatchedValue.js.map +0 -1
  867. package/testing/matchers/toEmitValue.d.ts +0 -4
  868. package/testing/matchers/toEmitValue.js +0 -37
  869. package/testing/matchers/toEmitValue.js.map +0 -1
  870. package/testing/matchers/toEmitValueStrict.js +0 -42
  871. package/testing/matchers/toEmitValueStrict.js.map +0 -1
  872. package/testing/matchers/toEqualApolloQueryResult.d.ts +0 -6
  873. package/testing/matchers/toEqualApolloQueryResult.js +0 -20
  874. package/testing/matchers/toEqualApolloQueryResult.js.map +0 -1
  875. package/testing/matchers/toEqualFetchResult.d.ts +0 -4
  876. package/testing/matchers/toEqualFetchResult.js +0 -20
  877. package/testing/matchers/toEqualFetchResult.js.map +0 -1
  878. package/testing/matchers/toEqualLazyQueryResult.d.ts +0 -10
  879. package/testing/matchers/toEqualLazyQueryResult.js +0 -36
  880. package/testing/matchers/toEqualLazyQueryResult.js.map +0 -1
  881. package/testing/matchers/toEqualQueryResult.d.ts +0 -9
  882. package/testing/matchers/toEqualQueryResult.js +0 -36
  883. package/testing/matchers/toEqualQueryResult.js.map +0 -1
  884. package/utilities/types/OnlyRequiredProperties.d.ts +0 -7
  885. package/utilities/types/OnlyRequiredProperties.js +0 -2
  886. package/utilities/types/OnlyRequiredProperties.js.map +0 -1
  887. package/utilities/types/TODO.d.ts +0 -3
  888. package/utilities/types/TODO.js +0 -2
  889. package/utilities/types/TODO.js.map +0 -1
  890. /package/__cjs/react/{types → internal}/types.cjs +0 -0
  891. /package/__cjs/react/{types → internal}/types.cjs.map +0 -0
  892. /package/react/{types → internal}/types.js +0 -0
  893. /package/react/{types → internal}/types.js.map +0 -0
@@ -6,6 +6,7 @@ const {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.QueryManager = void 0;
8
8
  const trie_1 = require("@wry/trie");
9
+ const graphql_1 = require("graphql");
9
10
  const rxjs_1 = require("rxjs");
10
11
  const cache_1 = require("@apollo/client/cache");
11
12
  const errors_1 = require("@apollo/client/errors");
@@ -26,9 +27,8 @@ const QueryInfo_js_1 = require("./QueryInfo.cjs");
26
27
  const { hasOwnProperty } = Object.prototype;
27
28
  const IGNORE = {};
28
29
  class QueryManager {
29
- cache;
30
- link;
31
30
  defaultOptions;
31
+ client;
32
32
  assumeImmutableResults;
33
33
  documentTransform;
34
34
  ssrMode;
@@ -37,6 +37,17 @@ class QueryManager {
37
37
  queryDeduplication;
38
38
  clientAwareness = {};
39
39
  localState;
40
+ /**
41
+ * Whether to prioritize cache values over network results when
42
+ * `fetchObservableWithInfo` is called.
43
+ * This will essentially turn a `"network-only"` or `"cache-and-network"`
44
+ * fetchPolicy into a `"cache-first"` fetchPolicy, but without influencing
45
+ * the `fetchPolicy` of the `ObservableQuery`.
46
+ *
47
+ * This can e.g. be used to prioritize the cache during the first render after
48
+ * SSR.
49
+ */
50
+ prioritizeCacheValues = false;
40
51
  onBroadcast;
41
52
  mutationStore;
42
53
  // All the queries that the QueryManager is currently managing (not
@@ -51,8 +62,7 @@ class QueryManager {
51
62
  const defaultDocumentTransform = new utilities_4.DocumentTransform((document) => this.cache.transformDocument(document),
52
63
  // Allow the apollo cache to manage its own transform caches
53
64
  { cache: false });
54
- this.cache = options.cache;
55
- this.link = options.link;
65
+ this.client = options.client;
56
66
  this.defaultOptions = options.defaultOptions;
57
67
  this.queryDeduplication = options.queryDeduplication;
58
68
  this.clientAwareness = options.clientAwareness;
@@ -76,6 +86,12 @@ class QueryManager {
76
86
  this.mutationStore = {};
77
87
  }
78
88
  }
89
+ get link() {
90
+ return this.client.link;
91
+ }
92
+ get cache() {
93
+ return this.client.cache;
94
+ }
79
95
  /**
80
96
  * Call this method to terminate any active query processes, making it safe
81
97
  * to dispose of this QueryManager instance.
@@ -84,15 +100,16 @@ class QueryManager {
84
100
  this.queries.forEach((_info, queryId) => {
85
101
  this.removeQuery(queryId);
86
102
  });
87
- this.cancelPendingFetches((0, invariant_1.newInvariantError)(72));
103
+ this.cancelPendingFetches((0, invariant_1.newInvariantError)(74));
88
104
  }
89
105
  cancelPendingFetches(error) {
90
106
  this.fetchCancelFns.forEach((cancel) => cancel(error));
91
107
  this.fetchCancelFns.clear();
92
108
  }
93
109
  async mutate({ mutation, variables, optimisticResponse, updateQueries, refetchQueries = [], awaitRefetchQueries = false, update: updateWithProxyFn, onQueryUpdated, fetchPolicy = this.defaultOptions.mutate?.fetchPolicy || "network-only", errorPolicy = this.defaultOptions.mutate?.errorPolicy || "none", keepRootFields, context, }) {
94
- (0, invariant_1.invariant)(mutation, 73);
95
- (0, invariant_1.invariant)(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 74);
110
+ (0, invariant_1.invariant)(mutation, 75);
111
+ (0, utilities_1.checkDocument)(mutation, graphql_1.OperationTypeNode.MUTATION);
112
+ (0, invariant_1.invariant)(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 76);
96
113
  const mutationId = this.generateMutationId();
97
114
  mutation = this.cache.transformForLink(this.transform(mutation));
98
115
  const { hasClientExports } = this.getDocumentInfo(mutation);
@@ -125,9 +142,10 @@ class QueryManager {
125
142
  ...context,
126
143
  optimisticResponse: isOptimistic ? optimisticResponse : void 0,
127
144
  }, variables, {}, false)
128
- .pipe((0, rxjs_1.mergeMap)((result) => {
129
- if ((0, utilities_4.graphQLResultHasError)(result) && errorPolicy === "none") {
130
- throw new errors_1.CombinedGraphQLErrors((0, utilities_4.getGraphQLErrorsFromResult)(result));
145
+ .pipe(validateDidEmitValue(), (0, rxjs_1.mergeMap)((result) => {
146
+ const hasErrors = (0, utilities_4.graphQLResultHasError)(result);
147
+ if (hasErrors && errorPolicy === "none") {
148
+ throw new errors_1.CombinedGraphQLErrors(result);
131
149
  }
132
150
  if (mutationStoreValue) {
133
151
  mutationStoreValue.loading = false;
@@ -137,8 +155,7 @@ class QueryManager {
137
155
  if (typeof refetchQueries === "function") {
138
156
  refetchQueries = refetchQueries(storeResult);
139
157
  }
140
- if (errorPolicy === "ignore" &&
141
- (0, utilities_4.graphQLResultHasError)(storeResult)) {
158
+ if (errorPolicy === "ignore" && hasErrors) {
142
159
  delete storeResult.errors;
143
160
  }
144
161
  return (0, rxjs_1.from)(this.markMutationResult({
@@ -167,28 +184,39 @@ class QueryManager {
167
184
  // ExecutionPatchResult has arrived and we have assembled the
168
185
  // multipart response into a single result.
169
186
  if (!("hasNext" in storeResult) || storeResult.hasNext === false) {
170
- resolve({
171
- ...storeResult,
187
+ const result = {
172
188
  data: this.maskOperation({
173
189
  document: mutation,
174
190
  data: storeResult.data,
175
191
  fetchPolicy,
176
192
  id: mutationId,
177
193
  }),
178
- });
194
+ };
195
+ if ((0, utilities_4.graphQLResultHasError)(storeResult)) {
196
+ result.error = new errors_1.CombinedGraphQLErrors(storeResult);
197
+ }
198
+ if (storeResult.extensions) {
199
+ result.extensions = storeResult.extensions;
200
+ }
201
+ resolve(result);
179
202
  }
180
203
  },
181
- error: (err) => {
182
- err = maybeWrapError(err);
204
+ error: (error) => {
183
205
  if (mutationStoreValue) {
184
206
  mutationStoreValue.loading = false;
185
- mutationStoreValue.error = err;
207
+ mutationStoreValue.error = error;
186
208
  }
187
209
  if (isOptimistic) {
188
210
  this.cache.removeOptimistic(mutationId);
189
211
  }
190
212
  this.broadcastQueries();
191
- reject(err);
213
+ if (errorPolicy === "ignore") {
214
+ return resolve({ data: undefined });
215
+ }
216
+ if (errorPolicy === "all") {
217
+ return resolve({ data: undefined, error });
218
+ }
219
+ reject(error);
192
220
  },
193
221
  });
194
222
  });
@@ -378,13 +406,17 @@ class QueryManager {
378
406
  return true;
379
407
  }
380
408
  fetchQuery(queryId, options, networkStatus) {
381
- return (0, rxjs_1.lastValueFrom)(this.fetchObservableWithInfo(queryId, options, networkStatus).observable, { defaultValue: undefined });
409
+ return (0, rxjs_1.lastValueFrom)(this.fetchObservableWithInfo(this.getOrCreateQuery(queryId), options, networkStatus).observable.pipe((0, rxjs_1.map)(internal_1.toQueryResult)), {
410
+ // This default is needed when a `standby` fetch policy is used to avoid
411
+ // an EmptyError from rejecting this promise.
412
+ defaultValue: { data: undefined },
413
+ });
382
414
  }
383
415
  transform(document) {
384
416
  return this.documentTransform.transformDocument(document);
385
417
  }
386
418
  transformCache = new utilities_2.AutoCleanedWeakCache(utilities_2.cacheSizes["queryManager.getDocumentInfo"] ||
387
- utilities_3.defaultCacheSizes["queryManager.getDocumentInfo"]);
419
+ 2000 /* defaultCacheSizes["queryManager.getDocumentInfo"] */);
388
420
  getDocumentInfo(document) {
389
421
  const { transformCache } = this;
390
422
  if (!transformCache.has(document)) {
@@ -424,12 +456,15 @@ class QueryManager {
424
456
  return transformCache.get(document);
425
457
  }
426
458
  getVariables(document, variables) {
459
+ const defaultVars = this.getDocumentInfo(document).defaultVars;
460
+ const varsWithDefaults = Object.entries(variables ?? {}).map(([key, value]) => [key, value === undefined ? defaultVars[key] : value]);
427
461
  return {
428
- ...this.getDocumentInfo(document).defaultVars,
429
- ...variables,
462
+ ...defaultVars,
463
+ ...Object.fromEntries(varsWithDefaults),
430
464
  };
431
465
  }
432
466
  watchQuery(options) {
467
+ (0, utilities_1.checkDocument)(options.query, graphql_1.OperationTypeNode.QUERY);
433
468
  const query = this.transform(options.query);
434
469
  // assign variable default values if supplied
435
470
  // NOTE: We don't modify options.query here with the transformed query to
@@ -439,7 +474,7 @@ class QueryManager {
439
474
  variables: this.getVariables(query, options.variables),
440
475
  };
441
476
  if (typeof options.notifyOnNetworkStatusChange === "undefined") {
442
- options.notifyOnNetworkStatusChange = false;
477
+ options.notifyOnNetworkStatusChange = true;
443
478
  }
444
479
  const queryInfo = new QueryInfo_js_1.QueryInfo(this);
445
480
  const observable = new ObservableQuery_js_1.ObservableQuery({
@@ -448,35 +483,31 @@ class QueryManager {
448
483
  options,
449
484
  });
450
485
  observable["lastQuery"] = query;
451
- this.queries.set(observable.queryId, queryInfo);
486
+ if (!ObservableQuery_js_1.ObservableQuery["inactiveOnCreation"].getValue()) {
487
+ this.queries.set(observable.queryId, queryInfo);
488
+ }
452
489
  // We give queryInfo the transformed query to ensure the first cache diff
453
490
  // uses the transformed query instead of the raw query
454
- queryInfo.init({
455
- document: query,
456
- observableQuery: observable,
457
- variables: observable.variables,
458
- });
491
+ queryInfo.init({ document: query, variables: observable.variables });
492
+ queryInfo.setObservableQuery(observable);
459
493
  return observable;
460
494
  }
461
- // TODO: catch `EmptyError` and rethrow as network error if `complete`
462
- // notification is emitted without a value.
463
495
  query(options, queryId = this.generateQueryId()) {
464
- (0, invariant_1.invariant)(options.query, 75);
465
- (0, invariant_1.invariant)(options.query.kind === "Document", 76);
466
- (0, invariant_1.invariant)(!options.returnPartialData, 77);
467
- (0, invariant_1.invariant)(!options.pollInterval, 78);
468
496
  const query = this.transform(options.query);
469
- return this.fetchQuery(queryId, { ...options, query })
470
- .then((result) => result && {
471
- ...result,
497
+ return this.fetchQuery(queryId, {
498
+ ...options,
499
+ query,
500
+ })
501
+ .then((value) => ({
502
+ ...value,
472
503
  data: this.maskOperation({
473
504
  document: query,
474
- data: result.data,
505
+ data: value?.data,
475
506
  fetchPolicy: options.fetchPolicy,
476
507
  id: queryId,
477
508
  }),
478
- })
479
- .finally(() => this.stopQuery(queryId));
509
+ }))
510
+ .finally(() => this.removeQuery(queryId));
480
511
  }
481
512
  queryIdCounter = 1;
482
513
  generateQueryId() {
@@ -498,7 +529,7 @@ class QueryManager {
498
529
  // depend on values that previously existed in the data portion of the
499
530
  // store. So, we cancel the promises and observers that we have issued
500
531
  // so far and not yet resolved (in the case of queries).
501
- this.cancelPendingFetches((0, invariant_1.newInvariantError)(79));
532
+ this.cancelPendingFetches((0, invariant_1.newInvariantError)(77));
502
533
  this.queries.forEach((queryInfo) => {
503
534
  if (queryInfo.observableQuery) {
504
535
  // Set loading to true so listeners don't trigger unless they want
@@ -564,7 +595,7 @@ class QueryManager {
564
595
  // pre-allocate a new query ID here, using a special prefix to enable
565
596
  // cleaning up these temporary queries later, after fetching.
566
597
  const queryId = (0, utilities_4.makeUniqueId)("legacyOneTimeQuery");
567
- const queryInfo = this.getQuery(queryId).init({
598
+ const queryInfo = this.getOrCreateQuery(queryId).init({
568
599
  document: options.query,
569
600
  variables: options.variables,
570
601
  });
@@ -586,10 +617,10 @@ class QueryManager {
586
617
  if (!included) {
587
618
  const queryName = queryNames.get(nameOrQueryString);
588
619
  if (queryName) {
589
- __DEV__ && invariant_1.invariant.warn(80, queryName);
620
+ __DEV__ && invariant_1.invariant.warn(78, queryName);
590
621
  }
591
622
  else {
592
- __DEV__ && invariant_1.invariant.warn(81);
623
+ __DEV__ && invariant_1.invariant.warn(79);
593
624
  }
594
625
  }
595
626
  });
@@ -605,51 +636,59 @@ class QueryManager {
605
636
  (fetchPolicy !== "standby" && fetchPolicy !== "cache-only")) {
606
637
  observableQueryPromises.push(observableQuery.refetch());
607
638
  }
608
- this.getQuery(queryId).setDiff(null);
639
+ (this.queries.get(queryId) || observableQuery["queryInfo"]).setDiff(null);
609
640
  });
610
641
  this.broadcastQueries();
611
642
  return Promise.all(observableQueryPromises);
612
643
  }
613
- setObservableQuery(observableQuery) {
614
- this.getQuery(observableQuery.queryId).setObservableQuery(observableQuery);
615
- }
616
644
  startGraphQLSubscription(options) {
617
645
  let { query, variables } = options;
618
646
  const { fetchPolicy, errorPolicy = "none", context = {}, extensions = {}, } = options;
647
+ (0, utilities_1.checkDocument)(query, graphql_1.OperationTypeNode.SUBSCRIPTION);
619
648
  query = this.transform(query);
620
649
  variables = this.getVariables(query, variables);
621
- const makeObservable = (variables) => this.getObservableFromLink(query, context, variables, extensions).pipe((0, rxjs_1.map)((result) => {
650
+ const makeObservable = (variables) => this.getObservableFromLink(query, context, variables, extensions).pipe((0, rxjs_1.map)((rawResult) => {
622
651
  if (fetchPolicy !== "no-cache") {
623
652
  // the subscription interface should handle not sending us results we no longer subscribe to.
624
653
  // XXX I don't think we ever send in an object with errors, but we might in the future...
625
- if ((0, QueryInfo_js_1.shouldWriteResult)(result, errorPolicy)) {
654
+ if ((0, QueryInfo_js_1.shouldWriteResult)(rawResult, errorPolicy)) {
626
655
  this.cache.write({
627
656
  query,
628
- result: result.data,
657
+ result: rawResult.data,
629
658
  dataId: "ROOT_SUBSCRIPTION",
630
659
  variables: variables,
631
660
  });
632
661
  }
633
662
  this.broadcastQueries();
634
663
  }
635
- const hasErrors = (0, utilities_4.graphQLResultHasError)(result);
636
- const hasProtocolErrors = (0, errors_1.graphQLResultHasProtocolErrors)(result);
637
- if (hasErrors && errorPolicy === "none") {
638
- throw new errors_1.CombinedGraphQLErrors(result.errors);
664
+ const result = {
665
+ data: rawResult.data ?? undefined,
666
+ };
667
+ if ((0, utilities_4.graphQLResultHasError)(rawResult)) {
668
+ result.error = new errors_1.CombinedGraphQLErrors(rawResult);
639
669
  }
640
- if (hasProtocolErrors) {
641
- // `errorPolicy` is a mechanism for handling GraphQL errors, according
642
- // to our documentation, so we throw protocol errors regardless of the
643
- // set error policy.
644
- throw result.extensions[errors_2.PROTOCOL_ERRORS_SYMBOL];
670
+ else if ((0, errors_1.graphQLResultHasProtocolErrors)(rawResult)) {
671
+ result.error = rawResult.extensions[errors_2.PROTOCOL_ERRORS_SYMBOL];
672
+ // Don't emit protocol errors added by HttpLink
673
+ delete rawResult.extensions[errors_2.PROTOCOL_ERRORS_SYMBOL];
674
+ }
675
+ if (rawResult.extensions &&
676
+ Object.keys(rawResult.extensions).length) {
677
+ result.extensions = rawResult.extensions;
678
+ }
679
+ if (result.error && errorPolicy === "none") {
680
+ result.data = undefined;
645
681
  }
646
682
  if (errorPolicy === "ignore") {
647
- delete result.errors;
683
+ delete result.error;
648
684
  }
649
685
  return result;
650
686
  }), (0, rxjs_1.catchError)((error) => {
651
- throw maybeWrapError(error);
652
- }));
687
+ if (errorPolicy === "ignore") {
688
+ return (0, rxjs_1.of)({ data: undefined });
689
+ }
690
+ return (0, rxjs_1.of)({ data: undefined, error });
691
+ }), (0, rxjs_1.filter)((result) => !!(result.data || result.error)));
653
692
  if (this.getDocumentInfo(query).hasClientExports) {
654
693
  const observablePromise = this.localState
655
694
  .addExportedVariables(query, variables, context)
@@ -662,10 +701,6 @@ class QueryManager {
662
701
  }
663
702
  return makeObservable(variables);
664
703
  }
665
- stopQuery(queryId) {
666
- this.removeQuery(queryId);
667
- this.broadcastQueries();
668
- }
669
704
  removeQuery(queryId) {
670
705
  // teardown all links
671
706
  // Both `QueryManager.fetchRequest` and `QueryManager.query` create separate promises
@@ -674,14 +709,14 @@ class QueryManager {
674
709
  // The same queryId could have two rejection fns for two promises
675
710
  this.fetchCancelFns.delete(queryId);
676
711
  if (this.queries.has(queryId)) {
677
- this.getQuery(queryId).stop();
712
+ this.queries.get(queryId)?.stop();
678
713
  this.queries.delete(queryId);
679
714
  }
680
715
  }
681
716
  broadcastQueries() {
682
717
  if (this.onBroadcast)
683
718
  this.onBroadcast();
684
- this.queries.forEach((info) => info.notify());
719
+ this.queries.forEach((info) => info.observableQuery?.["notify"]());
685
720
  }
686
721
  getLocalState() {
687
722
  return this.localState;
@@ -695,16 +730,25 @@ class QueryManager {
695
730
  this.queryDeduplication) {
696
731
  let observable;
697
732
  const { serverQuery, clientQuery } = this.getDocumentInfo(query);
733
+ const prepareContext = (context = {}) => {
734
+ const newContext = this.localState.prepareContext(context);
735
+ return {
736
+ ...this.defaultContext,
737
+ ...newContext,
738
+ queryDeduplication: deduplication,
739
+ clientAwareness: this.clientAwareness,
740
+ };
741
+ };
742
+ const executeContext = {
743
+ client: this.client,
744
+ };
698
745
  if (serverQuery) {
699
746
  const { inFlightLinkObservables, link } = this;
700
747
  const operation = {
701
748
  query: serverQuery,
702
749
  variables,
703
750
  operationName: (0, utilities_4.getOperationName)(serverQuery) || void 0,
704
- context: this.prepareContext({
705
- ...context,
706
- forceFetch: !deduplication,
707
- }),
751
+ context: prepareContext(context),
708
752
  extensions,
709
753
  };
710
754
  context = operation.context;
@@ -714,7 +758,7 @@ class QueryManager {
714
758
  const entry = inFlightLinkObservables.lookup(printedServerQuery, varJson);
715
759
  observable = entry.observable;
716
760
  if (!observable) {
717
- observable = entry.observable = (0, core_1.execute)(link, operation).pipe((0, internal_1.onAnyEvent)((event) => {
761
+ observable = entry.observable = (0, core_1.execute)(link, operation, executeContext).pipe((0, internal_1.onAnyEvent)((event) => {
718
762
  if ((event.type !== "next" ||
719
763
  !("hasNext" in event.value) ||
720
764
  !event.value.hasNext) &&
@@ -726,12 +770,12 @@ class QueryManager {
726
770
  }
727
771
  }
728
772
  else {
729
- observable = (0, core_1.execute)(link, operation);
773
+ observable = (0, core_1.execute)(link, operation, executeContext);
730
774
  }
731
775
  }
732
776
  else {
733
777
  observable = (0, rxjs_1.of)({ data: {} });
734
- context = this.prepareContext(context);
778
+ context = prepareContext(context);
735
779
  }
736
780
  if (clientQuery) {
737
781
  observable = observable.pipe((0, rxjs_1.mergeMap)((result) => {
@@ -743,34 +787,30 @@ class QueryManager {
743
787
  }));
744
788
  }));
745
789
  }
746
- return observable;
790
+ return observable.pipe((0, rxjs_1.catchError)((error) => {
791
+ error = (0, errors_1.toErrorLike)(error);
792
+ (0, errors_1.registerLinkError)(error);
793
+ throw error;
794
+ }));
747
795
  }
748
796
  getResultsFromLink(queryInfo, cacheWriteBehavior, options) {
749
797
  const requestId = (queryInfo.lastRequestId = this.generateRequestId());
798
+ const { errorPolicy } = options;
750
799
  // Performing transformForLink here gives this.cache a chance to fill in
751
800
  // missing fragment definitions (for example) before sending this document
752
801
  // through the link chain.
753
802
  const linkDocument = this.cache.transformForLink(options.query);
754
- return this.getObservableFromLink(linkDocument, options.context, options.variables).pipe((0, rxjs_1.catchError)((error) => {
755
- error = maybeWrapError(error);
756
- // Avoid storing errors from older interrupted queries.
757
- if (requestId >= queryInfo.lastRequestId) {
758
- queryInfo.resetLastWrite();
759
- queryInfo.reset();
760
- }
761
- throw error;
762
- }), (0, rxjs_1.map)((result) => {
803
+ return this.getObservableFromLink(linkDocument, options.context, options.variables).pipe((0, rxjs_1.map)((result) => {
763
804
  const graphQLErrors = (0, utilities_4.getGraphQLErrorsFromResult)(result);
764
805
  const hasErrors = graphQLErrors.length > 0;
765
- const { errorPolicy } = options;
766
806
  // If we interrupted this request by calling getResultsFromLink again
767
807
  // with the same QueryInfo object, we ignore the old results.
768
808
  if (requestId >= queryInfo.lastRequestId) {
769
809
  if (hasErrors && errorPolicy === "none") {
770
810
  queryInfo.resetLastWrite();
771
- queryInfo.reset();
811
+ queryInfo.observableQuery?.["resetNotifications"]();
772
812
  // Throwing here effectively calls observer.error.
773
- throw new errors_1.CombinedGraphQLErrors(graphQLErrors);
813
+ throw new errors_1.CombinedGraphQLErrors(result);
774
814
  }
775
815
  // Use linkDocument rather than queryInfo.document so the
776
816
  // operation/fragments used to write the result are the same as the
@@ -791,21 +831,42 @@ class QueryManager {
791
831
  aqr.data = void 0;
792
832
  }
793
833
  if (hasErrors && errorPolicy !== "ignore") {
794
- aqr.error = new errors_1.CombinedGraphQLErrors(graphQLErrors);
834
+ aqr.error = new errors_1.CombinedGraphQLErrors(result);
795
835
  aqr.networkStatus = networkStatus_js_1.NetworkStatus.error;
796
836
  }
797
837
  return aqr;
838
+ }), (0, rxjs_1.catchError)((error) => {
839
+ // Avoid storing errors from older interrupted queries.
840
+ if (requestId >= queryInfo.lastRequestId && errorPolicy === "none") {
841
+ queryInfo.resetLastWrite();
842
+ queryInfo.observableQuery?.["resetNotifications"]();
843
+ throw error;
844
+ }
845
+ const aqr = {
846
+ data: undefined,
847
+ loading: false,
848
+ networkStatus: networkStatus_js_1.NetworkStatus.ready,
849
+ partial: true,
850
+ };
851
+ if (errorPolicy !== "ignore") {
852
+ aqr.error = error;
853
+ aqr.networkStatus = networkStatus_js_1.NetworkStatus.error;
854
+ }
855
+ return (0, rxjs_1.of)(aqr);
798
856
  }));
799
857
  }
800
- fetchObservableWithInfo(queryId, options,
858
+ fetchObservableWithInfo(queryInfo, options,
801
859
  // The initial networkStatus for this fetch, most often
802
860
  // NetworkStatus.loading, but also possibly fetchMore, poll, refetch,
803
861
  // or setVariables.
804
862
  networkStatus = networkStatus_js_1.NetworkStatus.loading, query = options.query, emitLoadingState = false) {
805
863
  const variables = this.getVariables(query, options.variables);
806
- const queryInfo = this.getQuery(queryId);
807
864
  const defaults = this.defaultOptions.watchQuery;
808
- let { fetchPolicy = (defaults && defaults.fetchPolicy) || "cache-first", errorPolicy = (defaults && defaults.errorPolicy) || "none", returnPartialData = false, notifyOnNetworkStatusChange = false, context = {}, } = options;
865
+ let { fetchPolicy = (defaults && defaults.fetchPolicy) || "cache-first", errorPolicy = (defaults && defaults.errorPolicy) || "none", returnPartialData = false, notifyOnNetworkStatusChange = true, context = {}, } = options;
866
+ if (this.prioritizeCacheValues &&
867
+ (fetchPolicy === "network-only" || fetchPolicy === "cache-and-network")) {
868
+ fetchPolicy = "cache-first";
869
+ }
809
870
  const normalized = Object.assign({}, options, {
810
871
  query,
811
872
  variables,
@@ -833,13 +894,13 @@ class QueryManager {
833
894
  // This cancel function needs to be set before the concast is created,
834
895
  // in case concast creation synchronously cancels the request.
835
896
  const cleanupCancelFn = () => {
836
- this.fetchCancelFns.delete(queryId);
897
+ this.fetchCancelFns.delete(queryInfo.queryId);
837
898
  // We need to call `complete` on the subject here otherwise the merged
838
899
  // observable will never complete since it waits for all source
839
900
  // observables to complete before itself completes.
840
901
  fetchCancelSubject.complete();
841
902
  };
842
- this.fetchCancelFns.set(queryId, (reason) => {
903
+ this.fetchCancelFns.set(queryInfo.queryId, (reason) => {
843
904
  fetchCancelSubject.error(reason);
844
905
  cleanupCancelFn();
845
906
  });
@@ -877,7 +938,7 @@ class QueryManager {
877
938
  this.getObservableQueries(include).forEach((oq, queryId) => {
878
939
  includedQueriesById.set(queryId, {
879
940
  oq,
880
- lastDiff: this.getQuery(queryId).getDiff(),
941
+ lastDiff: (this.queries.get(queryId) || oq["queryInfo"]).getDiff(),
881
942
  });
882
943
  });
883
944
  }
@@ -963,9 +1024,7 @@ class QueryManager {
963
1024
  // queries, even the QueryOptions ones.
964
1025
  if (onQueryUpdated) {
965
1026
  if (!diff) {
966
- const info = oq["queryInfo"];
967
- info.reset(); // Force info.getDiff() to read from cache.
968
- diff = info.getDiff();
1027
+ diff = this.cache.diff(oq["queryInfo"]["getDiffOptions"]());
969
1028
  }
970
1029
  result = onQueryUpdated(oq, diff, lastDiff);
971
1030
  }
@@ -1005,7 +1064,7 @@ class QueryManager {
1005
1064
  !(0, utilities_3.isFullyUnmaskedOperation)(document) &&
1006
1065
  !this.noCacheWarningsByQueryId.has(operationId)) {
1007
1066
  this.noCacheWarningsByQueryId.add(operationId);
1008
- __DEV__ && invariant_1.invariant.warn(82, (0, utilities_4.getOperationName)(document) ??
1067
+ __DEV__ && invariant_1.invariant.warn(80, (0, utilities_4.getOperationName)(document) ??
1009
1068
  `Unnamed ${operationType ?? "operation"}`);
1010
1069
  }
1011
1070
  }
@@ -1095,7 +1154,7 @@ class QueryManager {
1095
1154
  context,
1096
1155
  fetchPolicy,
1097
1156
  errorPolicy,
1098
- });
1157
+ }).pipe(validateDidEmitValue());
1099
1158
  switch (fetchPolicy) {
1100
1159
  default:
1101
1160
  case "cache-first": {
@@ -1152,37 +1211,23 @@ class QueryManager {
1152
1211
  return { fromLink: false, observable: rxjs_1.EMPTY };
1153
1212
  }
1154
1213
  }
1155
- getQuery(queryId) {
1214
+ getOrCreateQuery(queryId) {
1156
1215
  if (queryId && !this.queries.has(queryId)) {
1157
1216
  this.queries.set(queryId, new QueryInfo_js_1.QueryInfo(this, queryId));
1158
1217
  }
1159
1218
  return this.queries.get(queryId);
1160
1219
  }
1161
- prepareContext(context = {}) {
1162
- const newContext = this.localState.prepareContext(context);
1163
- return {
1164
- ...this.defaultContext,
1165
- ...newContext,
1166
- clientAwareness: this.clientAwareness,
1167
- };
1168
- }
1169
1220
  }
1170
1221
  exports.QueryManager = QueryManager;
1171
- function isErrorLike(error) {
1172
- return (error !== null &&
1173
- typeof error === "object" &&
1174
- typeof error.message === "string" &&
1175
- typeof error.name === "string" &&
1176
- (typeof error.stack === "undefined" ||
1177
- typeof error.stack === "string"));
1178
- }
1179
- function maybeWrapError(error) {
1180
- if (isErrorLike(error)) {
1181
- return error;
1182
- }
1183
- if (typeof error === "string") {
1184
- return new Error(error, { cause: error });
1185
- }
1186
- return new errors_1.UnconventionalError(error);
1222
+ function validateDidEmitValue() {
1223
+ let didEmitValue = false;
1224
+ return (0, rxjs_1.tap)({
1225
+ next() {
1226
+ didEmitValue = true;
1227
+ },
1228
+ complete() {
1229
+ (0, invariant_1.invariant)(didEmitValue, 81);
1230
+ },
1231
+ });
1187
1232
  }
1188
1233
  //# sourceMappingURL=QueryManager.cjs.map