@apollo/client 3.8.0-alpha.9 → 3.8.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (582) hide show
  1. package/apollo-client.cjs +1030 -673
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +35 -31
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/cache.cjs.native.js +35 -31
  7. package/cache/core/cache.d.ts +5 -4
  8. package/cache/core/cache.d.ts.map +1 -1
  9. package/cache/core/cache.js +1 -0
  10. package/cache/core/cache.js.map +1 -1
  11. package/cache/core/types/Cache.d.ts +2 -2
  12. package/cache/core/types/Cache.d.ts.map +1 -1
  13. package/cache/core/types/Cache.js.map +1 -1
  14. package/cache/core/types/DataProxy.d.ts +4 -4
  15. package/cache/core/types/DataProxy.d.ts.map +1 -1
  16. package/cache/core/types/DataProxy.js.map +1 -1
  17. package/cache/core/types/common.d.ts +3 -3
  18. package/cache/core/types/common.d.ts.map +1 -1
  19. package/cache/core/types/common.js.map +1 -1
  20. package/cache/inmemory/entityStore.d.ts +5 -5
  21. package/cache/inmemory/entityStore.d.ts.map +1 -1
  22. package/cache/inmemory/entityStore.js +2 -2
  23. package/cache/inmemory/entityStore.js.map +1 -1
  24. package/cache/inmemory/fragmentRegistry.d.ts +1 -1
  25. package/cache/inmemory/fragmentRegistry.d.ts.map +1 -1
  26. package/cache/inmemory/fragmentRegistry.js.map +1 -1
  27. package/cache/inmemory/helpers.d.ts +6 -5
  28. package/cache/inmemory/helpers.d.ts.map +1 -1
  29. package/cache/inmemory/helpers.js.map +1 -1
  30. package/cache/inmemory/inMemoryCache.d.ts +9 -7
  31. package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
  32. package/cache/inmemory/inMemoryCache.js +14 -15
  33. package/cache/inmemory/inMemoryCache.js.map +1 -1
  34. package/cache/inmemory/key-extractor.d.ts +1 -1
  35. package/cache/inmemory/key-extractor.d.ts.map +1 -1
  36. package/cache/inmemory/key-extractor.js +2 -2
  37. package/cache/inmemory/key-extractor.js.map +1 -1
  38. package/cache/inmemory/policies.d.ts +7 -6
  39. package/cache/inmemory/policies.d.ts.map +1 -1
  40. package/cache/inmemory/policies.js +6 -6
  41. package/cache/inmemory/policies.js.map +1 -1
  42. package/cache/inmemory/reactiveVars.d.ts +1 -1
  43. package/cache/inmemory/reactiveVars.d.ts.map +1 -1
  44. package/cache/inmemory/reactiveVars.js.map +1 -1
  45. package/cache/inmemory/readFromStore.d.ts +6 -6
  46. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  47. package/cache/inmemory/readFromStore.js +10 -5
  48. package/cache/inmemory/readFromStore.js.map +1 -1
  49. package/cache/inmemory/types.d.ts +6 -6
  50. package/cache/inmemory/types.d.ts.map +1 -1
  51. package/cache/inmemory/types.js.map +1 -1
  52. package/cache/inmemory/writeToStore.d.ts +6 -6
  53. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  54. package/cache/inmemory/writeToStore.js +7 -8
  55. package/cache/inmemory/writeToStore.js.map +1 -1
  56. package/config/jest/setup.d.ts +1 -0
  57. package/config/jest/setup.d.ts.map +1 -1
  58. package/config/jest/setup.js +3 -0
  59. package/config/jest/setup.js.map +1 -1
  60. package/core/ApolloClient.d.ts +13 -10
  61. package/core/ApolloClient.d.ts.map +1 -1
  62. package/core/ApolloClient.js +18 -16
  63. package/core/ApolloClient.js.map +1 -1
  64. package/core/DocumentTransform.d.ts +24 -0
  65. package/core/DocumentTransform.d.ts.map +1 -0
  66. package/core/DocumentTransform.js +68 -0
  67. package/core/DocumentTransform.js.map +1 -0
  68. package/core/LocalState.d.ts +7 -9
  69. package/core/LocalState.d.ts.map +1 -1
  70. package/core/LocalState.js +6 -10
  71. package/core/LocalState.js.map +1 -1
  72. package/core/ObservableQuery.d.ts +11 -8
  73. package/core/ObservableQuery.d.ts.map +1 -1
  74. package/core/ObservableQuery.js +48 -28
  75. package/core/ObservableQuery.js.map +1 -1
  76. package/core/QueryInfo.d.ts +9 -9
  77. package/core/QueryInfo.d.ts.map +1 -1
  78. package/core/QueryInfo.js.map +1 -1
  79. package/core/QueryManager.d.ts +15 -11
  80. package/core/QueryManager.d.ts.map +1 -1
  81. package/core/QueryManager.js +115 -108
  82. package/core/QueryManager.js.map +1 -1
  83. package/core/core.cjs +332 -172
  84. package/core/core.cjs.map +1 -1
  85. package/core/core.cjs.native.js +332 -172
  86. package/core/equalByQuery.d.ts +4 -0
  87. package/core/equalByQuery.d.ts.map +1 -0
  88. package/{react/hooks/compareResults.js → core/equalByQuery.js} +14 -10
  89. package/core/equalByQuery.js.map +1 -0
  90. package/core/index.d.ts +2 -1
  91. package/core/index.d.ts.map +1 -1
  92. package/core/index.js +2 -1
  93. package/core/index.js.map +1 -1
  94. package/core/networkStatus.d.ts +1 -0
  95. package/core/networkStatus.d.ts.map +1 -1
  96. package/core/networkStatus.js +3 -0
  97. package/core/networkStatus.js.map +1 -1
  98. package/core/types.d.ts +14 -14
  99. package/core/types.d.ts.map +1 -1
  100. package/core/types.js.map +1 -1
  101. package/core/watchQueryOptions.d.ts +6 -7
  102. package/core/watchQueryOptions.d.ts.map +1 -1
  103. package/core/watchQueryOptions.js.map +1 -1
  104. package/dev/dev.cjs +642 -0
  105. package/dev/dev.cjs.map +1 -0
  106. package/dev/dev.cjs.native.js +642 -0
  107. package/dev/index.d.ts +4 -0
  108. package/dev/index.d.ts.map +1 -0
  109. package/dev/index.js +4 -0
  110. package/dev/index.js.map +1 -0
  111. package/dev/loadDevMessages.d.ts +2 -0
  112. package/dev/loadDevMessages.d.ts.map +1 -0
  113. package/dev/loadDevMessages.js +6 -0
  114. package/dev/loadDevMessages.js.map +1 -0
  115. package/dev/loadErrorMessageHandler.d.ts +3 -0
  116. package/dev/loadErrorMessageHandler.d.ts.map +1 -0
  117. package/dev/loadErrorMessageHandler.js +26 -0
  118. package/dev/loadErrorMessageHandler.js.map +1 -0
  119. package/dev/loadErrorMessages.d.ts +2 -0
  120. package/dev/loadErrorMessages.d.ts.map +1 -0
  121. package/dev/loadErrorMessages.js +6 -0
  122. package/dev/loadErrorMessages.js.map +1 -0
  123. package/dev/package.json +8 -0
  124. package/errors/errors.cjs +17 -17
  125. package/errors/errors.cjs.map +1 -1
  126. package/errors/errors.cjs.native.js +17 -17
  127. package/errors/index.d.ts +26 -10
  128. package/errors/index.d.ts.map +1 -1
  129. package/errors/index.js +17 -19
  130. package/errors/index.js.map +1 -1
  131. package/invariantErrorCodes.d.ts +13 -0
  132. package/invariantErrorCodes.d.ts.map +1 -0
  133. package/invariantErrorCodes.js +331 -144
  134. package/invariantErrorCodes.js.map +1 -0
  135. package/link/batch/batchLink.d.ts +4 -3
  136. package/link/batch/batchLink.d.ts.map +1 -1
  137. package/link/batch/batchLink.js.map +1 -1
  138. package/link/batch/batching.d.ts +1 -1
  139. package/link/batch/batching.d.ts.map +1 -1
  140. package/link/batch/batching.js.map +1 -1
  141. package/link/batch-http/batch-http.cjs +23 -2
  142. package/link/batch-http/batch-http.cjs.map +1 -1
  143. package/link/batch-http/batch-http.cjs.native.js +23 -2
  144. package/link/batch-http/batchHttpLink.d.ts +3 -2
  145. package/link/batch-http/batchHttpLink.d.ts.map +1 -1
  146. package/link/batch-http/batchHttpLink.js +7 -2
  147. package/link/batch-http/batchHttpLink.js.map +1 -1
  148. package/link/context/index.d.ts +3 -2
  149. package/link/context/index.d.ts.map +1 -1
  150. package/link/context/index.js.map +1 -1
  151. package/link/core/ApolloLink.d.ts +3 -2
  152. package/link/core/ApolloLink.d.ts.map +1 -1
  153. package/link/core/ApolloLink.js +3 -13
  154. package/link/core/ApolloLink.js.map +1 -1
  155. package/link/core/core.cjs +2 -12
  156. package/link/core/core.cjs.map +1 -1
  157. package/link/core/core.cjs.native.js +2 -12
  158. package/link/core/types.d.ts +8 -3
  159. package/link/core/types.d.ts.map +1 -1
  160. package/link/core/types.js.map +1 -1
  161. package/link/error/index.d.ts +4 -3
  162. package/link/error/index.d.ts.map +1 -1
  163. package/link/error/index.js.map +1 -1
  164. package/link/http/HttpLink.d.ts +3 -2
  165. package/link/http/HttpLink.d.ts.map +1 -1
  166. package/link/http/HttpLink.js.map +1 -1
  167. package/link/http/checkFetcher.js +2 -2
  168. package/link/http/checkFetcher.js.map +1 -1
  169. package/link/http/createHttpLink.d.ts +1 -1
  170. package/link/http/createHttpLink.d.ts.map +1 -1
  171. package/link/http/createHttpLink.js +21 -20
  172. package/link/http/createHttpLink.js.map +1 -1
  173. package/link/http/http.cjs +73 -43
  174. package/link/http/http.cjs.map +1 -1
  175. package/link/http/http.cjs.native.js +73 -43
  176. package/link/http/iterators/nodeStream.d.ts +1 -1
  177. package/link/http/iterators/nodeStream.d.ts.map +1 -1
  178. package/link/http/iterators/nodeStream.js.map +1 -1
  179. package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
  180. package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
  181. package/link/http/parseAndCheckHttpResponse.js +47 -26
  182. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  183. package/link/http/responseIterator.d.ts +1 -1
  184. package/link/http/responseIterator.d.ts.map +1 -1
  185. package/link/http/responseIterator.js.map +1 -1
  186. package/link/http/rewriteURIForGET.d.ts +1 -1
  187. package/link/http/rewriteURIForGET.d.ts.map +1 -1
  188. package/link/http/rewriteURIForGET.js.map +1 -1
  189. package/link/http/selectHttpOptionsAndBody.d.ts +3 -2
  190. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  191. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  192. package/link/http/selectURI.d.ts +1 -1
  193. package/link/http/selectURI.d.ts.map +1 -1
  194. package/link/http/selectURI.js.map +1 -1
  195. package/link/http/serializeFetchParameter.d.ts +1 -1
  196. package/link/http/serializeFetchParameter.d.ts.map +1 -1
  197. package/link/http/serializeFetchParameter.js +2 -2
  198. package/link/http/serializeFetchParameter.js.map +1 -1
  199. package/link/persisted-queries/index.d.ts +4 -3
  200. package/link/persisted-queries/index.d.ts.map +1 -1
  201. package/link/persisted-queries/index.js +16 -20
  202. package/link/persisted-queries/index.js.map +1 -1
  203. package/link/persisted-queries/persisted-queries.cjs +15 -19
  204. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  205. package/link/persisted-queries/persisted-queries.cjs.native.js +15 -19
  206. package/link/remove-typename/index.d.ts +2 -0
  207. package/link/remove-typename/index.d.ts.map +1 -0
  208. package/link/remove-typename/index.js +2 -0
  209. package/link/remove-typename/index.js.map +1 -0
  210. package/link/remove-typename/package.json +8 -0
  211. package/link/remove-typename/remove-typename.cjs +82 -0
  212. package/link/remove-typename/remove-typename.cjs.map +1 -0
  213. package/link/remove-typename/remove-typename.cjs.native.js +82 -0
  214. package/link/remove-typename/removeTypenameFromVariables.d.ts +11 -0
  215. package/link/remove-typename/removeTypenameFromVariables.d.ts.map +1 -0
  216. package/link/remove-typename/removeTypenameFromVariables.js +74 -0
  217. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -0
  218. package/link/retry/delayFunction.d.ts +1 -1
  219. package/link/retry/delayFunction.d.ts.map +1 -1
  220. package/link/retry/delayFunction.js.map +1 -1
  221. package/link/retry/retryFunction.d.ts +1 -1
  222. package/link/retry/retryFunction.d.ts.map +1 -1
  223. package/link/retry/retryFunction.js.map +1 -1
  224. package/link/retry/retryLink.d.ts +4 -3
  225. package/link/retry/retryLink.d.ts.map +1 -1
  226. package/link/retry/retryLink.js.map +1 -1
  227. package/link/schema/index.d.ts +3 -2
  228. package/link/schema/index.d.ts.map +1 -1
  229. package/link/schema/index.js.map +1 -1
  230. package/link/subscriptions/index.d.ts +2 -1
  231. package/link/subscriptions/index.d.ts.map +1 -1
  232. package/link/subscriptions/index.js +8 -3
  233. package/link/subscriptions/index.js.map +1 -1
  234. package/link/subscriptions/subscriptions.cjs +8 -3
  235. package/link/subscriptions/subscriptions.cjs.map +1 -1
  236. package/link/subscriptions/subscriptions.cjs.native.js +8 -3
  237. package/link/utils/createOperation.d.ts +1 -1
  238. package/link/utils/createOperation.d.ts.map +1 -1
  239. package/link/utils/createOperation.js.map +1 -1
  240. package/link/utils/filterOperationVariables.d.ts +5 -0
  241. package/link/utils/filterOperationVariables.d.ts.map +1 -0
  242. package/link/utils/filterOperationVariables.js +18 -0
  243. package/link/utils/filterOperationVariables.js.map +1 -0
  244. package/link/utils/index.d.ts +1 -0
  245. package/link/utils/index.d.ts.map +1 -1
  246. package/link/utils/index.js +1 -0
  247. package/link/utils/index.js.map +1 -1
  248. package/link/utils/throwServerError.d.ts +1 -1
  249. package/link/utils/throwServerError.d.ts.map +1 -1
  250. package/link/utils/throwServerError.js.map +1 -1
  251. package/link/utils/toPromise.d.ts +1 -1
  252. package/link/utils/toPromise.d.ts.map +1 -1
  253. package/link/utils/toPromise.js +1 -1
  254. package/link/utils/toPromise.js.map +1 -1
  255. package/link/utils/transformOperation.d.ts +1 -1
  256. package/link/utils/transformOperation.d.ts.map +1 -1
  257. package/link/utils/transformOperation.js.map +1 -1
  258. package/link/utils/utils.cjs +20 -2
  259. package/link/utils/utils.cjs.map +1 -1
  260. package/link/utils/utils.cjs.native.js +20 -2
  261. package/link/utils/validateOperation.d.ts +1 -1
  262. package/link/utils/validateOperation.d.ts.map +1 -1
  263. package/link/utils/validateOperation.js +2 -2
  264. package/link/utils/validateOperation.js.map +1 -1
  265. package/link/ws/index.d.ts +5 -3
  266. package/link/ws/index.d.ts.map +1 -1
  267. package/link/ws/index.js.map +1 -1
  268. package/package.json +36 -32
  269. package/react/cache/QueryReference.d.ts +34 -0
  270. package/react/cache/QueryReference.d.ts.map +1 -0
  271. package/react/cache/QueryReference.js +107 -0
  272. package/react/cache/QueryReference.js.map +1 -0
  273. package/react/cache/SuspenseCache.d.ts +10 -13
  274. package/react/cache/SuspenseCache.d.ts.map +1 -1
  275. package/react/cache/SuspenseCache.js +18 -41
  276. package/react/cache/SuspenseCache.js.map +1 -1
  277. package/react/cache/types.d.ts +2 -0
  278. package/react/cache/types.d.ts.map +1 -0
  279. package/react/cache/types.js +2 -0
  280. package/react/cache/types.js.map +1 -0
  281. package/react/components/Mutation.d.ts +2 -2
  282. package/react/components/Mutation.d.ts.map +1 -1
  283. package/react/components/Mutation.js.map +1 -1
  284. package/react/components/Query.d.ts +2 -2
  285. package/react/components/Query.d.ts.map +1 -1
  286. package/react/components/Query.js.map +1 -1
  287. package/react/components/Subscription.d.ts +2 -2
  288. package/react/components/Subscription.d.ts.map +1 -1
  289. package/react/components/Subscription.js.map +1 -1
  290. package/react/components/types.d.ts +4 -4
  291. package/react/components/types.d.ts.map +1 -1
  292. package/react/components/types.js.map +1 -1
  293. package/react/context/ApolloConsumer.d.ts +1 -1
  294. package/react/context/ApolloConsumer.d.ts.map +1 -1
  295. package/react/context/ApolloConsumer.js +2 -3
  296. package/react/context/ApolloConsumer.js.map +1 -1
  297. package/react/context/ApolloContext.d.ts +10 -3
  298. package/react/context/ApolloContext.d.ts.map +1 -1
  299. package/react/context/ApolloContext.js +10 -8
  300. package/react/context/ApolloContext.js.map +1 -1
  301. package/react/context/ApolloProvider.d.ts +2 -2
  302. package/react/context/ApolloProvider.d.ts.map +1 -1
  303. package/react/context/ApolloProvider.js +8 -13
  304. package/react/context/ApolloProvider.js.map +1 -1
  305. package/react/context/context.cjs +18 -22
  306. package/react/context/context.cjs.map +1 -1
  307. package/react/context/context.cjs.native.js +18 -22
  308. package/react/context/index.d.ts +1 -1
  309. package/react/context/index.d.ts.map +1 -1
  310. package/react/context/index.js +1 -1
  311. package/react/context/index.js.map +1 -1
  312. package/react/hoc/graphql.d.ts +3 -3
  313. package/react/hoc/graphql.d.ts.map +1 -1
  314. package/react/hoc/graphql.js.map +1 -1
  315. package/react/hoc/hoc-utils.d.ts +2 -2
  316. package/react/hoc/hoc-utils.d.ts.map +1 -1
  317. package/react/hoc/hoc-utils.js +2 -3
  318. package/react/hoc/hoc-utils.js.map +1 -1
  319. package/react/hoc/hoc.cjs +2 -4
  320. package/react/hoc/hoc.cjs.map +1 -1
  321. package/react/hoc/hoc.cjs.native.js +2 -4
  322. package/react/hoc/mutation-hoc.d.ts +4 -4
  323. package/react/hoc/mutation-hoc.d.ts.map +1 -1
  324. package/react/hoc/mutation-hoc.js.map +1 -1
  325. package/react/hoc/query-hoc.d.ts +2 -2
  326. package/react/hoc/query-hoc.d.ts.map +1 -1
  327. package/react/hoc/query-hoc.js.map +1 -1
  328. package/react/hoc/subscription-hoc.d.ts +2 -2
  329. package/react/hoc/subscription-hoc.d.ts.map +1 -1
  330. package/react/hoc/subscription-hoc.js.map +1 -1
  331. package/react/hoc/types.d.ts +4 -4
  332. package/react/hoc/types.d.ts.map +1 -1
  333. package/react/hoc/types.js.map +1 -1
  334. package/react/hoc/withApollo.d.ts +1 -1
  335. package/react/hoc/withApollo.d.ts.map +1 -1
  336. package/react/hoc/withApollo.js +2 -3
  337. package/react/hoc/withApollo.js.map +1 -1
  338. package/react/hooks/hooks.cjs +223 -219
  339. package/react/hooks/hooks.cjs.map +1 -1
  340. package/react/hooks/hooks.cjs.native.js +223 -219
  341. package/react/hooks/index.d.ts +2 -1
  342. package/react/hooks/index.d.ts.map +1 -1
  343. package/react/hooks/index.js +2 -1
  344. package/react/hooks/index.js.map +1 -1
  345. package/react/hooks/internal/__use.d.ts +4 -0
  346. package/react/hooks/internal/__use.d.ts.map +1 -0
  347. package/react/hooks/internal/__use.js +17 -0
  348. package/react/hooks/internal/__use.js.map +1 -0
  349. package/react/hooks/internal/index.d.ts +2 -0
  350. package/react/hooks/internal/index.d.ts.map +1 -1
  351. package/react/hooks/internal/index.js +2 -0
  352. package/react/hooks/internal/index.js.map +1 -1
  353. package/react/hooks/internal/useDeepMemo.d.ts +1 -1
  354. package/react/hooks/internal/useDeepMemo.d.ts.map +1 -1
  355. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  356. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -1
  357. package/react/hooks/internal/useIsomorphicLayoutEffect.js +2 -2
  358. package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
  359. package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts +2 -0
  360. package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts.map +1 -0
  361. package/react/hooks/internal/useStrictModeSafeCleanupEffect.js +11 -0
  362. package/react/hooks/internal/useStrictModeSafeCleanupEffect.js.map +1 -0
  363. package/react/hooks/useApolloClient.d.ts +1 -1
  364. package/react/hooks/useApolloClient.d.ts.map +1 -1
  365. package/react/hooks/useApolloClient.js +2 -4
  366. package/react/hooks/useApolloClient.js.map +1 -1
  367. package/react/hooks/useBackgroundQuery.d.ts +18 -0
  368. package/react/hooks/useBackgroundQuery.d.ts.map +1 -0
  369. package/react/hooks/useBackgroundQuery.js +69 -0
  370. package/react/hooks/useBackgroundQuery.js.map +1 -0
  371. package/react/hooks/useFragment.d.ts +14 -9
  372. package/react/hooks/useFragment.d.ts.map +1 -1
  373. package/react/hooks/useFragment.js +2 -2
  374. package/react/hooks/useFragment.js.map +1 -1
  375. package/react/hooks/useLazyQuery.d.ts +4 -4
  376. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  377. package/react/hooks/useLazyQuery.js +13 -22
  378. package/react/hooks/useLazyQuery.js.map +1 -1
  379. package/react/hooks/useMutation.d.ts +4 -4
  380. package/react/hooks/useMutation.d.ts.map +1 -1
  381. package/react/hooks/useMutation.js +1 -1
  382. package/react/hooks/useMutation.js.map +1 -1
  383. package/react/hooks/useQuery.d.ts +6 -6
  384. package/react/hooks/useQuery.d.ts.map +1 -1
  385. package/react/hooks/useQuery.js +29 -28
  386. package/react/hooks/useQuery.js.map +1 -1
  387. package/react/hooks/useReactiveVar.d.ts +1 -1
  388. package/react/hooks/useReactiveVar.d.ts.map +1 -1
  389. package/react/hooks/useReactiveVar.js.map +1 -1
  390. package/react/hooks/useSubscription.d.ts +4 -4
  391. package/react/hooks/useSubscription.d.ts.map +1 -1
  392. package/react/hooks/useSubscription.js +27 -19
  393. package/react/hooks/useSubscription.js.map +1 -1
  394. package/react/hooks/useSuspenseCache.d.ts +1 -1
  395. package/react/hooks/useSuspenseCache.d.ts.map +1 -1
  396. package/react/hooks/useSuspenseCache.js +2 -4
  397. package/react/hooks/useSuspenseCache.js.map +1 -1
  398. package/react/hooks/useSuspenseQuery.d.ts +39 -7
  399. package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
  400. package/react/hooks/useSuspenseQuery.js +68 -149
  401. package/react/hooks/useSuspenseQuery.js.map +1 -1
  402. package/react/hooks/useSyncExternalStore.js +1 -1
  403. package/react/index.d.ts +1 -1
  404. package/react/index.d.ts.map +1 -1
  405. package/react/index.js +1 -1
  406. package/react/index.js.map +1 -1
  407. package/react/parser/index.d.ts +1 -1
  408. package/react/parser/index.d.ts.map +1 -1
  409. package/react/parser/index.js +20 -17
  410. package/react/parser/index.js.map +1 -1
  411. package/react/parser/parser.cjs +19 -16
  412. package/react/parser/parser.cjs.map +1 -1
  413. package/react/parser/parser.cjs.native.js +19 -16
  414. package/react/react.cjs +116 -35
  415. package/react/react.cjs.map +1 -1
  416. package/react/react.cjs.native.js +116 -35
  417. package/react/ssr/RenderPromises.d.ts +2 -2
  418. package/react/ssr/RenderPromises.d.ts.map +1 -1
  419. package/react/ssr/RenderPromises.js.map +1 -1
  420. package/react/ssr/renderToStringWithData.d.ts +1 -1
  421. package/react/ssr/renderToStringWithData.d.ts.map +1 -1
  422. package/react/ssr/renderToStringWithData.js.map +1 -1
  423. package/react/types/types.d.ts +10 -13
  424. package/react/types/types.d.ts.map +1 -1
  425. package/react/types/types.js.map +1 -1
  426. package/testing/core/core.cjs +1 -1
  427. package/testing/core/core.cjs.map +1 -1
  428. package/testing/core/core.cjs.native.js +1 -1
  429. package/testing/core/mocking/mockClient.d.ts +2 -2
  430. package/testing/core/mocking/mockClient.d.ts.map +1 -1
  431. package/testing/core/mocking/mockClient.js.map +1 -1
  432. package/testing/core/mocking/mockLink.d.ts +2 -1
  433. package/testing/core/mocking/mockLink.d.ts.map +1 -1
  434. package/testing/core/mocking/mockLink.js +3 -3
  435. package/testing/core/mocking/mockLink.js.map +1 -1
  436. package/testing/core/mocking/mockQueryManager.d.ts +1 -1
  437. package/testing/core/mocking/mockQueryManager.d.ts.map +1 -1
  438. package/testing/core/mocking/mockQueryManager.js.map +1 -1
  439. package/testing/core/mocking/mockSubscriptionLink.d.ts +3 -2
  440. package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -1
  441. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  442. package/testing/core/mocking/mockWatchQuery.d.ts +2 -2
  443. package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -1
  444. package/testing/core/mocking/mockWatchQuery.js.map +1 -1
  445. package/testing/core/observableToPromise.d.ts +2 -2
  446. package/testing/core/observableToPromise.d.ts.map +1 -1
  447. package/testing/core/observableToPromise.js.map +1 -1
  448. package/testing/core/subscribeAndCount.d.ts +1 -1
  449. package/testing/core/subscribeAndCount.d.ts.map +1 -1
  450. package/testing/core/subscribeAndCount.js.map +1 -1
  451. package/testing/matchers/index.d.ts +2 -0
  452. package/testing/matchers/index.d.ts.map +1 -0
  453. package/testing/matchers/index.js +6 -0
  454. package/testing/matchers/index.js.map +1 -0
  455. package/testing/matchers/toMatchDocument.d.ts +4 -0
  456. package/testing/matchers/toMatchDocument.d.ts.map +1 -0
  457. package/testing/matchers/toMatchDocument.js +34 -0
  458. package/testing/matchers/toMatchDocument.js.map +1 -0
  459. package/testing/react/MockedProvider.d.ts +8 -7
  460. package/testing/react/MockedProvider.d.ts.map +1 -1
  461. package/testing/react/MockedProvider.js +7 -6
  462. package/testing/react/MockedProvider.js.map +1 -1
  463. package/testing/testing.cjs +7 -51
  464. package/testing/testing.cjs.map +1 -1
  465. package/testing/testing.cjs.native.js +7 -51
  466. package/utilities/common/compact.d.ts +1 -1
  467. package/utilities/common/compact.d.ts.map +1 -1
  468. package/utilities/common/compact.js.map +1 -1
  469. package/utilities/common/errorHandling.d.ts +1 -1
  470. package/utilities/common/errorHandling.d.ts.map +1 -1
  471. package/utilities/common/errorHandling.js.map +1 -1
  472. package/utilities/common/incrementalResult.d.ts +2 -1
  473. package/utilities/common/incrementalResult.d.ts.map +1 -1
  474. package/utilities/common/incrementalResult.js +4 -0
  475. package/utilities/common/incrementalResult.js.map +1 -1
  476. package/utilities/common/mergeOptions.d.ts +1 -1
  477. package/utilities/common/mergeOptions.d.ts.map +1 -1
  478. package/utilities/common/mergeOptions.js +1 -1
  479. package/utilities/common/mergeOptions.js.map +1 -1
  480. package/utilities/common/objects.d.ts +1 -0
  481. package/utilities/common/objects.d.ts.map +1 -1
  482. package/utilities/common/objects.js +6 -0
  483. package/utilities/common/objects.js.map +1 -1
  484. package/utilities/common/omitDeep.d.ts +3 -0
  485. package/utilities/common/omitDeep.d.ts.map +1 -0
  486. package/utilities/common/omitDeep.js +41 -0
  487. package/utilities/common/omitDeep.js.map +1 -0
  488. package/utilities/common/responseIterator.d.ts +2 -2
  489. package/utilities/common/responseIterator.d.ts.map +1 -1
  490. package/utilities/common/responseIterator.js.map +1 -1
  491. package/utilities/common/stringifyForDisplay.d.ts +1 -1
  492. package/utilities/common/stringifyForDisplay.d.ts.map +1 -1
  493. package/utilities/common/stringifyForDisplay.js +3 -2
  494. package/utilities/common/stringifyForDisplay.js.map +1 -1
  495. package/utilities/common/stripTypename.d.ts +2 -0
  496. package/utilities/common/stripTypename.d.ts.map +1 -0
  497. package/utilities/common/stripTypename.js +5 -0
  498. package/utilities/common/stripTypename.js.map +1 -0
  499. package/utilities/globals/global.d.ts +6 -3
  500. package/utilities/globals/global.d.ts.map +1 -1
  501. package/utilities/globals/global.js.map +1 -1
  502. package/utilities/globals/globals.cjs +67 -1
  503. package/utilities/globals/globals.cjs.map +1 -1
  504. package/utilities/globals/globals.cjs.native.js +67 -1
  505. package/utilities/globals/index.d.ts +2 -2
  506. package/utilities/globals/index.d.ts.map +1 -1
  507. package/utilities/globals/index.js +2 -2
  508. package/utilities/globals/index.js.map +1 -1
  509. package/utilities/globals/invariantWrappers.d.ts +24 -0
  510. package/utilities/globals/invariantWrappers.d.ts.map +1 -0
  511. package/utilities/globals/invariantWrappers.js +53 -0
  512. package/utilities/globals/invariantWrappers.js.map +1 -0
  513. package/utilities/graphql/directives.d.ts +1 -1
  514. package/utilities/graphql/directives.d.ts.map +1 -1
  515. package/utilities/graphql/directives.js +6 -7
  516. package/utilities/graphql/directives.js.map +1 -1
  517. package/utilities/graphql/fragments.d.ts +1 -1
  518. package/utilities/graphql/fragments.d.ts.map +1 -1
  519. package/utilities/graphql/fragments.js +8 -5
  520. package/utilities/graphql/fragments.js.map +1 -1
  521. package/utilities/graphql/getFromAST.d.ts +1 -1
  522. package/utilities/graphql/getFromAST.d.ts.map +1 -1
  523. package/utilities/graphql/getFromAST.js +9 -9
  524. package/utilities/graphql/getFromAST.js.map +1 -1
  525. package/utilities/graphql/operations.d.ts +5 -0
  526. package/utilities/graphql/operations.d.ts.map +1 -0
  527. package/utilities/graphql/operations.js +16 -0
  528. package/utilities/graphql/operations.js.map +1 -0
  529. package/utilities/graphql/storeUtils.d.ts +2 -2
  530. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  531. package/utilities/graphql/storeUtils.js +16 -7
  532. package/utilities/graphql/storeUtils.js.map +1 -1
  533. package/utilities/graphql/transform.d.ts +1 -1
  534. package/utilities/graphql/transform.d.ts.map +1 -1
  535. package/utilities/graphql/transform.js +30 -21
  536. package/utilities/graphql/transform.js.map +1 -1
  537. package/utilities/index.d.ts +6 -0
  538. package/utilities/index.d.ts.map +1 -1
  539. package/utilities/index.js +4 -0
  540. package/utilities/index.js.map +1 -1
  541. package/utilities/observables/Concast.d.ts +2 -1
  542. package/utilities/observables/Concast.d.ts.map +1 -1
  543. package/utilities/observables/Concast.js.map +1 -1
  544. package/utilities/observables/Observable.d.ts +2 -1
  545. package/utilities/observables/Observable.d.ts.map +1 -1
  546. package/utilities/observables/Observable.js +1 -1
  547. package/utilities/observables/Observable.js.map +1 -1
  548. package/utilities/observables/asyncMap.d.ts.map +1 -1
  549. package/utilities/observables/asyncMap.js.map +1 -1
  550. package/utilities/observables/iteration.d.ts +1 -1
  551. package/utilities/observables/iteration.d.ts.map +1 -1
  552. package/utilities/observables/iteration.js.map +1 -1
  553. package/utilities/policies/pagination.d.ts +1 -1
  554. package/utilities/policies/pagination.d.ts.map +1 -1
  555. package/utilities/policies/pagination.js.map +1 -1
  556. package/utilities/promises/decoration.d.ts +17 -0
  557. package/utilities/promises/decoration.d.ts.map +1 -0
  558. package/utilities/promises/decoration.js +37 -0
  559. package/utilities/promises/decoration.js.map +1 -0
  560. package/utilities/types/DeepOmit.d.ts +10 -0
  561. package/utilities/types/DeepOmit.d.ts.map +1 -0
  562. package/utilities/types/DeepOmit.js +2 -0
  563. package/utilities/types/DeepOmit.js.map +1 -0
  564. package/utilities/types/DeepPartial.d.ts +12 -0
  565. package/utilities/types/DeepPartial.d.ts.map +1 -0
  566. package/utilities/types/DeepPartial.js +2 -0
  567. package/utilities/types/DeepPartial.js.map +1 -0
  568. package/utilities/types/Primitive.d.ts +2 -0
  569. package/utilities/types/Primitive.d.ts.map +1 -0
  570. package/utilities/types/Primitive.js +2 -0
  571. package/utilities/types/Primitive.js.map +1 -0
  572. package/utilities/utilities.cjs +181 -45
  573. package/utilities/utilities.cjs.map +1 -1
  574. package/utilities/utilities.cjs.native.js +181 -45
  575. package/version.js +1 -1
  576. package/cache/inmemory/__mocks__/optimism.d.ts +0 -2
  577. package/cache/inmemory/__mocks__/optimism.d.ts.map +0 -1
  578. package/cache/inmemory/__mocks__/optimism.js +0 -14
  579. package/cache/inmemory/__mocks__/optimism.js.map +0 -1
  580. package/react/hooks/compareResults.d.ts +0 -3
  581. package/react/hooks/compareResults.d.ts.map +0 -1
  582. package/react/hooks/compareResults.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC","sourcesContent":["import '../../utilities/globals';\n\nexport * from './useApolloClient';\nexport * from './useLazyQuery';\nexport * from './useMutation';\nexport { useQuery } from './useQuery';\nexport * from './useSubscription';\nexport * from './useReactiveVar';\nexport * from './useFragment';\nexport * from './useSuspenseQuery';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,gBAAgB,GAKjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,YAAY,GAEb,MAAM,sBAAsB,CAAC","sourcesContent":["import '../../utilities/globals';\n\nexport * from './useApolloClient';\nexport * from './useLazyQuery';\nexport * from './useMutation';\nexport { useQuery } from './useQuery';\nexport * from './useSubscription';\nexport * from './useReactiveVar';\nexport * from './useFragment';\nexport {\n useSuspenseQuery,\n UseSuspenseQueryResult,\n FetchMoreFunction,\n RefetchFunction,\n SubscribeToMoreFunction,\n} from './useSuspenseQuery';\nexport {\n useBackgroundQuery,\n useReadQuery,\n UseBackgroundQueryResult,\n} from './useBackgroundQuery';\n"]}
