@apollo/client 3.9.0-alpha.4 → 3.9.0-alpha.5

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 (687) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/beige-geese-wink.md +5 -0
  3. package/.changeset/breezy-spiders-tap.md +38 -0
  4. package/.changeset/clean-items-smash.md +5 -0
  5. package/.changeset/cold-llamas-turn.md +8 -0
  6. package/.changeset/config.json +14 -0
  7. package/.changeset/dirty-kids-crash.md +5 -0
  8. package/.changeset/forty-cups-shop.md +5 -0
  9. package/.changeset/friendly-clouds-laugh.md +7 -0
  10. package/.changeset/hot-ducks-burn.md +5 -0
  11. package/.changeset/polite-avocados-warn.md +5 -0
  12. package/.changeset/pre.json +29 -0
  13. package/.changeset/quick-hats-marry.md +5 -0
  14. package/.changeset/shaggy-ears-scream.md +5 -0
  15. package/.changeset/shaggy-sheep-pull.md +5 -0
  16. package/.changeset/sixty-boxes-rest.md +8 -0
  17. package/.changeset/sour-sheep-walk.md +7 -0
  18. package/.changeset/strong-terms-perform.md +46 -0
  19. package/.changeset/thick-mice-collect.md +5 -0
  20. package/.changeset/thirty-ties-arrive.md +26 -0
  21. package/.changeset/violet-lions-draw.md +5 -0
  22. package/.changeset/wild-dolphins-jog.md +5 -0
  23. package/.changeset/yellow-flies-repeat.md +5 -0
  24. package/CHANGELOG.md +3535 -0
  25. package/apollo-client.cjs +475 -398
  26. package/apollo-client.cjs.map +1 -1
  27. package/apollo-client.min.cjs +1 -1
  28. package/cache/cache.cjs +135 -153
  29. package/cache/cache.cjs.map +1 -1
  30. package/cache/cache.cjs.native.js +135 -153
  31. package/cache/core/cache.d.ts +10 -0
  32. package/cache/core/cache.js +17 -5
  33. package/cache/core/cache.js.map +1 -1
  34. package/cache/core/types/Cache.d.ts +1 -1
  35. package/cache/core/types/Cache.js.map +1 -1
  36. package/cache/core/types/DataProxy.d.ts +92 -0
  37. package/cache/core/types/common.d.ts +1 -1
  38. package/cache/core/types/common.js +4 -1
  39. package/cache/core/types/common.js.map +1 -1
  40. package/cache/inmemory/entityStore.d.ts +10 -1
  41. package/cache/inmemory/entityStore.js +190 -29
  42. package/cache/inmemory/entityStore.js.map +1 -1
  43. package/cache/inmemory/fixPolyfills.js +9 -0
  44. package/cache/inmemory/fixPolyfills.js.map +1 -1
  45. package/cache/inmemory/fixPolyfills.native.js +12 -0
  46. package/cache/inmemory/fixPolyfills.native.js.map +1 -1
  47. package/cache/inmemory/fragmentRegistry.d.ts +1 -0
  48. package/cache/inmemory/fragmentRegistry.js +23 -14
  49. package/cache/inmemory/fragmentRegistry.js.map +1 -1
  50. package/cache/inmemory/helpers.js +20 -11
  51. package/cache/inmemory/helpers.js.map +1 -1
  52. package/cache/inmemory/inMemoryCache.js +164 -8
  53. package/cache/inmemory/inMemoryCache.js.map +1 -1
  54. package/cache/inmemory/key-extractor.js +72 -4
  55. package/cache/inmemory/key-extractor.js.map +1 -1
  56. package/cache/inmemory/object-canon.js +87 -3
  57. package/cache/inmemory/object-canon.js.map +1 -1
  58. package/cache/inmemory/policies.js +190 -43
  59. package/cache/inmemory/policies.js.map +1 -1
  60. package/cache/inmemory/reactiveVars.js +20 -2
  61. package/cache/inmemory/reactiveVars.js.map +1 -1
  62. package/cache/inmemory/readFromStore.d.ts +4 -0
  63. package/cache/inmemory/readFromStore.js +58 -9
  64. package/cache/inmemory/readFromStore.js.map +1 -1
  65. package/cache/inmemory/types.d.ts +28 -0
  66. package/cache/inmemory/types.js.map +1 -1
  67. package/cache/inmemory/writeToStore.js +152 -25
  68. package/cache/inmemory/writeToStore.js.map +1 -1
  69. package/config/jest/setup.js +2 -0
  70. package/config/jest/setup.js.map +1 -1
  71. package/core/ApolloClient.d.ts +264 -3
  72. package/core/ApolloClient.js +235 -7
  73. package/core/ApolloClient.js.map +1 -1
  74. package/core/LocalState.d.ts +4 -6
  75. package/core/LocalState.js +56 -18
  76. package/core/LocalState.js.map +1 -1
  77. package/core/ObservableQuery.d.ts +25 -0
  78. package/core/ObservableQuery.js +239 -30
  79. package/core/ObservableQuery.js.map +1 -1
  80. package/core/QueryInfo.d.ts +3 -3
  81. package/core/QueryInfo.js +118 -13
  82. package/core/QueryInfo.js.map +1 -1
  83. package/core/QueryManager.d.ts +8 -1
  84. package/core/QueryManager.js +247 -46
  85. package/core/QueryManager.js.map +1 -1
  86. package/core/core.cjs +127 -114
  87. package/core/core.cjs.map +1 -1
  88. package/core/core.cjs.native.js +127 -114
  89. package/core/equalByQuery.js +20 -1
  90. package/core/equalByQuery.js.map +1 -1
  91. package/core/index.d.ts +1 -1
  92. package/core/index.js +19 -0
  93. package/core/index.js.map +1 -1
  94. package/core/networkStatus.d.ts +39 -0
  95. package/core/networkStatus.js +39 -0
  96. package/core/networkStatus.js.map +1 -1
  97. package/core/types.d.ts +9 -0
  98. package/core/types.js.map +1 -1
  99. package/core/watchQueryOptions.d.ts +225 -1
  100. package/core/watchQueryOptions.js.map +1 -1
  101. package/dev/dev.cjs +10 -119
  102. package/dev/dev.cjs.map +1 -1
  103. package/dev/dev.cjs.native.js +10 -119
  104. package/dev/loadErrorMessageHandler.js.map +1 -1
  105. package/errors/errors.cjs +1 -1
  106. package/errors/errors.cjs.map +1 -1
  107. package/errors/errors.cjs.native.js +1 -1
  108. package/errors/index.js +14 -1
  109. package/errors/index.js.map +1 -1
  110. package/invariantErrorCodes.js +6 -8
  111. package/link/batch/batch.cjs +2 -2
  112. package/link/batch/batch.cjs.map +1 -1
  113. package/link/batch/batch.cjs.native.js +2 -2
  114. package/link/batch/batchLink.d.ts +21 -0
  115. package/link/batch/batchLink.js +2 -1
  116. package/link/batch/batchLink.js.map +1 -1
  117. package/link/batch/batching.js +24 -1
  118. package/link/batch/batching.js.map +1 -1
  119. package/link/batch-http/batch-http.cjs +3 -2
  120. package/link/batch-http/batch-http.cjs.map +1 -1
  121. package/link/batch-http/batch-http.cjs.native.js +3 -2
  122. package/link/batch-http/batchHttpLink.d.ts +4 -0
  123. package/link/batch-http/batchHttpLink.js +53 -2
  124. package/link/batch-http/batchHttpLink.js.map +1 -1
  125. package/link/context/context.cjs.map +1 -1
  126. package/link/context/index.js +1 -0
  127. package/link/context/index.js.map +1 -1
  128. package/link/core/ApolloLink.js +12 -5
  129. package/link/core/ApolloLink.js.map +1 -1
  130. package/link/core/core.cjs +5 -5
  131. package/link/core/core.cjs.map +1 -1
  132. package/link/core/core.cjs.native.js +5 -5
  133. package/link/error/error.cjs +1 -1
  134. package/link/error/error.cjs.map +1 -1
  135. package/link/error/error.cjs.native.js +1 -1
  136. package/link/error/index.d.ts +3 -0
  137. package/link/error/index.js +4 -1
  138. package/link/error/index.js.map +1 -1
  139. package/link/http/HttpLink.d.ts +0 -2
  140. package/link/http/HttpLink.js +1 -1
  141. package/link/http/HttpLink.js.map +1 -1
  142. package/link/http/checkFetcher.js.map +1 -1
  143. package/link/http/createHttpLink.js +23 -1
  144. package/link/http/createHttpLink.js.map +1 -1
  145. package/link/http/createSignalIfSupported.d.ts +5 -0
  146. package/link/http/createSignalIfSupported.js +5 -0
  147. package/link/http/createSignalIfSupported.js.map +1 -1
  148. package/link/http/http.cjs +14 -12
  149. package/link/http/http.cjs.map +1 -1
  150. package/link/http/http.cjs.native.js +14 -12
  151. package/link/http/index.js +2 -1
  152. package/link/http/index.js.map +1 -1
  153. package/link/http/iterators/async.d.ts +4 -0
  154. package/link/http/iterators/async.js +4 -0
  155. package/link/http/iterators/async.js.map +1 -1
  156. package/link/http/iterators/nodeStream.d.ts +4 -0
  157. package/link/http/iterators/nodeStream.js +4 -0
  158. package/link/http/iterators/nodeStream.js.map +1 -1
  159. package/link/http/iterators/promise.d.ts +4 -0
  160. package/link/http/iterators/promise.js +4 -0
  161. package/link/http/iterators/promise.js.map +1 -1
  162. package/link/http/iterators/reader.d.ts +4 -0
  163. package/link/http/iterators/reader.js +4 -0
  164. package/link/http/iterators/reader.js.map +1 -1
  165. package/link/http/parseAndCheckHttpResponse.js +51 -10
  166. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  167. package/link/http/responseIterator.d.ts +4 -0
  168. package/link/http/responseIterator.js +6 -0
  169. package/link/http/responseIterator.js.map +1 -1
  170. package/link/http/rewriteURIForGET.d.ts +1 -1
  171. package/link/http/rewriteURIForGET.js +10 -0
  172. package/link/http/rewriteURIForGET.js.map +1 -1
  173. package/link/http/selectHttpOptionsAndBody.d.ts +45 -0
  174. package/link/http/selectHttpOptionsAndBody.js +23 -0
  175. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  176. package/link/http/selectURI.js.map +1 -1
  177. package/link/http/serializeFetchParameter.js.map +1 -1
  178. package/link/persisted-queries/index.js +34 -4
  179. package/link/persisted-queries/index.js.map +1 -1
  180. package/link/persisted-queries/persisted-queries.cjs +4 -4
  181. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  182. package/link/persisted-queries/persisted-queries.cjs.native.js +4 -4
  183. package/link/remove-typename/remove-typename.cjs +12 -9
  184. package/link/remove-typename/remove-typename.cjs.map +1 -1
  185. package/link/remove-typename/remove-typename.cjs.native.js +12 -9
  186. package/link/remove-typename/removeTypenameFromVariables.js +12 -9
  187. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  188. package/link/retry/delayFunction.d.ts +29 -0
  189. package/link/retry/delayFunction.js +6 -0
  190. package/link/retry/delayFunction.js.map +1 -1
  191. package/link/retry/retry.cjs +5 -5
  192. package/link/retry/retry.cjs.map +1 -1
  193. package/link/retry/retry.cjs.native.js +5 -5
  194. package/link/retry/retryFunction.d.ts +20 -0
  195. package/link/retry/retryLink.d.ts +6 -0
  196. package/link/retry/retryLink.js +31 -6
  197. package/link/retry/retryLink.js.map +1 -1
  198. package/link/schema/index.d.ts +13 -0
  199. package/link/schema/index.js +3 -3
  200. package/link/schema/index.js.map +1 -1
  201. package/link/schema/schema.cjs +3 -3
  202. package/link/schema/schema.cjs.map +1 -1
  203. package/link/schema/schema.cjs.native.js +3 -3
  204. package/link/subscriptions/index.js +35 -2
  205. package/link/subscriptions/index.js.map +1 -1
  206. package/link/subscriptions/subscriptions.cjs +3 -2
  207. package/link/subscriptions/subscriptions.cjs.map +1 -1
  208. package/link/subscriptions/subscriptions.cjs.native.js +3 -2
  209. package/link/utils/createOperation.js.map +1 -1
  210. package/link/utils/filterOperationVariables.js +4 -0
  211. package/link/utils/filterOperationVariables.js.map +1 -1
  212. package/link/utils/toPromise.js.map +1 -1
  213. package/link/utils/transformOperation.js +3 -2
  214. package/link/utils/transformOperation.js.map +1 -1
  215. package/link/utils/utils.cjs +2 -2
  216. package/link/utils/utils.cjs.map +1 -1
  217. package/link/utils/utils.cjs.native.js +2 -2
  218. package/link/utils/validateOperation.js.map +1 -1
  219. package/link/ws/index.d.ts +12 -0
  220. package/link/ws/index.js +1 -1
  221. package/link/ws/index.js.map +1 -1
  222. package/link/ws/ws.cjs +1 -1
  223. package/link/ws/ws.cjs.map +1 -1
  224. package/link/ws/ws.cjs.native.js +1 -1
  225. package/package.json +50 -38
  226. package/react/cache/QueryReference.d.ts +18 -10
  227. package/react/cache/QueryReference.js +52 -8
  228. package/react/cache/QueryReference.js.map +1 -1
  229. package/react/cache/SuspenseCache.d.ts +10 -0
  230. package/react/cache/SuspenseCache.js +1 -2
  231. package/react/cache/SuspenseCache.js.map +1 -1
  232. package/react/cache/getSuspenseCache.js.map +1 -1
  233. package/react/cache/types.d.ts +3 -0
  234. package/react/cache/types.js.map +1 -1
  235. package/react/context/ApolloContext.d.ts +5 -0
  236. package/react/context/ApolloContext.js +10 -3
  237. package/react/context/ApolloContext.js.map +1 -1
  238. package/react/context/context.cjs +1 -3
  239. package/react/context/context.cjs.map +1 -1
  240. package/react/context/context.cjs.native.js +1 -3
  241. package/react/hoc/graphql.js.map +1 -1
  242. package/react/hoc/hoc-utils.js +3 -1
  243. package/react/hoc/hoc-utils.js.map +1 -1
  244. package/react/hoc/hoc.cjs +9 -17
  245. package/react/hoc/hoc.cjs.map +1 -1
  246. package/react/hoc/hoc.cjs.native.js +9 -17
  247. package/react/hoc/mutation-hoc.js +9 -4
  248. package/react/hoc/mutation-hoc.js.map +1 -1
  249. package/react/hoc/query-hoc.js +10 -4
  250. package/react/hoc/query-hoc.js.map +1 -1
  251. package/react/hoc/subscription-hoc.js +10 -4
  252. package/react/hoc/subscription-hoc.js.map +1 -1
  253. package/react/hoc/withApollo.js +3 -4
  254. package/react/hoc/withApollo.js.map +1 -1
  255. package/react/hooks/hooks.cjs +138 -66
  256. package/react/hooks/hooks.cjs.map +1 -1
  257. package/react/hooks/hooks.cjs.native.js +138 -66
  258. package/react/hooks/index.d.ts +2 -0
  259. package/react/hooks/index.js +1 -0
  260. package/react/hooks/index.js.map +1 -1
  261. package/react/hooks/internal/__use.js +5 -0
  262. package/react/hooks/internal/__use.js.map +1 -1
  263. package/react/hooks/internal/index.d.ts +1 -0
  264. package/react/hooks/internal/index.js +2 -0
  265. package/react/hooks/internal/index.js.map +1 -1
  266. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  267. package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -3
  268. package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
  269. package/react/hooks/internal/useRenderGuard.d.ts +2 -0
  270. package/react/hooks/internal/useRenderGuard.js +17 -0
  271. package/react/hooks/internal/useRenderGuard.js.map +1 -0
  272. package/react/hooks/useBackgroundQuery.js +14 -11
  273. package/react/hooks/useBackgroundQuery.js.map +1 -1
  274. package/react/hooks/useFragment.js +4 -3
  275. package/react/hooks/useFragment.js.map +1 -1
  276. package/react/hooks/useLazyQuery.js +13 -4
  277. package/react/hooks/useLazyQuery.js.map +1 -1
  278. package/react/hooks/useLoadableQuery.d.ts +30 -0
  279. package/react/hooks/useLoadableQuery.js +61 -0
  280. package/react/hooks/useLoadableQuery.js.map +1 -0
  281. package/react/hooks/useMutation.js +8 -3
  282. package/react/hooks/useMutation.js.map +1 -1
  283. package/react/hooks/useQuery.d.ts +11 -0
  284. package/react/hooks/useQuery.js +138 -6
  285. package/react/hooks/useQuery.js.map +1 -1
  286. package/react/hooks/useReactiveVar.js +5 -0
  287. package/react/hooks/useReactiveVar.js.map +1 -1
  288. package/react/hooks/useReadQuery.d.ts +19 -0
  289. package/react/hooks/useReadQuery.js +4 -10
  290. package/react/hooks/useReadQuery.js.map +1 -1
  291. package/react/hooks/useSubscription.js +5 -0
  292. package/react/hooks/useSubscription.js.map +1 -1
  293. package/react/hooks/useSuspenseQuery.js +22 -22
  294. package/react/hooks/useSuspenseQuery.js.map +1 -1
  295. package/react/hooks/useSyncExternalStore.js +53 -1
  296. package/react/hooks/useSyncExternalStore.js.map +1 -1
  297. package/react/parser/index.d.ts +3 -0
  298. package/react/parser/index.js +13 -6
  299. package/react/parser/index.js.map +1 -1
  300. package/react/parser/parser.cjs +11 -5
  301. package/react/parser/parser.cjs.map +1 -1
  302. package/react/parser/parser.cjs.native.js +11 -5
  303. package/react/ssr/RenderPromises.js +21 -1
  304. package/react/ssr/RenderPromises.js.map +1 -1
  305. package/react/ssr/getDataFromTree.js +18 -3
  306. package/react/ssr/getDataFromTree.js.map +1 -1
  307. package/react/ssr/ssr.cjs +6 -4
  308. package/react/ssr/ssr.cjs.map +1 -1
  309. package/react/ssr/ssr.cjs.native.js +6 -4
  310. package/react/types/types.d.ts +123 -1
  311. package/react/types/types.js.map +1 -1
  312. package/testing/core/core.cjs +14 -11
  313. package/testing/core/core.cjs.map +1 -1
  314. package/testing/core/core.cjs.native.js +14 -11
  315. package/testing/core/itAsync.d.ts +1 -1
  316. package/testing/core/itAsync.js.map +1 -1
  317. package/testing/core/mocking/mockFetch.d.ts +2 -2
  318. package/testing/core/mocking/mockFetch.js +8 -4
  319. package/testing/core/mocking/mockFetch.js.map +1 -1
  320. package/testing/core/mocking/mockLink.d.ts +1 -1
  321. package/testing/core/mocking/mockLink.js +17 -7
  322. package/testing/core/mocking/mockLink.js.map +1 -1
  323. package/testing/core/mocking/mockQueryManager.js +2 -0
  324. package/testing/core/mocking/mockQueryManager.js.map +1 -1
  325. package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
  326. package/testing/core/mocking/mockSubscriptionLink.js +1 -1
  327. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  328. package/testing/core/mocking/mockWatchQuery.js +1 -1
  329. package/testing/core/mocking/mockWatchQuery.js.map +1 -1
  330. package/testing/core/observableToPromise.d.ts +17 -3
  331. package/testing/core/observableToPromise.js +5 -0
  332. package/testing/core/observableToPromise.js.map +1 -1
  333. package/testing/core/subscribeAndCount.js +3 -0
  334. package/testing/core/subscribeAndCount.js.map +1 -1
  335. package/testing/core/wait.js +2 -2
  336. package/testing/core/wait.js.map +1 -1
  337. package/testing/core/withConsoleSpy.d.ts +3 -0
  338. package/testing/core/withConsoleSpy.js +7 -1
  339. package/testing/core/withConsoleSpy.js.map +1 -1
  340. package/testing/core/wrap.js +2 -0
  341. package/testing/core/wrap.js.map +1 -1
  342. package/testing/internal/ObservableStream.js +14 -14
  343. package/testing/internal/ObservableStream.js.map +1 -1
  344. package/testing/internal/disposables/disableActWarnings.d.ts +10 -0
  345. package/testing/internal/disposables/disableActWarnings.js +15 -0
  346. package/testing/internal/disposables/disableActWarnings.js.map +1 -0
  347. package/testing/internal/disposables/index.d.ts +1 -0
  348. package/testing/internal/disposables/index.js +1 -0
  349. package/testing/internal/disposables/index.js.map +1 -1
  350. package/testing/internal/disposables/spyOnConsole.d.ts +1 -0
  351. package/testing/internal/disposables/spyOnConsole.js +2 -0
  352. package/testing/internal/disposables/spyOnConsole.js.map +1 -1
  353. package/testing/internal/disposables/withCleanup.d.ts +1 -0
  354. package/testing/internal/disposables/withCleanup.js +3 -0
  355. package/testing/internal/disposables/withCleanup.js.map +1 -1
  356. package/testing/internal/profile/Render.d.ts +32 -1
  357. package/testing/internal/profile/Render.js +14 -2
  358. package/testing/internal/profile/Render.js.map +1 -1
  359. package/testing/internal/profile/context.d.ts +10 -0
  360. package/testing/internal/profile/context.js +14 -0
  361. package/testing/internal/profile/context.js.map +1 -0
  362. package/testing/internal/profile/index.d.ts +2 -2
  363. package/testing/internal/profile/index.js +1 -1
  364. package/testing/internal/profile/index.js.map +1 -1
  365. package/testing/internal/profile/profile.d.ts +67 -13
  366. package/testing/internal/profile/profile.js +153 -79
  367. package/testing/internal/profile/profile.js.map +1 -1
  368. package/testing/internal/profile/traces.d.ts +4 -0
  369. package/testing/internal/profile/traces.js +9 -5
  370. package/testing/internal/profile/traces.js.map +1 -1
  371. package/testing/matchers/ProfiledComponent.js +29 -26
  372. package/testing/matchers/ProfiledComponent.js.map +1 -1
  373. package/testing/matchers/index.js +2 -0
  374. package/testing/matchers/index.js.map +1 -1
  375. package/testing/matchers/toBeGarbageCollected.d.ts +8 -0
  376. package/testing/matchers/toBeGarbageCollected.js +48 -0
  377. package/testing/matchers/toBeGarbageCollected.js.map +1 -0
  378. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
  379. package/testing/matchers/toMatchDocument.js.map +1 -1
  380. package/testing/react/MockedProvider.d.ts +5 -1
  381. package/testing/react/MockedProvider.js +6 -2
  382. package/testing/react/MockedProvider.js.map +1 -1
  383. package/testing/testing.cjs +4 -2
  384. package/testing/testing.cjs.map +1 -1
  385. package/testing/testing.cjs.native.js +4 -2
  386. package/utilities/common/arrays.js +1 -0
  387. package/utilities/common/arrays.js.map +1 -1
  388. package/utilities/common/canUse.js +16 -1
  389. package/utilities/common/canUse.js.map +1 -1
  390. package/utilities/common/canonicalStringify.d.ts +17 -0
  391. package/utilities/common/canonicalStringify.js +41 -0
  392. package/utilities/common/canonicalStringify.js.map +1 -1
  393. package/utilities/common/cloneDeep.d.ts +3 -0
  394. package/utilities/common/cloneDeep.js +5 -0
  395. package/utilities/common/cloneDeep.js.map +1 -1
  396. package/utilities/common/compact.d.ts +4 -0
  397. package/utilities/common/compact.js +4 -0
  398. package/utilities/common/compact.js.map +1 -1
  399. package/utilities/common/errorHandling.js +1 -3
  400. package/utilities/common/errorHandling.js.map +1 -1
  401. package/utilities/common/incrementalResult.js +3 -0
  402. package/utilities/common/incrementalResult.js.map +1 -1
  403. package/utilities/common/makeUniqueId.js +2 -0
  404. package/utilities/common/makeUniqueId.js.map +1 -1
  405. package/utilities/common/maybeDeepFreeze.js +3 -0
  406. package/utilities/common/maybeDeepFreeze.js.map +1 -1
  407. package/utilities/common/mergeDeep.js +12 -1
  408. package/utilities/common/mergeDeep.js.map +1 -1
  409. package/utilities/common/mergeOptions.d.ts +1 -1
  410. package/utilities/common/mergeOptions.js.map +1 -1
  411. package/utilities/common/omitDeep.js.map +1 -1
  412. package/utilities/globals/global.js +7 -1
  413. package/utilities/globals/global.js.map +1 -1
  414. package/utilities/globals/globals.cjs +4 -5
  415. package/utilities/globals/globals.cjs.map +1 -1
  416. package/utilities/globals/globals.cjs.native.js +4 -5
  417. package/utilities/globals/index.d.ts +4 -0
  418. package/utilities/globals/index.js +7 -0
  419. package/utilities/globals/index.js.map +1 -1
  420. package/utilities/globals/invariantWrappers.d.ts +40 -0
  421. package/utilities/globals/invariantWrappers.js +11 -3
  422. package/utilities/globals/invariantWrappers.js.map +1 -1
  423. package/utilities/globals/maybe.js.map +1 -1
  424. package/utilities/graphql/DocumentTransform.d.ts +6 -5
  425. package/utilities/graphql/DocumentTransform.js +48 -27
  426. package/utilities/graphql/DocumentTransform.js.map +1 -1
  427. package/utilities/graphql/directives.js +3 -0
  428. package/utilities/graphql/directives.js.map +1 -1
  429. package/utilities/graphql/fragments.d.ts +25 -0
  430. package/utilities/graphql/fragments.js +36 -0
  431. package/utilities/graphql/fragments.js.map +1 -1
  432. package/utilities/graphql/getFromAST.d.ts +5 -0
  433. package/utilities/graphql/getFromAST.js +9 -0
  434. package/utilities/graphql/getFromAST.js.map +1 -1
  435. package/utilities/graphql/print.js +4 -5
  436. package/utilities/graphql/print.js.map +1 -1
  437. package/utilities/graphql/storeUtils.d.ts +14 -0
  438. package/utilities/graphql/storeUtils.js +8 -2
  439. package/utilities/graphql/storeUtils.js.map +1 -1
  440. package/utilities/graphql/transform.js +106 -7
  441. package/utilities/graphql/transform.js.map +1 -1
  442. package/utilities/index.d.ts +2 -0
  443. package/utilities/index.js.map +1 -1
  444. package/utilities/observables/Concast.d.ts +1 -1
  445. package/utilities/observables/Concast.js +85 -2
  446. package/utilities/observables/Concast.js.map +1 -1
  447. package/utilities/observables/Observable.js +6 -0
  448. package/utilities/observables/Observable.js.map +1 -1
  449. package/utilities/observables/asyncMap.js +12 -3
  450. package/utilities/observables/asyncMap.js.map +1 -1
  451. package/utilities/observables/iteration.js +3 -0
  452. package/utilities/observables/iteration.js.map +1 -1
  453. package/utilities/observables/subclassing.js +14 -0
  454. package/utilities/observables/subclassing.js.map +1 -1
  455. package/utilities/policies/pagination.js +47 -3
  456. package/utilities/policies/pagination.js.map +1 -1
  457. package/utilities/promises/decoration.js +1 -0
  458. package/utilities/promises/decoration.js.map +1 -1
  459. package/utilities/subscriptions/relay/index.js.map +1 -1
  460. package/utilities/subscriptions/relay/relay.cjs +9 -8
  461. package/utilities/subscriptions/relay/relay.cjs.map +1 -1
  462. package/utilities/subscriptions/relay/relay.cjs.native.js +9 -8
  463. package/utilities/subscriptions/urql/index.js.map +1 -1
  464. package/utilities/subscriptions/urql/urql.cjs +9 -8
  465. package/utilities/subscriptions/urql/urql.cjs.map +1 -1
  466. package/utilities/subscriptions/urql/urql.cjs.native.js +9 -8
  467. package/utilities/types/DeepOmit.js.map +1 -1
  468. package/utilities/types/DeepPartial.d.ts +1 -1
  469. package/utilities/types/DeepPartial.js +4 -0
  470. package/utilities/types/DeepPartial.js.map +1 -1
  471. package/utilities/types/IsStrictlyAny.js.map +1 -1
  472. package/utilities/types/OnlyRequiredProperties.d.ts +7 -0
  473. package/utilities/types/OnlyRequiredProperties.js +2 -0
  474. package/utilities/types/OnlyRequiredProperties.js.map +1 -0
  475. package/utilities/types/TODO.d.ts +3 -0
  476. package/utilities/types/TODO.js +2 -0
  477. package/utilities/types/TODO.js.map +1 -0
  478. package/utilities/utilities.cjs +61 -53
  479. package/utilities/utilities.cjs.map +1 -1
  480. package/utilities/utilities.cjs.native.js +61 -53
  481. package/version.js +1 -1
  482. package/cache/core/cache.d.ts.map +0 -1
  483. package/cache/core/types/Cache.d.ts.map +0 -1
  484. package/cache/core/types/DataProxy.d.ts.map +0 -1
  485. package/cache/core/types/common.d.ts.map +0 -1
  486. package/cache/index.d.ts.map +0 -1
  487. package/cache/inmemory/entityStore.d.ts.map +0 -1
  488. package/cache/inmemory/fixPolyfills.d.ts.map +0 -1
  489. package/cache/inmemory/fixPolyfills.native.d.ts.map +0 -1
  490. package/cache/inmemory/fragmentRegistry.d.ts.map +0 -1
  491. package/cache/inmemory/helpers.d.ts.map +0 -1
  492. package/cache/inmemory/inMemoryCache.d.ts.map +0 -1
  493. package/cache/inmemory/key-extractor.d.ts.map +0 -1
  494. package/cache/inmemory/object-canon.d.ts.map +0 -1
  495. package/cache/inmemory/policies.d.ts.map +0 -1
  496. package/cache/inmemory/reactiveVars.d.ts.map +0 -1
  497. package/cache/inmemory/readFromStore.d.ts.map +0 -1
  498. package/cache/inmemory/types.d.ts.map +0 -1
  499. package/cache/inmemory/writeToStore.d.ts.map +0 -1
  500. package/config/jest/setup.d.ts.map +0 -1
  501. package/core/ApolloClient.d.ts.map +0 -1
  502. package/core/LocalState.d.ts.map +0 -1
  503. package/core/ObservableQuery.d.ts.map +0 -1
  504. package/core/QueryInfo.d.ts.map +0 -1
  505. package/core/QueryManager.d.ts.map +0 -1
  506. package/core/equalByQuery.d.ts.map +0 -1
  507. package/core/index.d.ts.map +0 -1
  508. package/core/networkStatus.d.ts.map +0 -1
  509. package/core/types.d.ts.map +0 -1
  510. package/core/watchQueryOptions.d.ts.map +0 -1
  511. package/dev/index.d.ts.map +0 -1
  512. package/dev/loadDevMessages.d.ts.map +0 -1
  513. package/dev/loadErrorMessageHandler.d.ts.map +0 -1
  514. package/dev/loadErrorMessages.d.ts.map +0 -1
  515. package/errors/index.d.ts.map +0 -1
  516. package/index.d.ts.map +0 -1
  517. package/invariantErrorCodes.d.ts.map +0 -1
  518. package/link/batch/batchLink.d.ts.map +0 -1
  519. package/link/batch/batching.d.ts.map +0 -1
  520. package/link/batch/index.d.ts.map +0 -1
  521. package/link/batch-http/batchHttpLink.d.ts.map +0 -1
  522. package/link/batch-http/index.d.ts.map +0 -1
  523. package/link/context/index.d.ts.map +0 -1
  524. package/link/core/ApolloLink.d.ts.map +0 -1
  525. package/link/core/concat.d.ts.map +0 -1
  526. package/link/core/empty.d.ts.map +0 -1
  527. package/link/core/execute.d.ts.map +0 -1
  528. package/link/core/from.d.ts.map +0 -1
  529. package/link/core/index.d.ts.map +0 -1
  530. package/link/core/split.d.ts.map +0 -1
  531. package/link/core/types.d.ts.map +0 -1
  532. package/link/error/index.d.ts.map +0 -1
  533. package/link/http/HttpLink.d.ts.map +0 -1
  534. package/link/http/checkFetcher.d.ts.map +0 -1
  535. package/link/http/createHttpLink.d.ts.map +0 -1
  536. package/link/http/createSignalIfSupported.d.ts.map +0 -1
  537. package/link/http/index.d.ts.map +0 -1
  538. package/link/http/iterators/async.d.ts.map +0 -1
  539. package/link/http/iterators/nodeStream.d.ts.map +0 -1
  540. package/link/http/iterators/promise.d.ts.map +0 -1
  541. package/link/http/iterators/reader.d.ts.map +0 -1
  542. package/link/http/parseAndCheckHttpResponse.d.ts.map +0 -1
  543. package/link/http/responseIterator.d.ts.map +0 -1
  544. package/link/http/rewriteURIForGET.d.ts.map +0 -1
  545. package/link/http/selectHttpOptionsAndBody.d.ts.map +0 -1
  546. package/link/http/selectURI.d.ts.map +0 -1
  547. package/link/http/serializeFetchParameter.d.ts.map +0 -1
  548. package/link/persisted-queries/index.d.ts.map +0 -1
  549. package/link/remove-typename/index.d.ts.map +0 -1
  550. package/link/remove-typename/removeTypenameFromVariables.d.ts.map +0 -1
  551. package/link/retry/delayFunction.d.ts.map +0 -1
  552. package/link/retry/index.d.ts.map +0 -1
  553. package/link/retry/retryFunction.d.ts.map +0 -1
  554. package/link/retry/retryLink.d.ts.map +0 -1
  555. package/link/schema/index.d.ts.map +0 -1
  556. package/link/subscriptions/index.d.ts.map +0 -1
  557. package/link/utils/createOperation.d.ts.map +0 -1
  558. package/link/utils/filterOperationVariables.d.ts.map +0 -1
  559. package/link/utils/fromError.d.ts.map +0 -1
  560. package/link/utils/fromPromise.d.ts.map +0 -1
  561. package/link/utils/index.d.ts.map +0 -1
  562. package/link/utils/throwServerError.d.ts.map +0 -1
  563. package/link/utils/toPromise.d.ts.map +0 -1
  564. package/link/utils/transformOperation.d.ts.map +0 -1
  565. package/link/utils/validateOperation.d.ts.map +0 -1
  566. package/link/ws/index.d.ts.map +0 -1
  567. package/react/cache/QueryReference.d.ts.map +0 -1
  568. package/react/cache/SuspenseCache.d.ts.map +0 -1
  569. package/react/cache/getSuspenseCache.d.ts.map +0 -1
  570. package/react/cache/index.d.ts.map +0 -1
  571. package/react/cache/types.d.ts.map +0 -1
  572. package/react/components/Mutation.d.ts.map +0 -1
  573. package/react/components/Query.d.ts.map +0 -1
  574. package/react/components/Subscription.d.ts.map +0 -1
  575. package/react/components/index.d.ts.map +0 -1
  576. package/react/components/types.d.ts.map +0 -1
  577. package/react/context/ApolloConsumer.d.ts.map +0 -1
  578. package/react/context/ApolloContext.d.ts.map +0 -1
  579. package/react/context/ApolloProvider.d.ts.map +0 -1
  580. package/react/context/index.d.ts.map +0 -1
  581. package/react/hoc/graphql.d.ts.map +0 -1
  582. package/react/hoc/hoc-utils.d.ts.map +0 -1
  583. package/react/hoc/index.d.ts.map +0 -1
  584. package/react/hoc/mutation-hoc.d.ts.map +0 -1
  585. package/react/hoc/query-hoc.d.ts.map +0 -1
  586. package/react/hoc/subscription-hoc.d.ts.map +0 -1
  587. package/react/hoc/types.d.ts.map +0 -1
  588. package/react/hoc/withApollo.d.ts.map +0 -1
  589. package/react/hooks/constants.d.ts.map +0 -1
  590. package/react/hooks/index.d.ts.map +0 -1
  591. package/react/hooks/internal/__use.d.ts.map +0 -1
  592. package/react/hooks/internal/index.d.ts.map +0 -1
  593. package/react/hooks/internal/useDeepMemo.d.ts.map +0 -1
  594. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +0 -1
  595. package/react/hooks/useApolloClient.d.ts.map +0 -1
  596. package/react/hooks/useBackgroundQuery.d.ts.map +0 -1
  597. package/react/hooks/useFragment.d.ts.map +0 -1
  598. package/react/hooks/useLazyQuery.d.ts.map +0 -1
  599. package/react/hooks/useMutation.d.ts.map +0 -1
  600. package/react/hooks/useQuery.d.ts.map +0 -1
  601. package/react/hooks/useReactiveVar.d.ts.map +0 -1
  602. package/react/hooks/useReadQuery.d.ts.map +0 -1
  603. package/react/hooks/useSubscription.d.ts.map +0 -1
  604. package/react/hooks/useSuspenseQuery.d.ts.map +0 -1
  605. package/react/hooks/useSyncExternalStore.d.ts.map +0 -1
  606. package/react/index.d.ts.map +0 -1
  607. package/react/parser/index.d.ts.map +0 -1
  608. package/react/ssr/RenderPromises.d.ts.map +0 -1
  609. package/react/ssr/getDataFromTree.d.ts.map +0 -1
  610. package/react/ssr/index.d.ts.map +0 -1
  611. package/react/ssr/renderToStringWithData.d.ts.map +0 -1
  612. package/react/types/types.d.ts.map +0 -1
  613. package/testing/core/index.d.ts.map +0 -1
  614. package/testing/core/itAsync.d.ts.map +0 -1
  615. package/testing/core/mocking/mockClient.d.ts.map +0 -1
  616. package/testing/core/mocking/mockFetch.d.ts.map +0 -1
  617. package/testing/core/mocking/mockLink.d.ts.map +0 -1
  618. package/testing/core/mocking/mockQueryManager.d.ts.map +0 -1
  619. package/testing/core/mocking/mockSubscriptionLink.d.ts.map +0 -1
  620. package/testing/core/mocking/mockWatchQuery.d.ts.map +0 -1
  621. package/testing/core/observableToPromise.d.ts.map +0 -1
  622. package/testing/core/subscribeAndCount.d.ts.map +0 -1
  623. package/testing/core/wait.d.ts.map +0 -1
  624. package/testing/core/withConsoleSpy.d.ts.map +0 -1
  625. package/testing/core/wrap.d.ts.map +0 -1
  626. package/testing/index.d.ts.map +0 -1
  627. package/testing/internal/ObservableStream.d.ts.map +0 -1
  628. package/testing/internal/disposables/index.d.ts.map +0 -1
  629. package/testing/internal/disposables/spyOnConsole.d.ts.map +0 -1
  630. package/testing/internal/disposables/withCleanup.d.ts.map +0 -1
  631. package/testing/internal/index.d.ts.map +0 -1
  632. package/testing/internal/profile/Render.d.ts.map +0 -1
  633. package/testing/internal/profile/index.d.ts.map +0 -1
  634. package/testing/internal/profile/profile.d.ts.map +0 -1
  635. package/testing/internal/profile/traces.d.ts.map +0 -1
  636. package/testing/matchers/ProfiledComponent.d.ts.map +0 -1
  637. package/testing/matchers/index.d.ts.map +0 -1
  638. package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts.map +0 -1
  639. package/testing/matchers/toMatchDocument.d.ts.map +0 -1
  640. package/testing/react/MockedProvider.d.ts.map +0 -1
  641. package/utilities/common/arrays.d.ts.map +0 -1
  642. package/utilities/common/canUse.d.ts.map +0 -1
  643. package/utilities/common/canonicalStringify.d.ts.map +0 -1
  644. package/utilities/common/cloneDeep.d.ts.map +0 -1
  645. package/utilities/common/compact.d.ts.map +0 -1
  646. package/utilities/common/errorHandling.d.ts.map +0 -1
  647. package/utilities/common/filterInPlace.d.ts +0 -2
  648. package/utilities/common/filterInPlace.d.ts.map +0 -1
  649. package/utilities/common/filterInPlace.js +0 -11
  650. package/utilities/common/filterInPlace.js.map +0 -1
  651. package/utilities/common/incrementalResult.d.ts.map +0 -1
  652. package/utilities/common/makeUniqueId.d.ts.map +0 -1
  653. package/utilities/common/maybeDeepFreeze.d.ts.map +0 -1
  654. package/utilities/common/mergeDeep.d.ts.map +0 -1
  655. package/utilities/common/mergeOptions.d.ts.map +0 -1
  656. package/utilities/common/objects.d.ts.map +0 -1
  657. package/utilities/common/omitDeep.d.ts.map +0 -1
  658. package/utilities/common/stringifyForDisplay.d.ts.map +0 -1
  659. package/utilities/common/stripTypename.d.ts.map +0 -1
  660. package/utilities/globals/global.d.ts.map +0 -1
  661. package/utilities/globals/index.d.ts.map +0 -1
  662. package/utilities/globals/invariantWrappers.d.ts.map +0 -1
  663. package/utilities/globals/maybe.d.ts.map +0 -1
  664. package/utilities/graphql/DocumentTransform.d.ts.map +0 -1
  665. package/utilities/graphql/directives.d.ts.map +0 -1
  666. package/utilities/graphql/fragments.d.ts.map +0 -1
  667. package/utilities/graphql/getFromAST.d.ts.map +0 -1
  668. package/utilities/graphql/operations.d.ts.map +0 -1
  669. package/utilities/graphql/print.d.ts.map +0 -1
  670. package/utilities/graphql/storeUtils.d.ts.map +0 -1
  671. package/utilities/graphql/transform.d.ts.map +0 -1
  672. package/utilities/index.d.ts.map +0 -1
  673. package/utilities/observables/Concast.d.ts.map +0 -1
  674. package/utilities/observables/Observable.d.ts.map +0 -1
  675. package/utilities/observables/asyncMap.d.ts.map +0 -1
  676. package/utilities/observables/iteration.d.ts.map +0 -1
  677. package/utilities/observables/subclassing.d.ts.map +0 -1
  678. package/utilities/policies/pagination.d.ts.map +0 -1
  679. package/utilities/promises/decoration.d.ts.map +0 -1
  680. package/utilities/subscriptions/relay/index.d.ts.map +0 -1
  681. package/utilities/subscriptions/shared.d.ts.map +0 -1
  682. package/utilities/subscriptions/urql/index.d.ts.map +0 -1
  683. package/utilities/types/DeepOmit.d.ts.map +0 -1
  684. package/utilities/types/DeepPartial.d.ts.map +0 -1
  685. package/utilities/types/IsStrictlyAny.d.ts.map +0 -1
  686. package/utilities/types/Primitive.d.ts.map +0 -1
  687. package/version.d.ts.map +0 -1
@@ -41,7 +41,8 @@ var realHook$1 = React__namespace[uSESKey];
41
41
  var useSyncExternalStore = realHook$1 ||
42
42
  (function (subscribe, getSnapshot, getServerSnapshot) {
43
43
  var value = getSnapshot();
44
- if (globalThis.__DEV__ !== false &&
44
+ if (
45
+ globalThis.__DEV__ !== false &&
45
46
  !didWarnUncachedGetSnapshot &&
46
47
  value !== getSnapshot()) {
47
48
  didWarnUncachedGetSnapshot = true;
@@ -99,7 +100,7 @@ function useInternalState(client, query) {
99
100
  state.forceUpdateState = React__namespace.useReducer(function (tick) { return tick + 1; }, 0)[1];
100
101
  return state;
101
102
  }
102
- var InternalState = (function () {
103
+ var InternalState = (function () {
103
104
  function InternalState(client, query, previous) {
104
105
  var _this = this;
105
106
  this.client = client;
@@ -126,7 +127,7 @@ var InternalState = (function () {
126
127
  }
127
128
  }
128
129
  InternalState.prototype.forceUpdateState = function () {
129
- globalThis.__DEV__ !== false && globals.invariant.warn(50);
130
+ globalThis.__DEV__ !== false && globals.invariant.warn(51);
130
131
  };
131
132
  InternalState.prototype.executeQuery = function (options) {
132
133
  var _this = this;
@@ -249,7 +250,8 @@ var InternalState = (function () {
249
250
  InternalState.prototype.createWatchQueryOptions = function (_a) {
250
251
  var _b;
251
252
  if (_a === void 0) { _a = {}; }
252
- var skip = _a.skip; _a.ssr; _a.onCompleted; _a.onError; _a.defaultOptions; var otherOptions = tslib.__rest(_a, ["skip", "ssr", "onCompleted", "onError", "defaultOptions"]);
253
+ var skip = _a.skip; _a.ssr; _a.onCompleted; _a.onError; _a.defaultOptions;
254
+ var otherOptions = tslib.__rest(_a, ["skip", "ssr", "onCompleted", "onError", "defaultOptions"]);
253
255
  var watchQueryOptions = Object.assign(otherOptions, { query: this.query });
254
256
  if (this.renderPromises &&
255
257
  (watchQueryOptions.fetchPolicy === "network-only" ||
@@ -335,8 +337,8 @@ var InternalState = (function () {
335
337
  }
336
338
  };
337
339
  InternalState.prototype.toApolloError = function (result) {
338
- return utilities.isNonEmptyArray(result.errors)
339
- ? new errors.ApolloError({ graphQLErrors: result.errors })
340
+ return utilities.isNonEmptyArray(result.errors) ?
341
+ new errors.ApolloError({ graphQLErrors: result.errors })
340
342
  : result.error;
341
343
  };
342
344
  InternalState.prototype.getCurrentResult = function () {
@@ -416,10 +418,10 @@ function useLazyQuery(query, options) {
416
418
  }, []);
417
419
  Object.assign(result, eagerMethods);
418
420
  var execute = React__namespace.useCallback(function (executeOptions) {
419
- execOptionsRef.current = executeOptions
420
- ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
421
- fetchPolicy: initialFetchPolicy,
422
- };
421
+ execOptionsRef.current =
422
+ executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
423
+ fetchPolicy: initialFetchPolicy,
424
+ };
423
425
  var options = utilities.mergeOptions(optionsRef.current, tslib.__assign({ query: queryRef.current }, execOptionsRef.current));
424
426
  var promise = internalState
425
427
  .executeQuery(tslib.__assign(tslib.__assign({}, options), { skip: false }))
@@ -472,8 +474,8 @@ function useMutation(mutation, options) {
472
474
  .then(function (response) {
473
475
  var _a, _b;
474
476
  var data = response.data, errors$1 = response.errors;
475
- var error = errors$1 && errors$1.length > 0
476
- ? new errors.ApolloError({ graphQLErrors: errors$1 })
477
+ var error = errors$1 && errors$1.length > 0 ?
478
+ new errors.ApolloError({ graphQLErrors: errors$1 })
477
479
  : void 0;
478
480
  var onError = executeOptions.onError || ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError);
479
481
  if (error && onError) {
@@ -522,7 +524,9 @@ function useMutation(mutation, options) {
522
524
  }, []);
523
525
  var reset = React__namespace.useCallback(function () {
524
526
  if (ref.current.isMounted) {
525
- setResult({ called: false, loading: false, client: client });
527
+ var result_3 = { called: false, loading: false, client: client };
528
+ Object.assign(ref.current, { mutationId: 0, result: result_3 });
529
+ setResult(result_3);
526
530
  }
527
531
  }, []);
528
532
  React__namespace.useEffect(function () {
@@ -695,9 +699,9 @@ function useFragment(options) {
695
699
  var latestDiff = cache.diff(diffOptions);
696
700
  var getSnapshot = function () {
697
701
  var latestDiffToResult = diffToResult(latestDiff);
698
- return resultRef.current &&
699
- equality.equal(resultRef.current.data, latestDiffToResult.data)
700
- ? resultRef.current
702
+ return (resultRef.current &&
703
+ equality.equal(resultRef.current.data, latestDiffToResult.data)) ?
704
+ resultRef.current
701
705
  : (resultRef.current = latestDiffToResult);
702
706
  };
703
707
  return useSyncExternalStore(function (forceUpdate) {
@@ -733,6 +737,18 @@ function useDeepMemo(memoFn, deps) {
733
737
  return ref.current.value;
734
738
  }
735
739
 
740
+ function getRenderDispatcher() {
741
+ var _a, _b;
742
+ return (_b = (_a = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current;
743
+ }
744
+ var RenderDispatcher = null;
745
+ function useRenderGuard() {
746
+ RenderDispatcher = getRenderDispatcher();
747
+ return React__namespace.useCallback(function () {
748
+ return (RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher());
749
+ }, []);
750
+ }
751
+
736
752
  var useKey = "use";
737
753
  var realHook = React__namespace[useKey];
738
754
  var __use = realHook ||
@@ -749,12 +765,27 @@ var __use = realHook ||
749
765
  };
750
766
 
751
767
  var QUERY_REFERENCE_SYMBOL = Symbol();
768
+ var PROMISE_SYMBOL = Symbol();
752
769
  function wrapQueryRef(internalQueryRef) {
753
770
  var _a;
754
- return _a = {}, _a[QUERY_REFERENCE_SYMBOL] = internalQueryRef, _a;
771
+ return _a = {},
772
+ _a[QUERY_REFERENCE_SYMBOL] = internalQueryRef,
773
+ _a[PROMISE_SYMBOL] = internalQueryRef.promise,
774
+ _a;
755
775
  }
756
776
  function unwrapQueryRef(queryRef) {
757
- return queryRef[QUERY_REFERENCE_SYMBOL];
777
+ var internalQueryRef = queryRef[QUERY_REFERENCE_SYMBOL];
778
+ return [
779
+ internalQueryRef,
780
+ function () {
781
+ return internalQueryRef.promise.status === "fulfilled" ?
782
+ internalQueryRef.promise
783
+ : queryRef[PROMISE_SYMBOL];
784
+ },
785
+ ];
786
+ }
787
+ function updateWrappedQueryRef(queryRef, promise) {
788
+ queryRef[PROMISE_SYMBOL] = promise;
758
789
  }
759
790
  var OBSERVED_CHANGED_OPTIONS = [
760
791
  "canonizeResults",
@@ -764,9 +795,10 @@ var OBSERVED_CHANGED_OPTIONS = [
764
795
  "refetchWritePolicy",
765
796
  "returnPartialData",
766
797
  ];
767
- var InternalQueryReference = (function () {
798
+ var InternalQueryReference = (function () {
768
799
  function InternalQueryReference(observable, options) {
769
800
  var _this = this;
801
+ this.key = {};
770
802
  this.listeners = new Set();
771
803
  this.status = "loading";
772
804
  this.references = 0;
@@ -775,7 +807,6 @@ var InternalQueryReference = (function () {
775
807
  this.dispose = this.dispose.bind(this);
776
808
  this.observable = observable;
777
809
  this.result = observable.getCurrentResult(false);
778
- this.key = options.key;
779
810
  if (options.onDispose) {
780
811
  this.onDispose = options.onDispose;
781
812
  }
@@ -786,10 +817,10 @@ var InternalQueryReference = (function () {
786
817
  this.status = "idle";
787
818
  }
788
819
  else {
789
- this.promise = new Promise(function (resolve, reject) {
820
+ this.promise = utilities.wrapPromiseWithState(new Promise(function (resolve, reject) {
790
821
  _this.resolve = resolve;
791
822
  _this.reject = reject;
792
- });
823
+ }));
793
824
  }
794
825
  this.subscription = observable
795
826
  .filter(function (_a) {
@@ -921,10 +952,10 @@ var InternalQueryReference = (function () {
921
952
  InternalQueryReference.prototype.initiateFetch = function (returnedPromise) {
922
953
  var _this = this;
923
954
  this.status = "loading";
924
- this.promise = new Promise(function (resolve, reject) {
955
+ this.promise = utilities.wrapPromiseWithState(new Promise(function (resolve, reject) {
925
956
  _this.resolve = resolve;
926
957
  _this.reject = reject;
927
- });
958
+ }));
928
959
  this.promise.catch(function () { });
929
960
  returnedPromise
930
961
  .then(function (result) {
@@ -941,7 +972,7 @@ var InternalQueryReference = (function () {
941
972
  return InternalQueryReference;
942
973
  }());
943
974
 
944
- var SuspenseCache = (function () {
975
+ var SuspenseCache = (function () {
945
976
  function SuspenseCache(options) {
946
977
  if (options === void 0) { options = Object.create(null); }
947
978
  this.queryRefs = new trie.Trie(utilities.canUseWeakMap);
@@ -951,7 +982,6 @@ var SuspenseCache = (function () {
951
982
  var ref = this.queryRefs.lookupArray(cacheKey);
952
983
  if (!ref.current) {
953
984
  ref.current = new InternalQueryReference(createObservable(), {
954
- key: cacheKey,
955
985
  autoDisposeTimeoutMs: this.options.autoDisposeTimeoutMs,
956
986
  onDispose: function () {
957
987
  delete ref.current;
@@ -978,7 +1008,11 @@ function useSuspenseQuery(query, options) {
978
1008
  if (options === void 0) { options = Object.create(null); }
979
1009
  var client = useApolloClient(options.client);
980
1010
  var suspenseCache = getSuspenseCache(client);
981
- var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
1011
+ var watchQueryOptions = useWatchQueryOptions({
1012
+ client: client,
1013
+ query: query,
1014
+ options: options,
1015
+ });
982
1016
  var fetchPolicy = watchQueryOptions.fetchPolicy, variables = watchQueryOptions.variables;
983
1017
  var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
984
1018
  var cacheKey = tslib.__spreadArray([
@@ -988,22 +1022,19 @@ function useSuspenseQuery(query, options) {
988
1022
  var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
989
1023
  return client.watchQuery(watchQueryOptions);
990
1024
  });
991
- var _b = React__namespace.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
992
- var promise = promiseCache.get(queryRef.key);
993
- if (queryRef.didChangeOptions(watchQueryOptions)) {
994
- promise = queryRef.applyOptions(watchQueryOptions);
995
- promiseCache.set(queryRef.key, promise);
1025
+ var _b = React__namespace.useState([queryRef.key, queryRef.promise]), current = _b[0], setPromise = _b[1];
1026
+ if (current[0] !== queryRef.key) {
1027
+ current[0] = queryRef.key;
1028
+ current[1] = queryRef.promise;
996
1029
  }
997
- if (!promise) {
998
- promise = queryRef.promise;
999
- promiseCache.set(queryRef.key, promise);
1030
+ var promise = current[1];
1031
+ if (queryRef.didChangeOptions(watchQueryOptions)) {
1032
+ current[1] = promise = queryRef.applyOptions(watchQueryOptions);
1000
1033
  }
1001
1034
  React__namespace.useEffect(function () {
1002
1035
  var dispose = queryRef.retain();
1003
1036
  var removeListener = queryRef.listen(function (promise) {
1004
- setPromiseCache(function (promiseCache) {
1005
- return new Map(promiseCache).set(queryRef.key, promise);
1006
- });
1037
+ setPromise([queryRef.key, promise]);
1007
1038
  });
1008
1039
  return function () {
1009
1040
  removeListener();
@@ -1020,18 +1051,14 @@ function useSuspenseQuery(query, options) {
1020
1051
  };
1021
1052
  }, [queryRef.result]);
1022
1053
  var result = fetchPolicy === "standby" ? skipResult : __use(promise);
1023
- var fetchMore = React__namespace.useCallback(function (options) {
1054
+ var fetchMore = React__namespace.useCallback((function (options) {
1024
1055
  var promise = queryRef.fetchMore(options);
1025
- setPromiseCache(function (previousPromiseCache) {
1026
- return new Map(previousPromiseCache).set(queryRef.key, queryRef.promise);
1027
- });
1056
+ setPromise([queryRef.key, queryRef.promise]);
1028
1057
  return promise;
1029
- }, [queryRef]);
1058
+ }), [queryRef]);
1030
1059
  var refetch = React__namespace.useCallback(function (variables) {
1031
1060
  var promise = queryRef.refetch(variables);
1032
- setPromiseCache(function (previousPromiseCache) {
1033
- return new Map(previousPromiseCache).set(queryRef.key, queryRef.promise);
1034
- });
1061
+ setPromise([queryRef.key, queryRef.promise]);
1035
1062
  return promise;
1036
1063
  }, [queryRef]);
1037
1064
  var subscribeToMore = React__namespace.useCallback(function (options) { return queryRef.observable.subscribeToMore(options); }, [queryRef]);
@@ -1069,8 +1096,8 @@ function validatePartialDataReturn(fetchPolicy, returnPartialData) {
1069
1096
  }
1070
1097
  }
1071
1098
  function toApolloError(result) {
1072
- return utilities.isNonEmptyArray(result.errors)
1073
- ? new core.ApolloError({ graphQLErrors: result.errors })
1099
+ return utilities.isNonEmptyArray(result.errors) ?
1100
+ new core.ApolloError({ graphQLErrors: result.errors })
1074
1101
  : result.error;
1075
1102
  }
1076
1103
  function useWatchQueryOptions(_a) {
@@ -1110,47 +1137,91 @@ function useBackgroundQuery(query, options) {
1110
1137
  var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
1111
1138
  return client.watchQuery(watchQueryOptions);
1112
1139
  });
1113
- var _b = React__namespace.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
1140
+ var _b = React__namespace.useState(wrapQueryRef(queryRef)), wrappedQueryRef = _b[0], setWrappedQueryRef = _b[1];
1141
+ if (unwrapQueryRef(wrappedQueryRef)[0] !== queryRef) {
1142
+ setWrappedQueryRef(wrapQueryRef(queryRef));
1143
+ }
1114
1144
  if (queryRef.didChangeOptions(watchQueryOptions)) {
1115
1145
  var promise = queryRef.applyOptions(watchQueryOptions);
1116
- promiseCache.set(queryRef.key, promise);
1146
+ updateWrappedQueryRef(wrappedQueryRef, promise);
1117
1147
  }
1118
1148
  React__namespace.useEffect(function () { return queryRef.retain(); }, [queryRef]);
1119
1149
  var fetchMore = React__namespace.useCallback(function (options) {
1120
1150
  var promise = queryRef.fetchMore(options);
1121
- setPromiseCache(function (promiseCache) {
1122
- return new Map(promiseCache).set(queryRef.key, queryRef.promise);
1123
- });
1151
+ setWrappedQueryRef(wrapQueryRef(queryRef));
1124
1152
  return promise;
1125
1153
  }, [queryRef]);
1126
1154
  var refetch = React__namespace.useCallback(function (variables) {
1127
1155
  var promise = queryRef.refetch(variables);
1128
- setPromiseCache(function (promiseCache) {
1129
- return new Map(promiseCache).set(queryRef.key, queryRef.promise);
1130
- });
1156
+ setWrappedQueryRef(wrapQueryRef(queryRef));
1131
1157
  return promise;
1132
1158
  }, [queryRef]);
1133
- queryRef.promiseCache = promiseCache;
1134
- var wrappedQueryRef = React__namespace.useMemo(function () { return wrapQueryRef(queryRef); }, [queryRef]);
1135
1159
  return [
1136
1160
  didFetchResult.current ? wrappedQueryRef : void 0,
1137
1161
  { fetchMore: fetchMore, refetch: refetch },
1138
1162
  ];
1139
1163
  }
1140
1164
 
1141
- function useReadQuery(queryRef) {
1142
- var internalQueryRef = unwrapQueryRef(queryRef);
1143
- globals.invariant(internalQueryRef.promiseCache, 51);
1144
- var promiseCache = internalQueryRef.promiseCache, key = internalQueryRef.key;
1145
- if (!promiseCache.has(key)) {
1146
- promiseCache.set(key, internalQueryRef.promise);
1165
+ function useLoadableQuery(query, options) {
1166
+ if (options === void 0) { options = Object.create(null); }
1167
+ var client = useApolloClient(options.client);
1168
+ var suspenseCache = getSuspenseCache(client);
1169
+ var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
1170
+ var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
1171
+ var _b = React__namespace.useState(null), queryRef = _b[0], setQueryRef = _b[1];
1172
+ var internalQueryRef = queryRef && unwrapQueryRef(queryRef)[0];
1173
+ if (queryRef && (internalQueryRef === null || internalQueryRef === void 0 ? void 0 : internalQueryRef.didChangeOptions(watchQueryOptions))) {
1174
+ var promise = internalQueryRef.applyOptions(watchQueryOptions);
1175
+ updateWrappedQueryRef(queryRef, promise);
1147
1176
  }
1177
+ var calledDuringRender = useRenderGuard();
1178
+ React__namespace.useEffect(function () { return internalQueryRef === null || internalQueryRef === void 0 ? void 0 : internalQueryRef.retain(); }, [internalQueryRef]);
1179
+ var fetchMore = React__namespace.useCallback(function (options) {
1180
+ if (!internalQueryRef) {
1181
+ throw new Error("The query has not been loaded. Please load the query.");
1182
+ }
1183
+ var promise = internalQueryRef.fetchMore(options);
1184
+ setQueryRef(wrapQueryRef(internalQueryRef));
1185
+ return promise;
1186
+ }, [internalQueryRef]);
1187
+ var refetch = React__namespace.useCallback(function (options) {
1188
+ if (!internalQueryRef) {
1189
+ throw new Error("The query has not been loaded. Please load the query.");
1190
+ }
1191
+ var promise = internalQueryRef.refetch(options);
1192
+ setQueryRef(wrapQueryRef(internalQueryRef));
1193
+ return promise;
1194
+ }, [internalQueryRef]);
1195
+ var loadQuery = React__namespace.useCallback(function () {
1196
+ var args = [];
1197
+ for (var _i = 0; _i < arguments.length; _i++) {
1198
+ args[_i] = arguments[_i];
1199
+ }
1200
+ globals.invariant(!calledDuringRender(), 50);
1201
+ var variables = args[0];
1202
+ var cacheKey = tslib.__spreadArray([
1203
+ query,
1204
+ cache.canonicalStringify(variables)
1205
+ ], [].concat(queryKey), true);
1206
+ var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
1207
+ return client.watchQuery(tslib.__assign(tslib.__assign({}, watchQueryOptions), { variables: variables }));
1208
+ });
1209
+ setQueryRef(wrapQueryRef(queryRef));
1210
+ }, [query, queryKey, suspenseCache, watchQueryOptions, calledDuringRender]);
1211
+ var reset = React__namespace.useCallback(function () {
1212
+ setQueryRef(null);
1213
+ }, [queryRef]);
1214
+ return [loadQuery, queryRef, { fetchMore: fetchMore, refetch: refetch, reset: reset }];
1215
+ }
1216
+
1217
+ function useReadQuery(queryRef) {
1218
+ var _a = React__namespace.useMemo(function () { return unwrapQueryRef(queryRef); }, [queryRef]), internalQueryRef = _a[0], getPromise = _a[1];
1148
1219
  var promise = useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
1149
1220
  return internalQueryRef.listen(function (promise) {
1150
- internalQueryRef.promiseCache.set(internalQueryRef.key, promise);
1221
+ updateWrappedQueryRef(queryRef, promise);
1151
1222
  forceUpdate();
1152
1223
  });
1153
- }, [internalQueryRef]), function () { return promiseCache.get(key); }, function () { return promiseCache.get(key); });
1224
+ }, [internalQueryRef]), getPromise, getPromise);
1154
1225
  var result = __use(promise);
1155
1226
  return React__namespace.useMemo(function () {
1156
1227
  return {
@@ -1166,6 +1237,7 @@ exports.useApolloClient = useApolloClient;
1166
1237
  exports.useBackgroundQuery = useBackgroundQuery;
1167
1238
  exports.useFragment = useFragment;
1168
1239
  exports.useLazyQuery = useLazyQuery;
1240
+ exports.useLoadableQuery = useLoadableQuery;
1169
1241
  exports.useMutation = useMutation;
1170
1242
  exports.useQuery = useQuery;
1171
1243
  exports.useReactiveVar = useReactiveVar;
@@ -10,6 +10,8 @@ export type { UseSuspenseQueryResult } from "./useSuspenseQuery.js";
10
10
  export { useSuspenseQuery } from "./useSuspenseQuery.js";
11
11
  export type { UseBackgroundQueryResult } from "./useBackgroundQuery.js";
12
12
  export { useBackgroundQuery } from "./useBackgroundQuery.js";
13
+ export type { LoadQueryFunction, UseLoadableQueryResult, } from "./useLoadableQuery.js";
14
+ export { useLoadableQuery } from "./useLoadableQuery.js";
13
15
  export type { UseReadQueryResult } from "./useReadQuery.js";
14
16
  export { useReadQuery } from "./useReadQuery.js";
15
17
  export { skipToken } from "./constants.js";
@@ -8,6 +8,7 @@ export * from "./useReactiveVar.js";
8
8
  export * from "./useFragment.js";
9
9
  export { useSuspenseQuery } from "./useSuspenseQuery.js";
10
10
  export { useBackgroundQuery } from "./useBackgroundQuery.js";
11
+ export { useLoadableQuery } from "./useLoadableQuery.js";
11
12
  export { useReadQuery } from "./useReadQuery.js";
12
13
  export { skipToken } from "./constants.js";
13
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAE1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["import \"../../utilities/globals/index.js\";\n\nexport * from \"./useApolloClient.js\";\nexport * from \"./useLazyQuery.js\";\nexport * from \"./useMutation.js\";\nexport { useQuery } from \"./useQuery.js\";\nexport * from \"./useSubscription.js\";\nexport * from \"./useReactiveVar.js\";\nexport * from \"./useFragment.js\";\nexport type { UseSuspenseQueryResult } from \"./useSuspenseQuery.js\";\nexport { useSuspenseQuery } from \"./useSuspenseQuery.js\";\nexport type { UseBackgroundQueryResult } from \"./useBackgroundQuery.js\";\nexport { useBackgroundQuery } from \"./useBackgroundQuery.js\";\nexport type { UseReadQueryResult } from \"./useReadQuery.js\";\nexport { useReadQuery } from \"./useReadQuery.js\";\nexport { skipToken } from \"./constants.js\";\nexport type { SkipToken } from \"./constants.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAE1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAK7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["import \"../../utilities/globals/index.js\";\n\nexport * from \"./useApolloClient.js\";\nexport * from \"./useLazyQuery.js\";\nexport * from \"./useMutation.js\";\nexport { useQuery } from \"./useQuery.js\";\nexport * from \"./useSubscription.js\";\nexport * from \"./useReactiveVar.js\";\nexport * from \"./useFragment.js\";\nexport type { UseSuspenseQueryResult } from \"./useSuspenseQuery.js\";\nexport { useSuspenseQuery } from \"./useSuspenseQuery.js\";\nexport type { UseBackgroundQueryResult } from \"./useBackgroundQuery.js\";\nexport { useBackgroundQuery } from \"./useBackgroundQuery.js\";\nexport type {\n LoadQueryFunction,\n UseLoadableQueryResult,\n} from \"./useLoadableQuery.js\";\nexport { useLoadableQuery } from \"./useLoadableQuery.js\";\nexport type { UseReadQueryResult } from \"./useReadQuery.js\";\nexport { useReadQuery } from \"./useReadQuery.js\";\nexport { skipToken } from \"./constants.js\";\nexport type { SkipToken } from \"./constants.js\";\n"]}
@@ -1,7 +1,12 @@
1
1
  import { wrapPromiseWithState } from "../../../utilities/index.js";
2
2
  import * as React from "rehackt";
3
+ // Prevent webpack from complaining about our feature detection of the
4
+ // use property of the React namespace, which is expected not
5
+ // to exist when using current stable versions, and that's fine.
3
6
  var useKey = "use";
4
7
  var realHook = React[useKey];
8
+ // This is named with two underscores to allow this hook to evade typical rules of
9
+ // hooks (i.e. it can be used conditionally)
5
10
  export var __use = realHook ||
6
11
  function __use(promise) {
7
12
  var statefulPromise = wrapPromiseWithState(promise);
@@ -1 +1 @@
1
- {"version":3,"file":"__use.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/__use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAMjC,IAAM,MAAM,GAAG,KAA2B,CAAC;AAC3C,IAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAoB,CAAC;AAIlD,MAAM,CAAC,IAAM,KAAK,GAChB,QAAQ;IACR,SAAS,KAAK,CAAS,OAAwB;QAC7C,IAAM,eAAe,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAEtD,QAAQ,eAAe,CAAC,MAAM,EAAE;YAC9B,KAAK,SAAS;gBACZ,MAAM,eAAe,CAAC;YACxB,KAAK,UAAU;gBACb,MAAM,eAAe,CAAC,MAAM,CAAC;YAC/B,KAAK,WAAW;gBACd,OAAO,eAAe,CAAC,KAAK,CAAC;SAChC;IACH,CAAC,CAAC","sourcesContent":["import { wrapPromiseWithState } from \"../../../utilities/index.js\";\nimport * as React from \"rehackt\";\n\ntype Use = <T>(promise: Promise<T>) => T;\n// Prevent webpack from complaining about our feature detection of the\n// use property of the React namespace, which is expected not\n// to exist when using current stable versions, and that's fine.\nconst useKey = \"use\" as keyof typeof React;\nconst realHook = React[useKey] as Use | undefined;\n\n// This is named with two underscores to allow this hook to evade typical rules of\n// hooks (i.e. it can be used conditionally)\nexport const __use =\n realHook ||\n function __use<TValue>(promise: Promise<TValue>) {\n const statefulPromise = wrapPromiseWithState(promise);\n\n switch (statefulPromise.status) {\n case \"pending\":\n throw statefulPromise;\n case \"rejected\":\n throw statefulPromise.reason;\n case \"fulfilled\":\n return statefulPromise.value;\n }\n };\n"]}
1
+ {"version":3,"file":"__use.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/__use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAGjC,sEAAsE;AACtE,6DAA6D;AAC7D,gEAAgE;AAChE,IAAM,MAAM,GAAG,KAA2B,CAAC;AAC3C,IAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAoB,CAAC;AAElD,kFAAkF;AAClF,4CAA4C;AAC5C,MAAM,CAAC,IAAM,KAAK,GAChB,QAAQ;IACR,SAAS,KAAK,CAAS,OAAwB;QAC7C,IAAM,eAAe,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAEtD,QAAQ,eAAe,CAAC,MAAM,EAAE,CAAC;YAC/B,KAAK,SAAS;gBACZ,MAAM,eAAe,CAAC;YACxB,KAAK,UAAU;gBACb,MAAM,eAAe,CAAC,MAAM,CAAC;YAC/B,KAAK,WAAW;gBACd,OAAO,eAAe,CAAC,KAAK,CAAC;QACjC,CAAC;IACH,CAAC,CAAC","sourcesContent":["import { wrapPromiseWithState } from \"../../../utilities/index.js\";\nimport * as React from \"rehackt\";\n\ntype Use = <T>(promise: Promise<T>) => T;\n// Prevent webpack from complaining about our feature detection of the\n// use property of the React namespace, which is expected not\n// to exist when using current stable versions, and that's fine.\nconst useKey = \"use\" as keyof typeof React;\nconst realHook = React[useKey] as Use | undefined;\n\n// This is named with two underscores to allow this hook to evade typical rules of\n// hooks (i.e. it can be used conditionally)\nexport const __use =\n realHook ||\n function __use<TValue>(promise: Promise<TValue>) {\n const statefulPromise = wrapPromiseWithState(promise);\n\n switch (statefulPromise.status) {\n case \"pending\":\n throw statefulPromise;\n case \"rejected\":\n throw statefulPromise.reason;\n case \"fulfilled\":\n return statefulPromise.value;\n }\n };\n"]}
@@ -1,4 +1,5 @@
1
1
  export { useDeepMemo } from "./useDeepMemo.js";
2
2
  export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
3
+ export { useRenderGuard } from "./useRenderGuard.js";
3
4
  export { __use } from "./__use.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,6 @@
1
+ // These hooks are used internally and are not exported publicly by the library
1
2
  export { useDeepMemo } from "./useDeepMemo.js";
2
3
  export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
4
+ export { useRenderGuard } from "./useRenderGuard.js";
3
5
  export { __use } from "./__use.js";
4
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC","sourcesContent":["// These hooks are used internally and are not exported publicly by the library\nexport { useDeepMemo } from \"./useDeepMemo.js\";\nexport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\nexport { __use } from \"./__use.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC","sourcesContent":["// These hooks are used internally and are not exported publicly by the library\nexport { useDeepMemo } from \"./useDeepMemo.js\";\nexport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\nexport { useRenderGuard } from \"./useRenderGuard.js\";\nexport { __use } from \"./__use.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useDeepMemo.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,UAAU,WAAW,CACzB,MAAoB,EACpB,IAAoB;IAEpB,IAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAA2C,CAAC;IAEpE,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE;QAClD,GAAG,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,MAAA,EAAE,CAAC;KACzC;IAED,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC;AAC3B,CAAC","sourcesContent":["import type { DependencyList } from \"react\";\nimport * as React from \"rehackt\";\nimport { equal } from \"@wry/equality\";\n\nexport function useDeepMemo<TValue>(\n memoFn: () => TValue,\n deps: DependencyList\n) {\n const ref = React.useRef<{ deps: DependencyList; value: TValue }>();\n\n if (!ref.current || !equal(ref.current.deps, deps)) {\n ref.current = { value: memoFn(), deps };\n }\n\n return ref.current.value;\n}\n"]}
1
+ {"version":3,"file":"useDeepMemo.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,UAAU,WAAW,CACzB,MAAoB,EACpB,IAAoB;IAEpB,IAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAA2C,CAAC;IAEpE,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,MAAA,EAAE,CAAC;IAC1C,CAAC;IAED,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC;AAC3B,CAAC","sourcesContent":["import type { DependencyList } from \"react\";\nimport * as React from \"rehackt\";\nimport { equal } from \"@wry/equality\";\n\nexport function useDeepMemo<TValue>(\n memoFn: () => TValue,\n deps: DependencyList\n) {\n const ref = React.useRef<{ deps: DependencyList; value: TValue }>();\n\n if (!ref.current || !equal(ref.current.deps, deps)) {\n ref.current = { value: memoFn(), deps };\n }\n\n return ref.current.value;\n}\n"]}
@@ -1,6 +1,9 @@
1
1
  import * as React from "rehackt";
2
2
  import { canUseDOM } from "../../../utilities/index.js";
3
- export var useIsomorphicLayoutEffect = canUseDOM
4
- ? React.useLayoutEffect
5
- : React.useEffect;
3
+ // use canUseDOM here instead of canUseLayoutEffect because we want to be able
4
+ // to use useLayoutEffect in our jest tests. useLayoutEffect seems to work fine
5
+ // in useSuspenseQuery tests, but to honor the original comment about the
6
+ // warnings for useSyncExternalStore implementation, canUseLayoutEffect is left
7
+ // alone.
8
+ export var useIsomorphicLayoutEffect = canUseDOM ? React.useLayoutEffect : React.useEffect;
6
9
  //# sourceMappingURL=useIsomorphicLayoutEffect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIsomorphicLayoutEffect.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAOxD,MAAM,CAAC,IAAM,yBAAyB,GAAG,SAAS;IAChD,CAAC,CAAC,KAAK,CAAC,eAAe;IACvB,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC","sourcesContent":["import * as React from \"rehackt\";\nimport { canUseDOM } from \"../../../utilities/index.js\";\n\n// use canUseDOM here instead of canUseLayoutEffect because we want to be able\n// to use useLayoutEffect in our jest tests. useLayoutEffect seems to work fine\n// in useSuspenseQuery tests, but to honor the original comment about the\n// warnings for useSyncExternalStore implementation, canUseLayoutEffect is left\n// alone.\nexport const useIsomorphicLayoutEffect = canUseDOM\n ? React.useLayoutEffect\n : React.useEffect;\n"]}
1
+ {"version":3,"file":"useIsomorphicLayoutEffect.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,8EAA8E;AAC9E,+EAA+E;AAC/E,yEAAyE;AACzE,+EAA+E;AAC/E,SAAS;AACT,MAAM,CAAC,IAAM,yBAAyB,GACpC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC","sourcesContent":["import * as React from \"rehackt\";\nimport { canUseDOM } from \"../../../utilities/index.js\";\n\n// use canUseDOM here instead of canUseLayoutEffect because we want to be able\n// to use useLayoutEffect in our jest tests. useLayoutEffect seems to work fine\n// in useSuspenseQuery tests, but to honor the original comment about the\n// warnings for useSyncExternalStore implementation, canUseLayoutEffect is left\n// alone.\nexport const useIsomorphicLayoutEffect =\n canUseDOM ? React.useLayoutEffect : React.useEffect;\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function useRenderGuard(): () => boolean;
2
+ //# sourceMappingURL=useRenderGuard.d.ts.map
@@ -0,0 +1,17 @@
1
+ import * as React from "rehackt";
2
+ function getRenderDispatcher() {
3
+ var _a, _b;
4
+ return (_b = (_a = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current;
5
+ }
6
+ var RenderDispatcher = null;
7
+ /*
8
+ Relay does this too, so we hope this is safe.
9
+ https://github.com/facebook/relay/blob/8651fbca19adbfbb79af7a3bc40834d105fd7747/packages/react-relay/relay-hooks/loadQuery.js#L90-L98
10
+ */
11
+ export function useRenderGuard() {
12
+ RenderDispatcher = getRenderDispatcher();
13
+ return React.useCallback(function () {
14
+ return (RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher());
15
+ }, []);
16
+ }
17
+ //# sourceMappingURL=useRenderGuard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRenderGuard.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useRenderGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC,SAAS,mBAAmB;;IAC1B,OAAO,MAAA,MAAC,KAAa,CAAC,kDAAkD,0CACpE,sBAAsB,0CAAE,OAAO,CAAC;AACtC,CAAC;AAED,IAAI,gBAAgB,GAAY,IAAI,CAAC;AAErC;;;EAGE;AACF,MAAM,UAAU,cAAc;IAC5B,gBAAgB,GAAG,mBAAmB,EAAE,CAAC;IAEzC,OAAO,KAAK,CAAC,WAAW,CAAC;QACvB,OAAO,CACL,gBAAgB,KAAK,IAAI,IAAI,gBAAgB,KAAK,mBAAmB,EAAE,CACxE,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import * as React from \"rehackt\";\n\nfunction getRenderDispatcher() {\n return (React as any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED\n ?.ReactCurrentDispatcher?.current;\n}\n\nlet RenderDispatcher: unknown = null;\n\n/*\nRelay does this too, so we hope this is safe.\nhttps://github.com/facebook/relay/blob/8651fbca19adbfbb79af7a3bc40834d105fd7747/packages/react-relay/relay-hooks/loadQuery.js#L90-L98\n*/\nexport function useRenderGuard() {\n RenderDispatcher = getRenderDispatcher();\n\n return React.useCallback(() => {\n return (\n RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher()\n );\n }, []);\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { __spreadArray } from "tslib";
2
2
  import * as React from "rehackt";
3
3
  import { useApolloClient } from "./useApolloClient.js";
4
- import { wrapQueryRef } from "../cache/QueryReference.js";
4
+ import { unwrapQueryRef, updateWrappedQueryRef, wrapQueryRef, } from "../cache/QueryReference.js";
5
5
  import { getSuspenseCache } from "../cache/index.js";
6
6
  import { useWatchQueryOptions } from "./useSuspenseQuery.js";
7
7
  import { canonicalStringify } from "../../cache/index.js";
@@ -12,6 +12,12 @@ export function useBackgroundQuery(query, options) {
12
12
  var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
13
13
  var fetchPolicy = watchQueryOptions.fetchPolicy, variables = watchQueryOptions.variables;
14
14
  var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
15
+ // This ref tracks the first time query execution is enabled to determine
16
+ // whether to return a query ref or `undefined`. When initialized
17
+ // in a skipped state (either via `skip: true` or `skipToken`) we return
18
+ // `undefined` for the `queryRef` until the query has been enabled. Once
19
+ // enabled, a query ref is always returned regardless of whether the query is
20
+ // skipped again later.
15
21
  var didFetchResult = React.useRef(fetchPolicy !== "standby");
16
22
  didFetchResult.current || (didFetchResult.current = fetchPolicy !== "standby");
17
23
  var cacheKey = __spreadArray([
@@ -21,28 +27,25 @@ export function useBackgroundQuery(query, options) {
21
27
  var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
22
28
  return client.watchQuery(watchQueryOptions);
23
29
  });
24
- var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
30
+ var _b = React.useState(wrapQueryRef(queryRef)), wrappedQueryRef = _b[0], setWrappedQueryRef = _b[1];
31
+ if (unwrapQueryRef(wrappedQueryRef)[0] !== queryRef) {
32
+ setWrappedQueryRef(wrapQueryRef(queryRef));
33
+ }
25
34
  if (queryRef.didChangeOptions(watchQueryOptions)) {
26
35
  var promise = queryRef.applyOptions(watchQueryOptions);
27
- promiseCache.set(queryRef.key, promise);
36
+ updateWrappedQueryRef(wrappedQueryRef, promise);
28
37
  }
29
38
  React.useEffect(function () { return queryRef.retain(); }, [queryRef]);
30
39
  var fetchMore = React.useCallback(function (options) {
31
40
  var promise = queryRef.fetchMore(options);
32
- setPromiseCache(function (promiseCache) {
33
- return new Map(promiseCache).set(queryRef.key, queryRef.promise);
34
- });
41
+ setWrappedQueryRef(wrapQueryRef(queryRef));
35
42
  return promise;
36
43
  }, [queryRef]);
37
44
  var refetch = React.useCallback(function (variables) {
38
45
  var promise = queryRef.refetch(variables);
39
- setPromiseCache(function (promiseCache) {
40
- return new Map(promiseCache).set(queryRef.key, queryRef.promise);
41
- });
46
+ setWrappedQueryRef(wrapQueryRef(queryRef));
42
47
  return promise;
43
48
  }, [queryRef]);
44
- queryRef.promiseCache = promiseCache;
45
- var wrappedQueryRef = React.useMemo(function () { return wrapQueryRef(queryRef); }, [queryRef]);
46
49
  return [
47
50
  didFetchResult.current ? wrappedQueryRef : void 0,
48
51
  { fetchMore: fetchMore, refetch: refetch },