@@ -0,0 +1,4 @@
1
+ type Use = <T>(promise: Promise<T>) => T;
2
+ export declare const __use: Use;
3
+ export {};
4
+ //# sourceMappingURL=__use.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__use.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/internal/__use.ts"],"names":[],"mappings":"AAGA,KAAK,GAAG,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AASzC,eAAO,MAAM,KAAK,KAaf,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { wrapPromiseWithState } from "../../../utilities/index.js";
2
+ import React from 'react';
3
+ var useKey = 'use';
4
+ var realHook = React[useKey];
5
+ export var __use = realHook ||
6
+ function __use(promise) {
7
+ var statefulPromise = wrapPromiseWithState(promise);
8
+ switch (statefulPromise.status) {
9
+ case 'pending':
10
+ throw statefulPromise;
11
+ case 'rejected':
12
+ throw statefulPromise.reason;
13
+ case 'fulfilled':
14
+ return statefulPromise.value;
15
+ }
16
+ };
17
+ //# sourceMappingURL=__use.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__use.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/__use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,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';\nimport React from 'react';\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,3 +1,5 @@
1
1
  export { useDeepMemo } from './useDeepMemo';
2
2
  export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
3
+ export { useStrictModeSafeCleanupEffect } from './useStrictModeSafeCleanupEffect';
4
+ export { __use } from './__use';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/internal/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/internal/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
@@ -1,3 +1,5 @@
1
1
  export { useDeepMemo } from "./useDeepMemo.js";
2
2
  export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
3
+ export { useStrictModeSafeCleanupEffect } from "./useStrictModeSafeCleanupEffect.js";
4
+ export { __use } from "./__use.js";
3
5
  //# 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,eAAe,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC","sourcesContent":["// These hooks are used internally and are not exported publicly by the library\nexport { useDeepMemo } from './useDeepMemo';\nexport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC","sourcesContent":["// These hooks are used internally and are not exported publicly by the library\nexport { useDeepMemo } from './useDeepMemo';\nexport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';\nexport { useStrictModeSafeCleanupEffect } from './useStrictModeSafeCleanupEffect';\nexport { __use } from './__use';\n"]}
@@ -1,3 +1,3 @@
1
- import { DependencyList } from 'react';
1
+ import type { DependencyList } from 'react';
2
2
  export declare function useDeepMemo<TValue>(memoFn: () => TValue, deps: DependencyList): TValue;
3
3
  //# sourceMappingURL=useDeepMemo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDeepMemo.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,cAAc,EAAE,MAAM,OAAO,CAAC;AAG/C,wBAAgB,WAAW,CAAC,MAAM,EAChC,MAAM,EAAE,MAAM,MAAM,EACpB,IAAI,EAAE,cAAc,UASrB"}
1
+ {"version":3,"file":"useDeepMemo.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAI5C,wBAAgB,WAAW,CAAC,MAAM,EAChC,MAAM,EAAE,MAAM,MAAM,EACpB,IAAI,EAAE,cAAc,UASrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDeepMemo.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,UAAU,WAAW,CACzB,MAAoB,EACpB,IAAoB;IAEpB,IAAM,GAAG,GAAG,MAAM,EAA2C,CAAC;IAE9D,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 { useRef, DependencyList } from 'react';\nimport { equal } from '@wry/equality';\n\nexport function useDeepMemo<TValue>(\n memoFn: () => TValue,\n deps: DependencyList\n) {\n const ref = 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,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,UAAU,WAAW,CACzB,MAAoB,EACpB,IAAoB;IAEpB,IAAM,GAAG,GAAG,MAAM,EAA2C,CAAC;IAE9D,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 { useRef } from 'react';\nimport { equal } from '@wry/equality';\n\nexport function useDeepMemo<TValue>(\n memoFn: () => TValue,\n deps: DependencyList\n) {\n const ref = 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 +1 @@
1
- {"version":3,"file":"useIsomorphicLayoutEffect.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAa,MAAM,OAAO,CAAC;AAGnD,eAAO,MAAM,yBAAyB,wBAEzB,CAAC"}
1
+ {"version":3,"file":"useIsomorphicLayoutEffect.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAa,MAAM,OAAO,CAAC;AAQnD,eAAO,MAAM,yBAAyB,wBAEzB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { useLayoutEffect, useEffect } from 'react';
2
- import { canUseLayoutEffect } from "../../../utilities/index.js";
3
- export var useIsomorphicLayoutEffect = canUseLayoutEffect
2
+ import { canUseDOM } from "../../../utilities/index.js";
3
+ export var useIsomorphicLayoutEffect = canUseDOM
4
4
  ? useLayoutEffect
5
5
  : useEffect;
6
6
  //# sourceMappingURL=useIsomorphicLayoutEffect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIsomorphicLayoutEffect.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,CAAC,IAAM,yBAAyB,GAAG,kBAAkB;IACzD,CAAC,CAAC,eAAe;IACjB,CAAC,CAAC,SAAS,CAAC","sourcesContent":["import { useLayoutEffect, useEffect } from 'react';\nimport { canUseLayoutEffect } from '../../../utilities';\n\nexport const useIsomorphicLayoutEffect = canUseLayoutEffect\n ? useLayoutEffect\n : useEffect;\n"]}
1
+ {"version":3,"file":"useIsomorphicLayoutEffect.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAO/C,MAAM,CAAC,IAAM,yBAAyB,GAAG,SAAS;IAChD,CAAC,CAAC,eAAe;IACjB,CAAC,CAAC,SAAS,CAAC","sourcesContent":["import { useLayoutEffect, useEffect } from 'react';\nimport { canUseDOM } from '../../../utilities';\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 ? useLayoutEffect\n : useEffect;\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function useStrictModeSafeCleanupEffect(cleanup: () => void): void;
2
+ //# sourceMappingURL=useStrictModeSafeCleanupEffect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStrictModeSafeCleanupEffect.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useStrictModeSafeCleanupEffect.ts"],"names":[],"mappings":"AAEA,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,MAAM,IAAI,QAUjE"}
@@ -0,0 +1,11 @@
1
+ import { useEffect } from 'react';
2
+ export function useStrictModeSafeCleanupEffect(cleanup) {
3
+ var timeout;
4
+ useEffect(function () {
5
+ clearTimeout(timeout);
6
+ return function () {
7
+ timeout = setTimeout(cleanup);
8
+ };
9
+ }, []);
10
+ }
11
+ //# sourceMappingURL=useStrictModeSafeCleanupEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStrictModeSafeCleanupEffect.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useStrictModeSafeCleanupEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,UAAU,8BAA8B,CAAC,OAAmB;IAChE,IAAI,OAAuB,CAAC;IAE5B,SAAS,CAAC;QACR,YAAY,CAAC,OAAO,CAAC,CAAC;QAEtB,OAAO;YACL,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import { useEffect } from 'react';\n\nexport function useStrictModeSafeCleanupEffect(cleanup: () => void) {\n let timeout: NodeJS.Timeout;\n\n useEffect(() => {\n clearTimeout(timeout);\n\n return () => {\n timeout = setTimeout(cleanup);\n };\n }, []);\n}\n"]}
@@ -1,3 +1,3 @@
1
- import { ApolloClient } from '../../core';
1
+ import type { ApolloClient } from '../../core';
2
2
  export declare function useApolloClient(override?: ApolloClient<object>): ApolloClient<object>;
3
3
  //# sourceMappingURL=useApolloClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useApolloClient.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useApolloClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,wBAAgB,eAAe,CAC7B,QAAQ,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,GAC9B,YAAY,CAAC,MAAM,CAAC,CAWtB"}
1
+ {"version":3,"file":"useApolloClient.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useApolloClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,wBAAgB,eAAe,CAC7B,QAAQ,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,GAC9B,YAAY,CAAC,MAAM,CAAC,CAWtB"}
@@ -1,12 +1,10 @@
1
- import { invariant, __DEV__ } from "../../utilities/globals/index.js";
1
+ import { invariant } from "../../utilities/globals/index.js";
2
2
  import { useContext } from 'react';
3
3
  import { getApolloContext } from "../context/index.js";
4
4
  export function useApolloClient(override) {
5
5
  var context = useContext(getApolloContext());
6
6
  var client = override || context.client;
7
- __DEV__ ? invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
8
- 'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +
9
- 'instance in via options.') : invariant(!!client, 32);
7
+ invariant(!!client, 49);
10
8
  return client;
11
9
  }
12
10
  //# sourceMappingURL=useApolloClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useApolloClient.js","sourceRoot":"","sources":["../../../src/react/hooks/useApolloClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,UAAU,eAAe,CAC7B,QAA+B;IAE/B,IAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC/C,IAAM,MAAM,GAAG,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAC1C,SAAS,CACP,CAAC,CAAC,MAAM,EACR,oEAAoE;QACpE,0EAA0E;QAC1E,0BAA0B,CAC3B,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals';\nimport { useContext } from 'react';\nimport { ApolloClient } from '../../core';\nimport { getApolloContext } from '../context';\n\nexport function useApolloClient(\n override?: ApolloClient<object>,\n): ApolloClient<object> {\n const context = useContext(getApolloContext());\n const client = override || context.client;\n invariant(\n !!client,\n 'Could not find \"client\" in the context or passed in as an option. ' +\n 'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +\n 'instance in via options.',\n );\n\n return client;\n}\n"]}
1
+ {"version":3,"file":"useApolloClient.js","sourceRoot":"","sources":["../../../src/react/hooks/useApolloClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,UAAU,eAAe,CAC7B,QAA+B;IAE/B,IAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC/C,IAAM,MAAM,GAAG,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAC1C,SAAS,CACP,CAAC,CAAC,MAAM,EACR,oEAAoE;QACpE,0EAA0E;QAC1E,0BAA0B,CAC3B,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals';\nimport { useContext } from 'react';\nimport type { ApolloClient } from '../../core';\nimport { getApolloContext } from '../context';\n\nexport function useApolloClient(\n override?: ApolloClient<object>,\n): ApolloClient<object> {\n const context = useContext(getApolloContext());\n const client = override || context.client;\n invariant(\n !!client,\n 'Could not find \"client\" in the context or passed in as an option. ' +\n 'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +\n 'instance in via options.',\n );\n\n return client;\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import type { DocumentNode, OperationVariables, TypedDocumentNode } from '../../core';
2
+ import type { QueryReference } from '../cache/QueryReference';
3
+ import type { SuspenseQueryHookOptions, ObservableQueryFields } from '../types/types';
4
+ import type { FetchMoreFunction } from './useSuspenseQuery';
5
+ export type UseBackgroundQueryResult<TData = any, TVariables extends OperationVariables = OperationVariables> = [
6
+ QueryReference<TData>,
7
+ {
8
+ fetchMore: FetchMoreFunction<TData, TVariables>;
9
+ refetch: ObservableQueryFields<TData, TVariables>['refetch'];
10
+ }
11
+ ];
12
+ export declare function useBackgroundQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: Omit<SuspenseQueryHookOptions<TData, TVariables>, 'returnPartialData' | 'refetchWritePolicy'>): UseBackgroundQueryResult<TData>;
13
+ export declare function useReadQuery<TData>(queryRef: QueryReference<TData>): {
14
+ data: TData;
15
+ networkStatus: import("../../core").NetworkStatus;
16
+ error: import("../../errors").ApolloError | undefined;
17
+ };
18
+ //# sourceMappingURL=useBackgroundQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBackgroundQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useBackgroundQuery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAQxB,OAAO,KAAK,EAAE,iBAAiB,EAAmB,MAAM,oBAAoB,CAAC;AAI7E,MAAM,MAAM,wBAAwB,CAClC,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,IACxD;IACF,cAAc,CAAC,KAAK,CAAC;IACrB;QACE,SAAS,EAAE,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAChD,OAAO,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC;KAC9D;CACF,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,EAE1D,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC1D,OAAO,GAAE,IAAI,CACX,wBAAwB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC3C,mBAAmB,GAAG,oBAAoB,CACrB,GACtB,wBAAwB,CAAC,KAAK,CAAC,CA0DjC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC,KAAK,CAAC;;;;EAiClE"}
@@ -0,0 +1,69 @@
1
+ import { useEffect, useState, useMemo, useCallback } from 'react';
2
+ import { useApolloClient } from "./useApolloClient.js";
3
+ import { __use } from "./internal/index.js";
4
+ import { useSuspenseCache } from "./useSuspenseCache.js";
5
+ import { toApolloError, useTrackedQueryRefs, useWatchQueryOptions, } from "./useSuspenseQuery.js";
6
+ import { canonicalStringify } from "../../cache/index.js";
7
+ import { invariant } from "../../utilities/globals/index.js";
8
+ export function useBackgroundQuery(query, options) {
9
+ if (options === void 0) { options = Object.create(null); }
10
+ var suspenseCache = useSuspenseCache(options.suspenseCache);
11
+ var client = useApolloClient(options.client);
12
+ var watchQueryOptions = useWatchQueryOptions({ query: query, options: options });
13
+ var variables = watchQueryOptions.variables;
14
+ var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
15
+ var cacheKey = [client, query, canonicalStringify(variables)].concat(queryKey);
16
+ var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
17
+ return client.watchQuery(watchQueryOptions);
18
+ });
19
+ var _b = useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
20
+ useTrackedQueryRefs(queryRef);
21
+ var fetchMore = useCallback(function (options) {
22
+ var promise = queryRef.fetchMore(options);
23
+ setPromiseCache(function (promiseCache) {
24
+ return new Map(promiseCache).set(queryRef.key, promise);
25
+ });
26
+ return promise;
27
+ }, [queryRef]);
28
+ var refetch = useCallback(function (variables) {
29
+ var promise = queryRef.refetch(variables);
30
+ setPromiseCache(function (promiseCache) {
31
+ return new Map(promiseCache).set(queryRef.key, promise);
32
+ });
33
+ return promise;
34
+ }, [queryRef]);
35
+ queryRef.promiseCache = promiseCache;
36
+ return useMemo(function () {
37
+ return [
38
+ queryRef,
39
+ {
40
+ fetchMore: fetchMore,
41
+ refetch: refetch,
42
+ },
43
+ ];
44
+ }, [queryRef, fetchMore, refetch]);
45
+ }
46
+ export function useReadQuery(queryRef) {
47
+ var _a = useState(0), forceUpdate = _a[1];
48
+ invariant(queryRef.promiseCache, 50);
49
+ var promise = queryRef.promiseCache.get(queryRef.key);
50
+ if (!promise) {
51
+ promise = queryRef.promise;
52
+ queryRef.promiseCache.set(queryRef.key, promise);
53
+ }
54
+ useEffect(function () {
55
+ return queryRef.listen(function (promise) {
56
+ queryRef.promiseCache.set(queryRef.key, promise);
57
+ forceUpdate(function (prevState) { return prevState + 1; });
58
+ });
59
+ }, [queryRef]);
60
+ var result = __use(promise);
61
+ return useMemo(function () {
62
+ return {
63
+ data: result.data,
64
+ networkStatus: result.networkStatus,
65
+ error: toApolloError(result),
66
+ };
67
+ }, [result]);
68
+ }
69
+ //# sourceMappingURL=useBackgroundQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBackgroundQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useBackgroundQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAMlE,OAAO,EAAE,eAAe,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AAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAEtD,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QAC3B,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;KAClD;IAED,SAAS,CAAC;QACR,OAAO,QAAQ,CAAC,MAAM,CAAC,UAAC,OAAO;YAC7B,QAAQ,CAAC,YAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAClD,WAAW,CAAC,UAAC,SAAS,IAAK,OAAA,SAAS,GAAG,CAAC,EAAb,CAAa,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,IAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAE9B,OAAO,OAAO,CAAC;QACb,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC;SAC7B,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AACf,CAAC","sourcesContent":["import { useEffect, useState, useMemo, useCallback } from 'react';\nimport type {\n DocumentNode,\n OperationVariables,\n TypedDocumentNode,\n} from '../../core';\nimport { useApolloClient } from './useApolloClient';\nimport type { QueryReference } from '../cache/QueryReference';\nimport type {\n SuspenseQueryHookOptions,\n ObservableQueryFields,\n} from '../types/types';\nimport { __use } from './internal';\nimport { useSuspenseCache } from './useSuspenseCache';\nimport {\n toApolloError,\n useTrackedQueryRefs,\n useWatchQueryOptions,\n} from './useSuspenseQuery';\nimport type { FetchMoreFunction, RefetchFunction } from './useSuspenseQuery';\nimport { canonicalStringify } from '../../cache';\nimport { invariant } from '../../utilities/globals';\n\nexport type UseBackgroundQueryResult<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> = [\n QueryReference<TData>,\n {\n fetchMore: FetchMoreFunction<TData, TVariables>;\n refetch: ObservableQueryFields<TData, TVariables>['refetch'];\n }\n];\n\nexport function useBackgroundQuery<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: Omit<\n SuspenseQueryHookOptions<TData, TVariables>,\n 'returnPartialData' | 'refetchWritePolicy'\n > = Object.create(null)\n): UseBackgroundQueryResult<TData> {\n const suspenseCache = useSuspenseCache(options.suspenseCache);\n const client = useApolloClient(options.client);\n const watchQueryOptions = useWatchQueryOptions({ query, options });\n const { variables } = watchQueryOptions;\n const { queryKey = [] } = options;\n\n const cacheKey = (\n [client, query, canonicalStringify(variables)] as any[]\n ).concat(queryKey);\n\n const queryRef = suspenseCache.getQueryRef(cacheKey, () =>\n client.watchQuery(watchQueryOptions)\n );\n\n const [promiseCache, setPromiseCache] = useState(\n () => new Map([[queryRef.key, queryRef.promise]])\n );\n\n useTrackedQueryRefs(queryRef);\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = useCallback(\n (options) => {\n const promise = queryRef.fetchMore(options);\n\n setPromiseCache((promiseCache) =>\n new Map(promiseCache).set(queryRef.key, promise)\n );\n\n return promise;\n },\n [queryRef]\n );\n\n const refetch: RefetchFunction<TData, TVariables> = useCallback(\n (variables) => {\n const promise = queryRef.refetch(variables);\n\n setPromiseCache((promiseCache) =>\n new Map(promiseCache).set(queryRef.key, promise)\n );\n\n return promise;\n },\n [queryRef]\n );\n\n queryRef.promiseCache = promiseCache;\n\n return useMemo(() => {\n return [\n queryRef,\n {\n fetchMore,\n refetch,\n },\n ];\n }, [queryRef, fetchMore, refetch]);\n}\n\nexport function useReadQuery<TData>(queryRef: QueryReference<TData>) {\n const [, forceUpdate] = useState(0);\n\n invariant(\n queryRef.promiseCache,\n 'It appears that `useReadQuery` was used outside of `useBackgroundQuery`. ' +\n '`useReadQuery` is only supported for use with `useBackgroundQuery`. ' +\n 'Please ensure you are passing the `queryRef` returned from `useBackgroundQuery`.'\n );\n\n let promise = queryRef.promiseCache.get(queryRef.key);\n\n if (!promise) {\n promise = queryRef.promise;\n queryRef.promiseCache.set(queryRef.key, promise);\n }\n\n useEffect(() => {\n return queryRef.listen((promise) => {\n queryRef.promiseCache!.set(queryRef.key, promise);\n forceUpdate((prevState) => prevState + 1);\n });\n }, [queryRef]);\n\n const result = __use(promise);\n\n return useMemo(() => {\n return {\n data: result.data,\n networkStatus: result.networkStatus,\n error: toApolloError(result),\n };\n }, [result]);\n}\n"]}
@@ -1,14 +1,19 @@
1
- import { Cache, Reference, StoreObject, MissingTree } from "../../cache";
2
- import { OperationVariables } from "../../core";
3
- import { NoInfer } from "../types/types";
4
- export interface UseFragmentOptions<TData, TVars> extends Omit<Cache.DiffOptions<NoInfer<TData>, NoInfer<TVars>>, "id" | "query" | "optimistic" | "previousResult">, Omit<Cache.ReadFragmentOptions<TData, TVars>, "id" | "variables"> {
1
+ import type { DeepPartial } from "../../utilities";
2
+ import type { Cache, Reference, StoreObject, MissingTree } from "../../cache";
3
+ import type { OperationVariables } from "../../core";
4
+ import type { NoInfer } from "../types/types";
5
+ export interface UseFragmentOptions<TData, TVars> extends Omit<Cache.DiffOptions<NoInfer<TData>, NoInfer<TVars>>, "id" | "query" | "optimistic" | "previousResult" | "returnPartialData">, Omit<Cache.ReadFragmentOptions<TData, TVars>, "id" | "variables" | "returnPartialData"> {
5
6
  from: StoreObject | Reference | string;
6
7
  optimistic?: boolean;
7
8
  }
8
- export interface UseFragmentResult<TData> {
9
- data: TData | undefined;
10
- complete: boolean;
9
+ export type UseFragmentResult<TData> = {
10
+ data: TData;
11
+ complete: true;
12
+ missing?: never;
13
+ } | {
14
+ data: DeepPartial<TData>;
15
+ complete: false;
11
16
  missing?: MissingTree;
12
- }
13
- export declare function useFragment_experimental<TData = any, TVars = OperationVariables>(options: UseFragmentOptions<TData, TVars>): UseFragmentResult<TData>;
17
+ };
18
+ export declare function useFragment<TData = any, TVars = OperationVariables>(options: UseFragmentOptions<TData, TVars>): UseFragmentResult<TData>;
14
19
  //# sourceMappingURL=useFragment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFragment.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACZ,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,MAAM,WAAW,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAChD,SAAQ,IAAI,CACV,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAC/C,IAAI,GACJ,OAAO,GACP,YAAY,GACZ,gBAAgB,CACnB,EAAE,IAAI,CACL,KAAK,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,EACrC,IAAI,GACJ,WAAW,CACd;IACC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC;IAEvC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAgBD,MAAM,WAAW,iBAAiB,CAAC,KAAK;IACtC,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,wBAAgB,wBAAwB,CACtC,KAAK,GAAG,GAAG,EACX,KAAK,GAAG,kBAAkB,EAE1B,OAAO,EAAE,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,GACxC,iBAAiB,CAAC,KAAK,CAAC,CA8C1B"}
1
+ {"version":3,"file":"useFragment.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACZ,MAAM,aAAa,CAAC;AAIrB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAChD,SAAQ,IAAI,CACV,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAC/C,IAAI,GACJ,OAAO,GACP,YAAY,GACZ,gBAAgB,GAChB,mBAAmB,CACtB,EAAE,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,EAC3C,IAAI,GACJ,WAAW,GACX,mBAAmB,CACtB;IACC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC;IAEvC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,iBAAiB,CAAC,KAAK,IAC/B;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,IAAI,CAAC;IACf,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,GACD;IACE,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAEN,wBAAgB,WAAW,CACzB,KAAK,GAAG,GAAG,EACX,KAAK,GAAG,kBAAkB,EAE1B,OAAO,EAAE,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,GACxC,iBAAiB,CAAC,KAAK,CAAC,CA+C1B"}
@@ -4,10 +4,10 @@ import { equal } from "@wry/equality";
4
4
  import { mergeDeepArray } from "../../utilities/index.js";
5
5
  import { useApolloClient } from "./useApolloClient.js";
6
6
  import { useSyncExternalStore } from "./useSyncExternalStore.js";
7
- export function useFragment_experimental(options) {
7
+ export function useFragment(options) {
8
8
  var cache = useApolloClient().cache;
9
9
  var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = __rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
10
- var diffOptions = __assign(__assign({}, rest), { id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
10
+ var diffOptions = __assign(__assign({}, rest), { returnPartialData: true, id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
11
11
  var resultRef = useRef();
12
12
  var latestDiff = cache.diff(diffOptions);
13
13
  var getSnapshot = function () {
@@ -1 +1 @@
1
- {"version":3,"file":"useFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAyC9D,MAAM,UAAU,wBAAwB,CAItC,OAAyC;IAEjC,IAAA,KAAK,GAAK,eAAe,EAAE,MAAtB,CAAuB;IAGlC,IAAA,QAAQ,GAKN,OAAO,SALD,EACR,YAAY,GAIV,OAAO,aAJG,EACZ,IAAI,GAGF,OAAO,KAHL,EACJ,KAEE,OAAO,WAFQ,EAAjB,UAAU,mBAAG,IAAI,KAAA,EACd,IAAI,UACL,OAAO,EANL,kDAML,CADQ,CACG;IAEZ,IAAM,WAAW,yBACZ,IAAI,KACP,EAAE,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CA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G,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,OAAO,EAAb,CAAa,CAAC,CACzC,CAAC;KACH;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { useRef } from \"react\";\nimport { equal } from \"@wry/equality\";\n\nimport { mergeDeepArray } from \"../../utilities\";\nimport {\n Cache,\n Reference,\n StoreObject,\n MissingTree,\n} from \"../../cache\";\n\nimport { useApolloClient } from \"./useApolloClient\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore\";\nimport { OperationVariables } from \"../../core\";\nimport { NoInfer } from \"../types/types\";\n\nexport interface UseFragmentOptions<TData, TVars>\nextends Omit<\n Cache.DiffOptions<NoInfer<TData>, NoInfer<TVars>>,\n | \"id\"\n | \"query\"\n | \"optimistic\"\n | \"previousResult\"\n>, Omit<\n Cache.ReadFragmentOptions<TData, TVars>,\n | \"id\"\n | \"variables\"\n> {\n from: StoreObject | Reference | string;\n // Override this field to make it optional (default: true).\n optimistic?: boolean;\n}\n\n// Since the above definition of UseFragmentOptions can be hard to parse without\n// help from TypeScript/VSCode, here are the intended fields and their types.\n// Uncomment this code to check that it's consistent with the definition above.\n//\n// export interface UseFragmentOptions<TData, TVars> {\n// from: string | StoreObject | Reference;\n// fragment: DocumentNode | TypedDocumentNode<TData, TVars>;\n// fragmentName?: string;\n// optimistic?: boolean;\n// variables?: TVars;\n// returnPartialData?: boolean;\n// canonizeResults?: boolean;\n// }\n\nexport interface UseFragmentResult<TData> {\n data: TData | undefined;\n complete: boolean;\n missing?: MissingTree;\n}\n\nexport function useFragment_experimental<\n TData = any,\n TVars = OperationVariables\n>(\n options: UseFragmentOptions<TData, TVars>,\n): UseFragmentResult<TData> {\n const { cache } = useApolloClient();\n\n const {\n fragment,\n fragmentName,\n from,\n optimistic = true,\n ...rest\n } = options;\n\n const diffOptions: Cache.DiffOptions<TData, TVars> = {\n ...rest,\n id: typeof from === \"string\" ? from : cache.identify(from),\n query: cache[\"getFragmentDoc\"](fragment, fragmentName),\n optimistic,\n };\n\n const resultRef = useRef<UseFragmentResult<TData>>();\n let latestDiff = cache.diff<TData>(diffOptions);\n\n // Used for both getSnapshot and getServerSnapshot\n const getSnapshot = () => {\n const latestDiffToResult = diffToResult(latestDiff);\n return resultRef.current &&\n equal(resultRef.current.data, latestDiffToResult.data)\n ? resultRef.current\n : (resultRef.current = latestDiffToResult);\n };\n\n return useSyncExternalStore(\n (forceUpdate) => {\n return cache.watch({\n ...diffOptions,\n immediate: true,\n callback(diff) {\n if (!equal(diff, latestDiff)) {\n resultRef.current = diffToResult((latestDiff = diff));\n forceUpdate();\n }\n },\n });\n },\n getSnapshot,\n getSnapshot\n );\n}\n\nfunction diffToResult<TData>(\n diff: Cache.DiffResult<TData>,\n): UseFragmentResult<TData> {\n const result: UseFragmentResult<TData> = {\n data: diff.result,\n complete: !!diff.complete,\n };\n\n if (diff.missing) {\n result.missing = mergeDeepArray(\n diff.missing.map(error => error.missing),\n );\n }\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"useFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAkC9D,MAAM,UAAU,WAAW,CAIzB,OAAyC;IAEjC,IAAA,KAAK,GAAK,eAAe,EAAE,MAAtB,CAAuB;IAGlC,IAAA,QAAQ,GAKN,OAAO,SALD,EACR,YAAY,GAIV,OAAO,aAJG,EACZ,IAAI,GAGF,OAAO,KAHL,EACJ,KAEE,OAAO,WAFQ,EAAjB,UAAU,mBAAG,IAAI,KAAA,EACd,IAAI,UACL,OAAO,EANL,kDAML,CADQ,C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,QAAQ;KACE,CAAC;IAE9B,IAAI,IAAI,CAAC,OAAO,EAAE;QAChB,MAAM,CAAC,OAAO,GAAG,cAAc,CAC7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,OAAO,EAAb,CAAa,CAAC,CACzC,CAAC;KACH;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { useRef } from \"react\";\nimport { equal } from \"@wry/equality\";\n\nimport type { DeepPartial} from \"../../utilities\";\nimport { mergeDeepArray } from \"../../utilities\";\nimport type {\n Cache,\n Reference,\n StoreObject,\n MissingTree,\n} from \"../../cache\";\n\nimport { useApolloClient } from \"./useApolloClient\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore\";\nimport type { OperationVariables } from \"../../core\";\nimport type { NoInfer } from \"../types/types\";\n\nexport interface UseFragmentOptions<TData, TVars>\nextends Omit<\n Cache.DiffOptions<NoInfer<TData>, NoInfer<TVars>>,\n | \"id\"\n | \"query\"\n | \"optimistic\"\n | \"previousResult\"\n | \"returnPartialData\"\n>, Omit<Cache.ReadFragmentOptions<TData, TVars>,\n | \"id\"\n | \"variables\"\n | \"returnPartialData\"\n> {\n from: StoreObject | Reference | string;\n // Override this field to make it optional (default: true).\n optimistic?: boolean;\n}\n\nexport type UseFragmentResult<TData> =\n | {\n data: TData;\n complete: true;\n missing?: never;\n }\n | {\n data: DeepPartial<TData>;\n complete: false;\n missing?: MissingTree;\n };\n\nexport function useFragment<\n TData = any,\n TVars = OperationVariables\n>(\n options: UseFragmentOptions<TData, TVars>,\n): UseFragmentResult<TData> {\n const { cache } = useApolloClient();\n\n const {\n fragment,\n fragmentName,\n from,\n optimistic = true,\n ...rest\n } = options;\n\n const diffOptions: Cache.DiffOptions<TData, TVars> = {\n ...rest,\n returnPartialData: true,\n id: typeof from === \"string\" ? from : cache.identify(from),\n query: cache[\"getFragmentDoc\"](fragment, fragmentName),\n optimistic\n };\n\n const resultRef = useRef<UseFragmentResult<TData>>();\n let latestDiff = cache.diff<TData>(diffOptions);\n\n // Used for both getSnapshot and getServerSnapshot\n const getSnapshot = () => {\n const latestDiffToResult = diffToResult(latestDiff);\n return resultRef.current &&\n equal(resultRef.current.data, latestDiffToResult.data)\n ? resultRef.current\n : (resultRef.current = latestDiffToResult);\n };\n\n return useSyncExternalStore(\n (forceUpdate) => {\n return cache.watch({\n ...diffOptions,\n immediate: true,\n callback(diff) {\n if (!equal(diff, latestDiff)) {\n resultRef.current = diffToResult((latestDiff = diff));\n forceUpdate();\n }\n },\n });\n },\n getSnapshot,\n getSnapshot\n );\n}\n\nfunction diffToResult<TData>(\n diff: Cache.DiffResult<TData>,\n): UseFragmentResult<TData> {\n const result = {\n data: diff.result!,\n complete: !!diff.complete,\n } as UseFragmentResult<TData>;\n\n if (diff.missing) {\n result.missing = mergeDeepArray(\n diff.missing.map(error => error.missing),\n );\n }\n\n return result;\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { DocumentNode } from 'graphql';
2
- import { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
- import { OperationVariables } from '../../core';
4
- import { LazyQueryHookOptions, LazyQueryResultTuple, NoInfer } from '../types/types';
1
+ import type { DocumentNode } from 'graphql';
2
+ import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
+ import type { OperationVariables } from '../../core';
4
+ import type { LazyQueryHookOptions, LazyQueryResultTuple, NoInfer } from '../types/types';
5
5
  export declare function useLazyQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: LazyQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>): LazyQueryResultTuple<TData, TVariables>;
6
6
  //# sourceMappingURL=useLazyQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLazyQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useLazyQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAGtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAEL,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,EAER,MAAM,gBAAgB,CAAC;AAexB,wBAAgB,YAAY,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,EAClG,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC1D,OAAO,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,GAClE,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,CAkFzC"}
1
+ {"version":3,"file":"useLazyQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useLazyQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,KAAK,EAEV,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,EAER,MAAM,gBAAgB,CAAC;AAexB,wBAAgB,YAAY,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,EAClG,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC1D,OAAO,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,GAClE,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,CA8EzC"}
@@ -1,5 +1,5 @@
1
1
  import { __assign } from "tslib";
2
- import { useCallback, useEffect, useMemo, useRef } from 'react';
2
+ import { useCallback, useMemo, useRef } from 'react';
3
3
  import { mergeOptions } from "../../utilities/index.js";
4
4
  import { useInternalState } from "./useQuery.js";
5
5
  import { useApolloClient } from "./useApolloClient.js";
@@ -12,11 +12,15 @@ var EAGER_METHODS = [
12
12
  'subscribeToMore',
13
13
  ];
14
14
  export function useLazyQuery(query, options) {
15
- var _a, _b;
16
- var abortControllersRef = useRef(new Set());
15
+ var _a;
17
16
  var execOptionsRef = useRef();
18
- var merged = execOptionsRef.current ? mergeOptions(options, execOptionsRef.current) : options;
19
- var internalState = useInternalState(useApolloClient(options && options.client), (_b = (_a = execOptionsRef.current) === null || _a === void 0 ? void 0 : _a.query) !== null && _b !== void 0 ? _b : query);
17
+ var optionsRef = useRef();
18
+ var queryRef = useRef();
19
+ var merged = mergeOptions(options, execOptionsRef.current || {});
20
+ var document = (_a = merged === null || merged === void 0 ? void 0 : merged.query) !== null && _a !== void 0 ? _a : query;
21
+ optionsRef.current = merged;
22
+ queryRef.current = document;
23
+ var internalState = useInternalState(useApolloClient(options && options.client), document);
20
24
  var useQueryResult = internalState.useQuery(__assign(__assign({}, merged), { skip: !execOptionsRef.current }));
21
25
  var initialFetchPolicy = useQueryResult.observable.options.initialFetchPolicy ||
22
26
  internalState.getDefaultFetchPolicy();
@@ -42,28 +46,15 @@ export function useLazyQuery(query, options) {
42
46
  return eagerMethods;
43
47
  }, []);
44
48
  Object.assign(result, eagerMethods);
45
- useEffect(function () {
46
- return function () {
47
- abortControllersRef.current.forEach(function (controller) {
48
- controller.abort();
49
- });
50
- };
51
- }, []);
52
49
  var execute = useCallback(function (executeOptions) {
53
- var controller = new AbortController();
54
- abortControllersRef.current.add(controller);
55
50
  execOptionsRef.current = executeOptions ? __assign(__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
56
51
  fetchPolicy: initialFetchPolicy,
57
52
  };
53
+ var options = mergeOptions(optionsRef.current, __assign({ query: queryRef.current }, execOptionsRef.current));
58
54
  var promise = internalState
59
- .asyncUpdate(controller.signal)
60
- .then(function (queryResult) {
61
- abortControllersRef.current.delete(controller);
62
- return Object.assign(queryResult, eagerMethods);
63
- });
64
- promise.catch(function () {
65
- abortControllersRef.current.delete(controller);
66
- });
55
+ .executeQuery(__assign(__assign({}, options), { skip: false }))
56
+ .then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
57
+ promise.catch(function () { });
67
58
  return promise;
68
59
  }, []);
69
60
  return [execute, result];
@@ -1 +1 @@
1
- {"version":3,"file":"useLazyQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useLazyQuery.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGhE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQ/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIpD,IAAM,aAAa,GAAG;IACpB,SAAS;IACT,WAAW;IACX,WAAW;IACX,aAAa;IACb,cAAc;IACd,iBAAiB;CACT,CAAC;AAEX,MAAM,UAAU,YAAY,CAC1B,KAA0D,EAC1D,OAAmE;;IAEnE,IAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,GAAG,EAAmB,CAAC,CAAC;IAE/D,IAAM,cAAc,GAAG,MAAM,EAAwD,CAAC;IACtF,IAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAEhG,IAAM,aAAa,GAAG,gBAAgB,CACpC,eAAe,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,EAC1C,MAAA,MAAA,cAAc,CAAC,OAAO,0CAAE,KAAK,mCAAI,KAAK,CACvC,CAAC;IAEF,IAAM,cAAc,GAAG,aAAa,CAAC,Q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,IAAI,eAAe,EAAE,CAAC;QACzC,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAE5C,cAAc,CAAC,OAAO,GAAG,cAAc,CAAC,CAAC,uBACpC,cAAc,KACjB,WAAW,EAAE,cAAc,CAAC,WAAW,IAAI,kBAAkB,IAC7D,CAAC,CAAC;YACF,WAAW,EAAE,kBAAkB;SAChC,CAAC;QAEF,IAAM,OAAO,GAAG,aAAa;aAC1B,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC;aAC9B,IAAI,CAAC,UAAA,WAAW;YACf,mBAAmB,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAE/C,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;QAEL,OAAO,CAAC,KAAK,CAAC;YACZ,mBAAmB,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { DocumentNode } from 'graphql';\nimport { TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport { useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { OperationVariables } from '../../core';\nimport { mergeOptions } from '../../utilities';\nimport {\n LazyQueryHookExecOptions,\n LazyQueryHookOptions,\n LazyQueryResultTuple,\n NoInfer,\n QueryResult,\n} from '../types/types';\nimport { useInternalState } from './useQuery';\nimport { useApolloClient } from './useApolloClient';\n\n// The following methods, when called will execute the query, regardless of\n// whether the useLazyQuery execute function was called before.\nconst EAGER_METHODS = [\n 'refetch',\n 'reobserve',\n 'fetchMore',\n 'updateQuery',\n 'startPolling',\n 'subscribeToMore',\n] as const;\n\nexport function useLazyQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: LazyQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>\n): LazyQueryResultTuple<TData, TVariables> {\n const abortControllersRef = useRef(new Set<AbortController>());\n\n const execOptionsRef = useRef<Partial<LazyQueryHookExecOptions<TData, TVariables>>>();\n const merged = execOptionsRef.current ? mergeOptions(options, execOptionsRef.current) : options;\n\n const internalState = useInternalState<TData, TVariables>(\n useApolloClient(options && options.client),\n execOptionsRef.current?.query ?? query\n );\n\n const useQueryResult = internalState.useQuery({\n ...merged,\n skip: !execOptionsRef.current,\n });\n\n const initialFetchPolicy =\n useQueryResult.observable.options.initialFetchPolicy ||\n internalState.getDefaultFetchPolicy();\n\n const result: QueryResult<TData, TVariables> =\n Object.assign(useQueryResult, {\n called: !!execOptionsRef.current,\n });\n\n // We use useMemo here to make sure the eager methods have a stable identity.\n const eagerMethods = useMemo(() => {\n const eagerMethods: Record<string, any> = {};\n for (const key of EAGER_METHODS) {\n const method = result[key];\n eagerMethods[key] = function () {\n if (!execOptionsRef.current) {\n execOptionsRef.current = Object.create(null);\n // Only the first time populating execOptionsRef.current matters here.\n internalState.forceUpdate();\n }\n return method.apply(this, arguments);\n };\n }\n\n return eagerMethods;\n }, []);\n\n Object.assign(result, eagerMethods);\n\n useEffect(() => {\n return () => {\n abortControllersRef.current.forEach((controller) => {\n controller.abort();\n });\n }\n }, [])\n\n const execute = useCallback<\n LazyQueryResultTuple<TData, TVariables>[0]\n >(executeOptions => {\n const controller = new AbortController();\n abortControllersRef.current.add(controller);\n\n execOptionsRef.current = executeOptions ? {\n ...executeOptions,\n fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy,\n } : {\n fetchPolicy: initialFetchPolicy,\n };\n\n const promise = internalState\n .asyncUpdate(controller.signal) // Like internalState.forceUpdate, but returns a Promise.\n .then(queryResult => {\n abortControllersRef.current.delete(controller);\n\n return Object.assign(queryResult, eagerMethods);\n });\n\n promise.catch(() => {\n abortControllersRef.current.delete(controller);\n });\n\n return promise;\n }, []);\n\n return [execute, result];\n}\n"]}
1
+ {"version":3,"file":"useLazyQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useLazyQuery.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQ/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIpD,IAAM,aAAa,GAAG;IACpB,SAAS;IACT,WAAW;IACX,WAAW;IACX,aAAa;IACb,cAAc;IACd,iBAAiB;CACT,CAAC;AAEX,MAAM,UAAU,YAAY,CAC1B,KAA0D,EAC1D,OAAmE;;IAEnE,IAAM,cAAc,GAAG,MAAM,EAAwD,CAAC;IACtF,IAAM,UAAU,GAAG,MAAM,EAA2C,CAAC;IACrE,IAAM,QAAQ,GAAG,MAAM,EAAuD,CAAC;IAC/E,IAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IACnE,IAAM,QAAQ,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,mCAAI,KAAK,CAAC;IAIxC,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC;IAE5B,IAAM,aAAa,GAAG,gBAAgB,CACpC,eAAe,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,EAC1C,QAAQ,CACT,CAAC;IAEF,IAAM,cAAc,GAAG,aAAa,CAAC,QAAQ,uBACxC,MAAM,KACT,IAAI,EAAE,CAAC,cAAc,CAAC,OAAO,IAC7B,CAAC;IAEH,IAAM,kBAAkB,GACtB,cAAc,CAAC,UAAU,CAAC,OAAO,CAAC,kBAAkB;Q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AAE,KAAK,IAAG;aACzC,IAAI,CAAC,UAAC,WAAW,IAAK,OAAA,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,EAAxC,CAAwC,CAAC,CAAC;QAInE,OAAO,CAAC,KAAK,CAAC,cAAO,CAAC,CAAC,CAAC;QAExB,OAAO,OAAO,CAAC;IACjB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import type { DocumentNode } from 'graphql';\nimport type { TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport { useCallback, useMemo, useRef } from 'react';\n\nimport type { OperationVariables } from '../../core';\nimport { mergeOptions } from '../../utilities';\nimport type {\n LazyQueryHookExecOptions,\n LazyQueryHookOptions,\n LazyQueryResultTuple,\n NoInfer,\n QueryResult,\n} from '../types/types';\nimport { useInternalState } from './useQuery';\nimport { useApolloClient } from './useApolloClient';\n\n// The following methods, when called will execute the query, regardless of\n// whether the useLazyQuery execute function was called before.\nconst EAGER_METHODS = [\n 'refetch',\n 'reobserve',\n 'fetchMore',\n 'updateQuery',\n 'startPolling',\n 'subscribeToMore',\n] as const;\n\nexport function useLazyQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: LazyQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>\n): LazyQueryResultTuple<TData, TVariables> {\n const execOptionsRef = useRef<Partial<LazyQueryHookExecOptions<TData, TVariables>>>();\n const optionsRef = useRef<LazyQueryHookOptions<TData, TVariables>>();\n const queryRef = useRef<DocumentNode | TypedDocumentNode<TData, TVariables>>();\n const merged = mergeOptions(options, execOptionsRef.current || {});\n const document = merged?.query ?? query;\n\n // Use refs to track options and the used query to ensure the `execute` \n // function remains referentially stable between renders.\n optionsRef.current = merged;\n queryRef.current = document;\n\n const internalState = useInternalState<TData, TVariables>(\n useApolloClient(options && options.client),\n document\n );\n\n const useQueryResult = internalState.useQuery({\n ...merged,\n skip: !execOptionsRef.current,\n });\n\n const initialFetchPolicy =\n useQueryResult.observable.options.initialFetchPolicy ||\n internalState.getDefaultFetchPolicy();\n\n const result: QueryResult<TData, TVariables> =\n Object.assign(useQueryResult, {\n called: !!execOptionsRef.current,\n });\n\n // We use useMemo here to make sure the eager methods have a stable identity.\n const eagerMethods = useMemo(() => {\n const eagerMethods: Record<string, any> = {};\n for (const key of EAGER_METHODS) {\n const method = result[key];\n eagerMethods[key] = function () {\n if (!execOptionsRef.current) {\n execOptionsRef.current = Object.create(null);\n // Only the first time populating execOptionsRef.current matters here.\n internalState.forceUpdate();\n }\n return method.apply(this, arguments);\n };\n }\n\n return eagerMethods;\n }, []);\n\n Object.assign(result, eagerMethods);\n\n const execute = useCallback<\n LazyQueryResultTuple<TData, TVariables>[0]\n >(executeOptions => {\n execOptionsRef.current = executeOptions ? {\n ...executeOptions,\n fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy,\n } : {\n fetchPolicy: initialFetchPolicy,\n };\n\n const options = mergeOptions(optionsRef.current, {\n query: queryRef.current,\n ...execOptionsRef.current,\n })\n\n const promise = internalState\n .executeQuery({ ...options, skip: false })\n .then((queryResult) => Object.assign(queryResult, eagerMethods));\n\n // Because the return value of `useLazyQuery` is usually floated, we need\n // to catch the promise to prevent unhandled rejections.\n promise.catch(() => {});\n\n return promise;\n }, []);\n\n return [execute, result];\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { DocumentNode } from 'graphql';
2
- import { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
- import { MutationHookOptions, MutationTuple, NoInfer } from '../types/types';
4
- import { ApolloCache, DefaultContext, OperationVariables } from '../../core';
1
+ import type { DocumentNode } from 'graphql';
2
+ import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
+ import type { MutationHookOptions, MutationTuple, NoInfer } from '../types/types';
4
+ import type { ApolloCache, DefaultContext, OperationVariables } from '../../core';
5
5
  export declare function useMutation<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(mutation: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: MutationHookOptions<NoInfer<TData>, NoInfer<TVariables>, TContext, TCache>): MutationTuple<TData, TVariables, TContext, TCache>;
6
6
  //# sourceMappingURL=useMutation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMutation.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useMutation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAEL,mBAAmB,EAEnB,aAAa,EACb,OAAO,EACR,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,WAAW,EACX,cAAc,EAEd,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAMpB,wBAAgB,WAAW,CACzB,KAAK,GAAG,GAAG,EACX,UAAU,GAAG,kBAAkB,EAC/B,QAAQ,GAAG,cAAc,EACzB,MAAM,SAAS,WAAW,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAElD,QAAQ,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC7D,OAAO,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GACnF,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CA8HpD"}
1
+ {"version":3,"file":"useMutation.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useMutation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,KAAK,EAEV,mBAAmB,EAEnB,aAAa,EACb,OAAO,EACR,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,kBAAkB,EAAC,MAAM,YAAY,CAAC;AASxC,wBAAgB,WAAW,CACzB,KAAK,GAAG,GAAG,EACX,UAAU,GAAG,kBAAkB,EAC/B,QAAQ,GAAG,cAAc,EACzB,MAAM,SAAS,WAAW,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAElD,QAAQ,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC7D,OAAO,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GACnF,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CA8HpD"}
@@ -1,6 +1,6 @@
1
1
  import { __assign } from "tslib";
2
2
  import { useCallback, useEffect, useRef, useState } from 'react';
3
- import { mergeOptions, } from "../../core/index.js";
3
+ import { mergeOptions } from "../../utilities/index.js";
4
4
  import { equal } from '@wry/equality';
5
5
  import { DocumentType, verifyDocumentType } from "../parser/index.js";
6
6
  import { ApolloError } from "../../errors/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"useMutation.js","sourceRoot":"","sources":["../../../src/react/hooks/useMutation.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAWjE,OAAO,EAGL,YAAY,GAEb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;A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OAAO,aAAI,KAAK,OAAA,IAAK,MAAM,EAAG,CAAC;AACzC,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { DocumentNode } from 'graphql';\nimport { TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport {\n MutationFunctionOptions,\n MutationHookOptions,\n MutationResult,\n MutationTuple,\n NoInfer,\n} from '../types/types';\n\nimport {\n ApolloCache,\n DefaultContext,\n mergeOptions,\n OperationVariables,\n} from '../../core';\nimport { equal } from '@wry/equality';\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport { ApolloError } from '../../errors';\nimport { useApolloClient } from './useApolloClient';\n\nexport function useMutation<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n>(\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: MutationHookOptions<NoInfer<TData>, NoInfer<TVariables>, TContext, TCache>,\n): MutationTuple<TData, TVariables, TContext, TCache> {\n const client = useApolloClient(options?.client);\n verifyDocumentType(mutation, DocumentType.Mutation);\n const [result, setResult] = useState<Omit<MutationResult, 'reset'>>({\n called: false,\n loading: false,\n client,\n });\n\n const ref = useRef({\n result,\n mutationId: 0,\n isMounted: true,\n client,\n mutation,\n options,\n });\n\n // TODO: Trying to assign these in a useEffect or useLayoutEffect breaks\n // higher-order components.\n {\n Object.assign(ref.current, { client, options, mutation });\n }\n\n const execute = useCallback((\n executeOptions: MutationFunctionOptions<\n TData,\n TVariables,\n TContext,\n TCache\n > = {}\n ) => {\n const {options, mutation} = ref.current;\n const baseOptions = { ...options, mutation };\n const client = executeOptions.client || ref.current.client;\n\n if (!ref.current.result.loading && !baseOptions.ignoreResults && ref.current.isMounted) {\n setResult(ref.current.result = {\n loading: true,\n error: void 0,\n data: void 0,\n called: true,\n client,\n });\n }\n\n const mutationId = ++ref.current.mutationId;\n const clientOptions = mergeOptions(\n baseOptions,\n executeOptions as any,\n );\n\n return client.mutate(clientOptions).then((response) => {\n const { data, errors } = response;\n const error =\n errors && errors.length > 0\n ? new ApolloError({ graphQLErrors: errors })\n : void 0;\n\n if (\n mutationId === ref.current.mutationId &&\n !clientOptions.ignoreResults\n ) {\n const result = {\n called: true,\n loading: false,\n data,\n error,\n client,\n };\n\n if (ref.current.isMounted && !equal(ref.current.result, result)) {\n setResult(ref.current.result = result);\n }\n }\n\n const onCompleted = executeOptions.onCompleted || ref.current.options?.onCompleted\n onCompleted?.(response.data!, clientOptions);\n\n return response;\n }).catch((error) => {\n if (\n mutationId === ref.current.mutationId &&\n ref.current.isMounted\n ) {\n const result = {\n loading: false,\n error,\n data: void 0,\n called: true,\n client,\n };\n\n if (!equal(ref.current.result, result)) {\n setResult(ref.current.result = result);\n }\n }\n\n const onError = executeOptions.onError || ref.current.options?.onError\n\n if (onError) {\n onError(error, clientOptions);\n\n // TODO(brian): why are we returning this here???\n return { data: void 0, errors: error };\n }\n\n throw error;\n });\n }, []);\n\n const reset = useCallback(() => {\n if (ref.current.isMounted) {\n setResult({ called: false, loading: false, client });\n }\n }, []);\n\n useEffect(() => {\n ref.current.isMounted = true;\n\n return () => {\n ref.current.isMounted = false;\n };\n }, []);\n\n return [execute, { reset, ...result }];\n}\n"]}
1
+ {"version":3,"file":"useMutation.js","sourceRoot":"","sources":["../../../src/react/hooks/useMutation.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAejE,OAAO,EACL,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,UAAU,WAAW,CAMzB,QAA6D,EAC7D,O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;AACzC,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport type { DocumentNode } from 'graphql';\nimport type { TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport type {\n MutationFunctionOptions,\n MutationHookOptions,\n MutationResult,\n MutationTuple,\n NoInfer,\n} from '../types/types';\n\nimport type {\n ApolloCache,\n DefaultContext,\n OperationVariables} from '../../core';\nimport {\n mergeOptions\n} from '../../utilities';\nimport { equal } from '@wry/equality';\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport { ApolloError } from '../../errors';\nimport { useApolloClient } from './useApolloClient';\n\nexport function useMutation<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n>(\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: MutationHookOptions<NoInfer<TData>, NoInfer<TVariables>, TContext, TCache>,\n): MutationTuple<TData, TVariables, TContext, TCache> {\n const client = useApolloClient(options?.client);\n verifyDocumentType(mutation, DocumentType.Mutation);\n const [result, setResult] = useState<Omit<MutationResult, 'reset'>>({\n called: false,\n loading: false,\n client,\n });\n\n const ref = useRef({\n result,\n mutationId: 0,\n isMounted: true,\n client,\n mutation,\n options,\n });\n\n // TODO: Trying to assign these in a useEffect or useLayoutEffect breaks\n // higher-order components.\n {\n Object.assign(ref.current, { client, options, mutation });\n }\n\n const execute = useCallback((\n executeOptions: MutationFunctionOptions<\n TData,\n TVariables,\n TContext,\n TCache\n > = {}\n ) => {\n const {options, mutation} = ref.current;\n const baseOptions = { ...options, mutation };\n const client = executeOptions.client || ref.current.client;\n\n if (!ref.current.result.loading && !baseOptions.ignoreResults && ref.current.isMounted) {\n setResult(ref.current.result = {\n loading: true,\n error: void 0,\n data: void 0,\n called: true,\n client,\n });\n }\n\n const mutationId = ++ref.current.mutationId;\n const clientOptions = mergeOptions(\n baseOptions,\n executeOptions as any,\n );\n\n return client.mutate(clientOptions).then((response) => {\n const { data, errors } = response;\n const error =\n errors && errors.length > 0\n ? new ApolloError({ graphQLErrors: errors })\n : void 0;\n\n if (\n mutationId === ref.current.mutationId &&\n !clientOptions.ignoreResults\n ) {\n const result = {\n called: true,\n loading: false,\n data,\n error,\n client,\n };\n\n if (ref.current.isMounted && !equal(ref.current.result, result)) {\n setResult(ref.current.result = result);\n }\n }\n\n const onCompleted = executeOptions.onCompleted || ref.current.options?.onCompleted\n onCompleted?.(response.data!, clientOptions);\n\n return response;\n }).catch((error) => {\n if (\n mutationId === ref.current.mutationId &&\n ref.current.isMounted\n ) {\n const result = {\n loading: false,\n error,\n data: void 0,\n called: true,\n client,\n };\n\n if (!equal(ref.current.result, result)) {\n setResult(ref.current.result = result);\n }\n }\n\n const onError = executeOptions.onError || ref.current.options?.onError\n\n if (onError) {\n onError(error, clientOptions);\n\n // TODO(brian): why are we returning this here???\n return { data: void 0, errors: error };\n }\n\n throw error;\n });\n }, []);\n\n const reset = useCallback(() => {\n if (ref.current.isMounted) {\n setResult({ called: false, loading: false, client });\n }\n }, []);\n\n useEffect(() => {\n ref.current.isMounted = true;\n\n return () => {\n ref.current.isMounted = false;\n };\n }, []);\n\n return [execute, { reset, ...result }];\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { OperationVariables, WatchQueryFetchPolicy } from '../../core';
2
- import { ApolloClient, ApolloQueryResult, DocumentNode, TypedDocumentNode } from '../../core';
3
- import { QueryHookOptions, QueryResult, NoInfer } from '../types/types';
1
+ import type { OperationVariables, WatchQueryFetchPolicy } from '../../core';
2
+ import type { ApolloClient, ApolloQueryResult, DocumentNode, TypedDocumentNode } from '../../core';
3
+ import type { QueryHookOptions, QueryResult, NoInfer } from '../types/types';
4
4
  import { useApolloClient } from './useApolloClient';
5
5
  export declare function useQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: QueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>): QueryResult<TData, TVariables>;
6
6
  export declare function useInternalState<TData, TVariables extends OperationVariables>(client: ApolloClient<any>, query: DocumentNode | TypedDocumentNode<TData, TVariables>): InternalState<TData, TVariables>;
@@ -9,9 +9,9 @@ declare class InternalState<TData, TVariables extends OperationVariables> {
9
9
  readonly query: DocumentNode | TypedDocumentNode<TData, TVariables>;
10
10
  constructor(client: ReturnType<typeof useApolloClient>, query: DocumentNode | TypedDocumentNode<TData, TVariables>, previous?: InternalState<TData, TVariables>);
11
11
  forceUpdate(): void;
12
- asyncUpdate(signal: AbortSignal): Promise<QueryResult<TData, TVariables>>;
13
- private asyncResolveFns;
14
- private optionsToIgnoreOnce;
12
+ executeQuery(options: QueryHookOptions<TData, TVariables> & {
13
+ query?: DocumentNode;
14
+ }): Promise<QueryResult<TData, TVariables>>;
15
15
  useQuery(options: QueryHookOptions<TData, TVariables>): QueryResult<TData, TVariables>;
16
16
  private renderPromises;
17
17
  private queryHookOptions;