@apollo/client 0.0.0-pr-10521-20230206180228

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 (778) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +45 -0
  3. package/apollo-client.cjs +7614 -0
  4. package/apollo-client.cjs.map +1 -0
  5. package/apollo-client.min.cjs +1 -0
  6. package/cache/cache.cjs +2425 -0
  7. package/cache/cache.cjs.map +1 -0
  8. package/cache/cache.cjs.native.js +2425 -0
  9. package/cache/core/cache.d.ts +32 -0
  10. package/cache/core/cache.d.ts.map +1 -0
  11. package/cache/core/cache.js +84 -0
  12. package/cache/core/cache.js.map +1 -0
  13. package/cache/core/types/Cache.d.ts +55 -0
  14. package/cache/core/types/Cache.d.ts.map +1 -0
  15. package/cache/core/types/Cache.js +4 -0
  16. package/cache/core/types/Cache.js.map +1 -0
  17. package/cache/core/types/DataProxy.d.ts +52 -0
  18. package/cache/core/types/DataProxy.d.ts.map +1 -0
  19. package/cache/core/types/DataProxy.js +2 -0
  20. package/cache/core/types/DataProxy.js.map +1 -0
  21. package/cache/core/types/common.d.ts +47 -0
  22. package/cache/core/types/common.d.ts.map +1 -0
  23. package/cache/core/types/common.js +26 -0
  24. package/cache/core/types/common.js.map +1 -0
  25. package/cache/index.d.ts +15 -0
  26. package/cache/index.d.ts.map +1 -0
  27. package/cache/index.js +14 -0
  28. package/cache/index.js.map +1 -0
  29. package/cache/inmemory/__mocks__/optimism.d.ts +2 -0
  30. package/cache/inmemory/__mocks__/optimism.d.ts.map +1 -0
  31. package/cache/inmemory/__mocks__/optimism.js +14 -0
  32. package/cache/inmemory/__mocks__/optimism.js.map +1 -0
  33. package/cache/inmemory/entityStore.d.ts +83 -0
  34. package/cache/inmemory/entityStore.d.ts.map +1 -0
  35. package/cache/inmemory/entityStore.js +467 -0
  36. package/cache/inmemory/entityStore.js.map +1 -0
  37. package/cache/inmemory/fixPolyfills.d.ts +1 -0
  38. package/cache/inmemory/fixPolyfills.d.ts.map +1 -0
  39. package/cache/inmemory/fixPolyfills.js +1 -0
  40. package/cache/inmemory/fixPolyfills.js.map +1 -0
  41. package/cache/inmemory/fixPolyfills.native.d.ts +2 -0
  42. package/cache/inmemory/fixPolyfills.native.d.ts.map +1 -0
  43. package/cache/inmemory/fixPolyfills.native.js +48 -0
  44. package/cache/inmemory/fixPolyfills.native.js.map +1 -0
  45. package/cache/inmemory/fragmentRegistry.d.ts +8 -0
  46. package/cache/inmemory/fragmentRegistry.d.ts.map +1 -0
  47. package/cache/inmemory/fragmentRegistry.js +113 -0
  48. package/cache/inmemory/fragmentRegistry.js.map +1 -0
  49. package/cache/inmemory/helpers.d.ts +27 -0
  50. package/cache/inmemory/helpers.d.ts.map +1 -0
  51. package/cache/inmemory/helpers.js +85 -0
  52. package/cache/inmemory/helpers.js.map +1 -0
  53. package/cache/inmemory/inMemoryCache.d.ts +52 -0
  54. package/cache/inmemory/inMemoryCache.d.ts.map +1 -0
  55. package/cache/inmemory/inMemoryCache.js +316 -0
  56. package/cache/inmemory/inMemoryCache.js.map +1 -0
  57. package/cache/inmemory/key-extractor.d.ts +9 -0
  58. package/cache/inmemory/key-extractor.d.ts.map +1 -0
  59. package/cache/inmemory/key-extractor.js +118 -0
  60. package/cache/inmemory/key-extractor.js.map +1 -0
  61. package/cache/inmemory/object-canon.d.ts +17 -0
  62. package/cache/inmemory/object-canon.d.ts.map +1 -0
  63. package/cache/inmemory/object-canon.js +120 -0
  64. package/cache/inmemory/object-canon.js.map +1 -0
  65. package/cache/inmemory/policies.d.ts +96 -0
  66. package/cache/inmemory/policies.d.ts.map +1 -0
  67. package/cache/inmemory/policies.js +416 -0
  68. package/cache/inmemory/policies.js.map +1 -0
  69. package/cache/inmemory/reactiveVars.d.ts +18 -0
  70. package/cache/inmemory/reactiveVars.d.ts.map +1 -0
  71. package/cache/inmemory/reactiveVars.js +65 -0
  72. package/cache/inmemory/reactiveVars.js.map +1 -0
  73. package/cache/inmemory/readFromStore.d.ts +36 -0
  74. package/cache/inmemory/readFromStore.d.ts.map +1 -0
  75. package/cache/inmemory/readFromStore.js +267 -0
  76. package/cache/inmemory/readFromStore.js.map +1 -0
  77. package/cache/inmemory/types.d.ts +81 -0
  78. package/cache/inmemory/types.d.ts.map +1 -0
  79. package/cache/inmemory/types.js +4 -0
  80. package/cache/inmemory/types.js.map +1 -0
  81. package/cache/inmemory/writeToStore.d.ts +37 -0
  82. package/cache/inmemory/writeToStore.d.ts.map +1 -0
  83. package/cache/inmemory/writeToStore.js +394 -0
  84. package/cache/inmemory/writeToStore.js.map +1 -0
  85. package/cache/package.json +8 -0
  86. package/config/jest/setup.d.ts +2 -0
  87. package/config/jest/setup.d.ts.map +1 -0
  88. package/config/jest/setup.js +5 -0
  89. package/config/jest/setup.js.map +1 -0
  90. package/core/ApolloClient.d.ts +76 -0
  91. package/core/ApolloClient.d.ts.map +1 -0
  92. package/core/ApolloClient.js +240 -0
  93. package/core/ApolloClient.js.map +1 -0
  94. package/core/LocalState.d.ts +69 -0
  95. package/core/LocalState.d.ts.map +1 -0
  96. package/core/LocalState.js +321 -0
  97. package/core/LocalState.js.map +1 -0
  98. package/core/ObservableQuery.d.ts +74 -0
  99. package/core/ObservableQuery.d.ts.map +1 -0
  100. package/core/ObservableQuery.js +507 -0
  101. package/core/ObservableQuery.js.map +1 -0
  102. package/core/QueryInfo.d.ts +62 -0
  103. package/core/QueryInfo.d.ts.map +1 -0
  104. package/core/QueryInfo.js +287 -0
  105. package/core/QueryInfo.js.map +1 -0
  106. package/core/QueryManager.d.ts +120 -0
  107. package/core/QueryManager.d.ts.map +1 -0
  108. package/core/QueryManager.js +890 -0
  109. package/core/QueryManager.js.map +1 -0
  110. package/core/core.cjs +2349 -0
  111. package/core/core.cjs.map +1 -0
  112. package/core/core.cjs.native.js +2349 -0
  113. package/core/index.d.ts +17 -0
  114. package/core/index.d.ts.map +1 -0
  115. package/core/index.js +17 -0
  116. package/core/index.js.map +1 -0
  117. package/core/networkStatus.d.ts +11 -0
  118. package/core/networkStatus.d.ts.map +1 -0
  119. package/core/networkStatus.js +14 -0
  120. package/core/networkStatus.js.map +1 -0
  121. package/core/package.json +8 -0
  122. package/core/types.d.ts +74 -0
  123. package/core/types.d.ts.map +1 -0
  124. package/core/types.js +3 -0
  125. package/core/types.js.map +1 -0
  126. package/core/watchQueryOptions.d.ts +78 -0
  127. package/core/watchQueryOptions.d.ts.map +1 -0
  128. package/core/watchQueryOptions.js +2 -0
  129. package/core/watchQueryOptions.js.map +1 -0
  130. package/errors/errors.cjs +49 -0
  131. package/errors/errors.cjs.map +1 -0
  132. package/errors/errors.cjs.native.js +49 -0
  133. package/errors/index.d.ts +23 -0
  134. package/errors/index.d.ts.map +1 -0
  135. package/errors/index.js +42 -0
  136. package/errors/index.js.map +1 -0
  137. package/errors/package.json +8 -0
  138. package/index.d.ts +3 -0
  139. package/index.d.ts.map +1 -0
  140. package/index.js +3 -0
  141. package/index.js.map +1 -0
  142. package/invariantErrorCodes.js +339 -0
  143. package/link/batch/batch.cjs +159 -0
  144. package/link/batch/batch.cjs.map +1 -0
  145. package/link/batch/batch.cjs.native.js +159 -0
  146. package/link/batch/batchLink.d.ts +19 -0
  147. package/link/batch/batchLink.d.ts.map +1 -0
  148. package/link/batch/batchLink.js +31 -0
  149. package/link/batch/batchLink.js.map +1 -0
  150. package/link/batch/batching.d.ts +27 -0
  151. package/link/batch/batching.d.ts.map +1 -0
  152. package/link/batch/batching.js +125 -0
  153. package/link/batch/batching.js.map +1 -0
  154. package/link/batch/index.d.ts +2 -0
  155. package/link/batch/index.d.ts.map +1 -0
  156. package/link/batch/index.js +2 -0
  157. package/link/batch/index.js.map +1 -0
  158. package/link/batch/package.json +8 -0
  159. package/link/batch-http/batch-http.cjs +137 -0
  160. package/link/batch-http/batch-http.cjs.map +1 -0
  161. package/link/batch-http/batch-http.cjs.native.js +137 -0
  162. package/link/batch-http/batchHttpLink.d.ts +16 -0
  163. package/link/batch-http/batchHttpLink.d.ts.map +1 -0
  164. package/link/batch-http/batchHttpLink.js +131 -0
  165. package/link/batch-http/batchHttpLink.js.map +1 -0
  166. package/link/batch-http/index.d.ts +2 -0
  167. package/link/batch-http/index.d.ts.map +1 -0
  168. package/link/batch-http/index.js +2 -0
  169. package/link/batch-http/index.js.map +1 -0
  170. package/link/batch-http/package.json +8 -0
  171. package/link/context/context.cjs +38 -0
  172. package/link/context/context.cjs.map +1 -0
  173. package/link/context/context.cjs.native.js +38 -0
  174. package/link/context/index.d.ts +5 -0
  175. package/link/context/index.d.ts.map +1 -0
  176. package/link/context/index.js +31 -0
  177. package/link/context/index.js.map +1 -0
  178. package/link/context/package.json +8 -0
  179. package/link/core/ApolloLink.d.ts +16 -0
  180. package/link/core/ApolloLink.d.ts.map +1 -0
  181. package/link/core/ApolloLink.js +100 -0
  182. package/link/core/ApolloLink.js.map +1 -0
  183. package/link/core/concat.d.ts +3 -0
  184. package/link/core/concat.d.ts.map +1 -0
  185. package/link/core/concat.js +3 -0
  186. package/link/core/concat.js.map +1 -0
  187. package/link/core/core.cjs +121 -0
  188. package/link/core/core.cjs.map +1 -0
  189. package/link/core/core.cjs.native.js +121 -0
  190. package/link/core/empty.d.ts +3 -0
  191. package/link/core/empty.d.ts.map +1 -0
  192. package/link/core/empty.js +3 -0
  193. package/link/core/empty.js.map +1 -0
  194. package/link/core/execute.d.ts +3 -0
  195. package/link/core/execute.d.ts.map +1 -0
  196. package/link/core/execute.js +3 -0
  197. package/link/core/execute.js.map +1 -0
  198. package/link/core/from.d.ts +3 -0
  199. package/link/core/from.d.ts.map +1 -0
  200. package/link/core/from.js +3 -0
  201. package/link/core/from.js.map +1 -0
  202. package/link/core/index.d.ts +9 -0
  203. package/link/core/index.d.ts.map +1 -0
  204. package/link/core/index.js +9 -0
  205. package/link/core/index.js.map +1 -0
  206. package/link/core/package.json +8 -0
  207. package/link/core/split.d.ts +3 -0
  208. package/link/core/split.d.ts.map +1 -0
  209. package/link/core/split.js +3 -0
  210. package/link/core/split.js.map +1 -0
  211. package/link/core/types.d.ts +52 -0
  212. package/link/core/types.d.ts.map +1 -0
  213. package/link/core/types.js +2 -0
  214. package/link/core/types.js.map +1 -0
  215. package/link/error/error.cjs +90 -0
  216. package/link/error/error.cjs.map +1 -0
  217. package/link/error/error.cjs.native.js +90 -0
  218. package/link/error/index.d.ts +24 -0
  219. package/link/error/index.d.ts.map +1 -0
  220. package/link/error/index.js +83 -0
  221. package/link/error/index.js.map +1 -0
  222. package/link/error/package.json +8 -0
  223. package/link/http/HttpLink.d.ts +8 -0
  224. package/link/http/HttpLink.d.ts.map +1 -0
  225. package/link/http/HttpLink.js +15 -0
  226. package/link/http/HttpLink.js.map +1 -0
  227. package/link/http/checkFetcher.d.ts +2 -0
  228. package/link/http/checkFetcher.d.ts.map +1 -0
  229. package/link/http/checkFetcher.js +7 -0
  230. package/link/http/checkFetcher.js.map +1 -0
  231. package/link/http/createHttpLink.d.ts +4 -0
  232. package/link/http/createHttpLink.d.ts.map +1 -0
  233. package/link/http/createHttpLink.js +127 -0
  234. package/link/http/createHttpLink.js.map +1 -0
  235. package/link/http/createSignalIfSupported.d.ts +8 -0
  236. package/link/http/createSignalIfSupported.d.ts.map +1 -0
  237. package/link/http/createSignalIfSupported.js +8 -0
  238. package/link/http/createSignalIfSupported.js.map +1 -0
  239. package/link/http/http.cjs +593 -0
  240. package/link/http/http.cjs.map +1 -0
  241. package/link/http/http.cjs.native.js +593 -0
  242. package/link/http/index.d.ts +11 -0
  243. package/link/http/index.d.ts.map +1 -0
  244. package/link/http/index.js +11 -0
  245. package/link/http/index.js.map +1 -0
  246. package/link/http/iterators/async.d.ts +2 -0
  247. package/link/http/iterators/async.d.ts.map +1 -0
  248. package/link/http/iterators/async.js +14 -0
  249. package/link/http/iterators/async.js.map +1 -0
  250. package/link/http/iterators/nodeStream.d.ts +4 -0
  251. package/link/http/iterators/nodeStream.d.ts.map +1 -0
  252. package/link/http/iterators/nodeStream.js +71 -0
  253. package/link/http/iterators/nodeStream.js.map +1 -0
  254. package/link/http/iterators/promise.d.ts +2 -0
  255. package/link/http/iterators/promise.d.ts.map +1 -0
  256. package/link/http/iterators/promise.js +28 -0
  257. package/link/http/iterators/promise.js.map +1 -0
  258. package/link/http/iterators/reader.d.ts +2 -0
  259. package/link/http/iterators/reader.d.ts.map +1 -0
  260. package/link/http/iterators/reader.js +15 -0
  261. package/link/http/iterators/reader.js.map +1 -0
  262. package/link/http/package.json +8 -0
  263. package/link/http/parseAndCheckHttpResponse.d.ts +14 -0
  264. package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -0
  265. package/link/http/parseAndCheckHttpResponse.js +148 -0
  266. package/link/http/parseAndCheckHttpResponse.js.map +1 -0
  267. package/link/http/responseIterator.d.ts +3 -0
  268. package/link/http/responseIterator.d.ts.map +1 -0
  269. package/link/http/responseIterator.js +23 -0
  270. package/link/http/responseIterator.js.map +1 -0
  271. package/link/http/rewriteURIForGET.d.ts +9 -0
  272. package/link/http/rewriteURIForGET.d.ts.map +1 -0
  273. package/link/http/rewriteURIForGET.js +43 -0
  274. package/link/http/rewriteURIForGET.js.map +1 -0
  275. package/link/http/selectHttpOptionsAndBody.d.ts +57 -0
  276. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -0
  277. package/link/http/selectHttpOptionsAndBody.js +78 -0
  278. package/link/http/selectHttpOptionsAndBody.js.map +1 -0
  279. package/link/http/selectURI.d.ts +3 -0
  280. package/link/http/selectURI.d.ts.map +1 -0
  281. package/link/http/selectURI.js +14 -0
  282. package/link/http/selectURI.js.map +1 -0
  283. package/link/http/serializeFetchParameter.d.ts +6 -0
  284. package/link/http/serializeFetchParameter.d.ts.map +1 -0
  285. package/link/http/serializeFetchParameter.js +14 -0
  286. package/link/http/serializeFetchParameter.js.map +1 -0
  287. package/link/persisted-queries/index.d.ts +31 -0
  288. package/link/persisted-queries/index.d.ts.map +1 -0
  289. package/link/persisted-queries/index.js +170 -0
  290. package/link/persisted-queries/index.js.map +1 -0
  291. package/link/persisted-queries/package.json +8 -0
  292. package/link/persisted-queries/persisted-queries.cjs +174 -0
  293. package/link/persisted-queries/persisted-queries.cjs.map +1 -0
  294. package/link/persisted-queries/persisted-queries.cjs.native.js +174 -0
  295. package/link/retry/delayFunction.d.ts +11 -0
  296. package/link/retry/delayFunction.d.ts.map +1 -0
  297. package/link/retry/delayFunction.js +12 -0
  298. package/link/retry/delayFunction.js.map +1 -0
  299. package/link/retry/index.d.ts +2 -0
  300. package/link/retry/index.d.ts.map +1 -0
  301. package/link/retry/index.js +2 -0
  302. package/link/retry/index.js.map +1 -0
  303. package/link/retry/package.json +8 -0
  304. package/link/retry/retry.cjs +170 -0
  305. package/link/retry/retry.cjs.map +1 -0
  306. package/link/retry/retry.cjs.native.js +170 -0
  307. package/link/retry/retryFunction.d.ts +10 -0
  308. package/link/retry/retryFunction.d.ts.map +1 -0
  309. package/link/retry/retryFunction.js +9 -0
  310. package/link/retry/retryFunction.js.map +1 -0
  311. package/link/retry/retryLink.d.ts +17 -0
  312. package/link/retry/retryLink.d.ts.map +1 -0
  313. package/link/retry/retryLink.js +145 -0
  314. package/link/retry/retryLink.js.map +1 -0
  315. package/link/schema/index.d.ts +22 -0
  316. package/link/schema/index.d.ts.map +1 -0
  317. package/link/schema/index.js +50 -0
  318. package/link/schema/index.js.map +1 -0
  319. package/link/schema/package.json +8 -0
  320. package/link/schema/schema.cjs +56 -0
  321. package/link/schema/schema.cjs.map +1 -0
  322. package/link/schema/schema.cjs.native.js +56 -0
  323. package/link/subscriptions/index.d.ts +9 -0
  324. package/link/subscriptions/index.d.ts.map +1 -0
  325. package/link/subscriptions/index.js +39 -0
  326. package/link/subscriptions/index.js.map +1 -0
  327. package/link/subscriptions/package.json +8 -0
  328. package/link/subscriptions/subscriptions.cjs +45 -0
  329. package/link/subscriptions/subscriptions.cjs.map +1 -0
  330. package/link/subscriptions/subscriptions.cjs.native.js +45 -0
  331. package/link/utils/createOperation.d.ts +3 -0
  332. package/link/utils/createOperation.d.ts.map +1 -0
  333. package/link/utils/createOperation.js +23 -0
  334. package/link/utils/createOperation.js.map +1 -0
  335. package/link/utils/fromError.d.ts +3 -0
  336. package/link/utils/fromError.d.ts.map +1 -0
  337. package/link/utils/fromError.js +7 -0
  338. package/link/utils/fromError.js.map +1 -0
  339. package/link/utils/fromPromise.d.ts +3 -0
  340. package/link/utils/fromPromise.d.ts.map +1 -0
  341. package/link/utils/fromPromise.js +12 -0
  342. package/link/utils/fromPromise.js.map +1 -0
  343. package/link/utils/index.d.ts +9 -0
  344. package/link/utils/index.d.ts.map +1 -0
  345. package/link/utils/index.js +9 -0
  346. package/link/utils/index.js.map +1 -0
  347. package/link/utils/package.json +8 -0
  348. package/link/utils/throwServerError.d.ts +7 -0
  349. package/link/utils/throwServerError.d.ts.map +1 -0
  350. package/link/utils/throwServerError.js +9 -0
  351. package/link/utils/throwServerError.js.map +1 -0
  352. package/link/utils/toPromise.d.ts +3 -0
  353. package/link/utils/toPromise.d.ts.map +1 -0
  354. package/link/utils/toPromise.js +19 -0
  355. package/link/utils/toPromise.js.map +1 -0
  356. package/link/utils/transformOperation.d.ts +3 -0
  357. package/link/utils/transformOperation.d.ts.map +1 -0
  358. package/link/utils/transformOperation.js +17 -0
  359. package/link/utils/transformOperation.js.map +1 -0
  360. package/link/utils/utils.cjs +115 -0
  361. package/link/utils/utils.cjs.map +1 -0
  362. package/link/utils/utils.cjs.native.js +115 -0
  363. package/link/utils/validateOperation.d.ts +3 -0
  364. package/link/utils/validateOperation.d.ts.map +1 -0
  365. package/link/utils/validateOperation.js +18 -0
  366. package/link/utils/validateOperation.js.map +1 -0
  367. package/link/ws/index.d.ts +17 -0
  368. package/link/ws/index.d.ts.map +1 -0
  369. package/link/ws/index.js +22 -0
  370. package/link/ws/index.js.map +1 -0
  371. package/link/ws/package.json +8 -0
  372. package/link/ws/ws.cjs +28 -0
  373. package/link/ws/ws.cjs.map +1 -0
  374. package/link/ws/ws.cjs.native.js +28 -0
  375. package/main.cjs +16 -0
  376. package/main.cjs.map +1 -0
  377. package/main.cjs.native.js +16 -0
  378. package/package.json +141 -0
  379. package/react/cache/SuspenseCache.d.ts +18 -0
  380. package/react/cache/SuspenseCache.d.ts.map +1 -0
  381. package/react/cache/SuspenseCache.js +49 -0
  382. package/react/cache/SuspenseCache.js.map +1 -0
  383. package/react/cache/index.d.ts +2 -0
  384. package/react/cache/index.d.ts.map +1 -0
  385. package/react/cache/index.js +2 -0
  386. package/react/cache/index.js.map +1 -0
  387. package/react/components/Mutation.d.ts +12 -0
  388. package/react/components/Mutation.d.ts.map +1 -0
  389. package/react/components/Mutation.js +22 -0
  390. package/react/components/Mutation.js.map +1 -0
  391. package/react/components/Query.d.ts +12 -0
  392. package/react/components/Query.d.ts.map +1 -0
  393. package/react/components/Query.js +23 -0
  394. package/react/components/Query.js.map +1 -0
  395. package/react/components/Subscription.d.ts +12 -0
  396. package/react/components/Subscription.d.ts.map +1 -0
  397. package/react/components/Subscription.js +17 -0
  398. package/react/components/Subscription.js.map +1 -0
  399. package/react/components/components.cjs +81 -0
  400. package/react/components/components.cjs.map +1 -0
  401. package/react/components/components.cjs.native.js +81 -0
  402. package/react/components/index.d.ts +5 -0
  403. package/react/components/index.d.ts.map +1 -0
  404. package/react/components/index.js +5 -0
  405. package/react/components/index.js.map +1 -0
  406. package/react/components/package.json +8 -0
  407. package/react/components/types.d.ts +18 -0
  408. package/react/components/types.d.ts.map +1 -0
  409. package/react/components/types.js +2 -0
  410. package/react/components/types.js.map +1 -0
  411. package/react/context/ApolloConsumer.d.ts +7 -0
  412. package/react/context/ApolloConsumer.d.ts.map +1 -0
  413. package/react/context/ApolloConsumer.js +12 -0
  414. package/react/context/ApolloConsumer.js.map +1 -0
  415. package/react/context/ApolloContext.d.ts +12 -0
  416. package/react/context/ApolloContext.d.ts.map +1 -0
  417. package/react/context/ApolloContext.js +20 -0
  418. package/react/context/ApolloContext.js.map +1 -0
  419. package/react/context/ApolloProvider.d.ts +10 -0
  420. package/react/context/ApolloProvider.d.ts.map +1 -0
  421. package/react/context/ApolloProvider.js +20 -0
  422. package/react/context/ApolloProvider.js.map +1 -0
  423. package/react/context/context.cjs +70 -0
  424. package/react/context/context.cjs.map +1 -0
  425. package/react/context/context.cjs.native.js +70 -0
  426. package/react/context/index.d.ts +5 -0
  427. package/react/context/index.d.ts.map +1 -0
  428. package/react/context/index.js +5 -0
  429. package/react/context/index.js.map +1 -0
  430. package/react/context/package.json +8 -0
  431. package/react/hoc/graphql.d.ts +6 -0
  432. package/react/hoc/graphql.d.ts.map +1 -0
  433. package/react/hoc/graphql.js +17 -0
  434. package/react/hoc/graphql.js.map +1 -0
  435. package/react/hoc/hoc-utils.d.ts +17 -0
  436. package/react/hoc/hoc-utils.d.ts.map +1 -0
  437. package/react/hoc/hoc-utils.js +47 -0
  438. package/react/hoc/hoc-utils.js.map +1 -0
  439. package/react/hoc/hoc.cjs +325 -0
  440. package/react/hoc/hoc.cjs.map +1 -0
  441. package/react/hoc/hoc.cjs.native.js +325 -0
  442. package/react/hoc/index.d.ts +8 -0
  443. package/react/hoc/index.d.ts.map +1 -0
  444. package/react/hoc/index.js +8 -0
  445. package/react/hoc/index.js.map +1 -0
  446. package/react/hoc/mutation-hoc.d.ts +7 -0
  447. package/react/hoc/mutation-hoc.d.ts.map +1 -0
  448. package/react/hoc/mutation-hoc.js +63 -0
  449. package/react/hoc/mutation-hoc.js.map +1 -0
  450. package/react/hoc/package.json +8 -0
  451. package/react/hoc/query-hoc.d.ts +5 -0
  452. package/react/hoc/query-hoc.d.ts.map +1 -0
  453. package/react/hoc/query-hoc.js +70 -0
  454. package/react/hoc/query-hoc.js.map +1 -0
  455. package/react/hoc/subscription-hoc.d.ts +5 -0
  456. package/react/hoc/subscription-hoc.d.ts.map +1 -0
  457. package/react/hoc/subscription-hoc.js +80 -0
  458. package/react/hoc/subscription-hoc.js.map +1 -0
  459. package/react/hoc/types.d.ts +43 -0
  460. package/react/hoc/types.d.ts.map +1 -0
  461. package/react/hoc/types.js +2 -0
  462. package/react/hoc/types.js.map +1 -0
  463. package/react/hoc/withApollo.d.ts +4 -0
  464. package/react/hoc/withApollo.d.ts.map +1 -0
  465. package/react/hoc/withApollo.js +45 -0
  466. package/react/hoc/withApollo.js.map +1 -0
  467. package/react/hooks/compareResults.d.ts +3 -0
  468. package/react/hooks/compareResults.d.ts.map +1 -0
  469. package/react/hooks/compareResults.js +63 -0
  470. package/react/hooks/compareResults.js.map +1 -0
  471. package/react/hooks/hooks.cjs +913 -0
  472. package/react/hooks/hooks.cjs.map +1 -0
  473. package/react/hooks/hooks.cjs.native.js +913 -0
  474. package/react/hooks/index.d.ts +10 -0
  475. package/react/hooks/index.d.ts.map +1 -0
  476. package/react/hooks/index.js +10 -0
  477. package/react/hooks/index.js.map +1 -0
  478. package/react/hooks/internal/index.d.ts +3 -0
  479. package/react/hooks/internal/index.d.ts.map +1 -0
  480. package/react/hooks/internal/index.js +3 -0
  481. package/react/hooks/internal/index.js.map +1 -0
  482. package/react/hooks/internal/useDeepMemo.d.ts +3 -0
  483. package/react/hooks/internal/useDeepMemo.d.ts.map +1 -0
  484. package/react/hooks/internal/useDeepMemo.js +10 -0
  485. package/react/hooks/internal/useDeepMemo.js.map +1 -0
  486. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +3 -0
  487. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -0
  488. package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -0
  489. package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -0
  490. package/react/hooks/package.json +8 -0
  491. package/react/hooks/useApolloClient.d.ts +3 -0
  492. package/react/hooks/useApolloClient.d.ts.map +1 -0
  493. package/react/hooks/useApolloClient.js +12 -0
  494. package/react/hooks/useApolloClient.js.map +1 -0
  495. package/react/hooks/useFragment.d.ts +13 -0
  496. package/react/hooks/useFragment.d.ts.map +1 -0
  497. package/react/hooks/useFragment.js +39 -0
  498. package/react/hooks/useFragment.js.map +1 -0
  499. package/react/hooks/useLazyQuery.d.ts +6 -0
  500. package/react/hooks/useLazyQuery.d.ts.map +1 -0
  501. package/react/hooks/useLazyQuery.js +71 -0
  502. package/react/hooks/useLazyQuery.js.map +1 -0
  503. package/react/hooks/useMutation.d.ts +6 -0
  504. package/react/hooks/useMutation.d.ts.map +1 -0
  505. package/react/hooks/useMutation.js +100 -0
  506. package/react/hooks/useMutation.js.map +1 -0
  507. package/react/hooks/useQuery.d.ts +41 -0
  508. package/react/hooks/useQuery.d.ts.map +1 -0
  509. package/react/hooks/useQuery.js +302 -0
  510. package/react/hooks/useQuery.js.map +1 -0
  511. package/react/hooks/useReactiveVar.d.ts +3 -0
  512. package/react/hooks/useReactiveVar.d.ts.map +1 -0
  513. package/react/hooks/useReactiveVar.js +16 -0
  514. package/react/hooks/useReactiveVar.js.map +1 -0
  515. package/react/hooks/useSubscription.d.ts +6 -0
  516. package/react/hooks/useSubscription.d.ts.map +1 -0
  517. package/react/hooks/useSubscription.js +141 -0
  518. package/react/hooks/useSubscription.js.map +1 -0
  519. package/react/hooks/useSuspenseCache.d.ts +2 -0
  520. package/react/hooks/useSuspenseCache.d.ts.map +1 -0
  521. package/react/hooks/useSuspenseCache.js +10 -0
  522. package/react/hooks/useSuspenseCache.js.map +1 -0
  523. package/react/hooks/useSuspenseQuery.d.ts +12 -0
  524. package/react/hooks/useSuspenseQuery.d.ts.map +1 -0
  525. package/react/hooks/useSuspenseQuery.js +181 -0
  526. package/react/hooks/useSuspenseQuery.js.map +1 -0
  527. package/react/hooks/useSyncExternalStore.d.ts +4 -0
  528. package/react/hooks/useSyncExternalStore.d.ts.map +1 -0
  529. package/react/hooks/useSyncExternalStore.js +48 -0
  530. package/react/hooks/useSyncExternalStore.js.map +1 -0
  531. package/react/index.d.ts +7 -0
  532. package/react/index.d.ts.map +1 -0
  533. package/react/index.js +7 -0
  534. package/react/index.js.map +1 -0
  535. package/react/package.json +8 -0
  536. package/react/parser/index.d.ts +15 -0
  537. package/react/parser/index.d.ts.map +1 -0
  538. package/react/parser/index.js +94 -0
  539. package/react/parser/index.js.map +1 -0
  540. package/react/parser/package.json +8 -0
  541. package/react/parser/parser.cjs +103 -0
  542. package/react/parser/parser.cjs.map +1 -0
  543. package/react/parser/parser.cjs.native.js +103 -0
  544. package/react/react.cjs +69 -0
  545. package/react/react.cjs.map +1 -0
  546. package/react/react.cjs.native.js +69 -0
  547. package/react/ssr/RenderPromises.d.ts +22 -0
  548. package/react/ssr/RenderPromises.d.ts.map +1 -0
  549. package/react/ssr/RenderPromises.js +90 -0
  550. package/react/ssr/RenderPromises.js.map +1 -0
  551. package/react/ssr/getDataFromTree.d.ts +13 -0
  552. package/react/ssr/getDataFromTree.d.ts.map +1 -0
  553. package/react/ssr/getDataFromTree.js +32 -0
  554. package/react/ssr/getDataFromTree.js.map +1 -0
  555. package/react/ssr/index.d.ts +4 -0
  556. package/react/ssr/index.d.ts.map +1 -0
  557. package/react/ssr/index.js +4 -0
  558. package/react/ssr/index.js.map +1 -0
  559. package/react/ssr/package.json +8 -0
  560. package/react/ssr/renderToStringWithData.d.ts +3 -0
  561. package/react/ssr/renderToStringWithData.d.ts.map +1 -0
  562. package/react/ssr/renderToStringWithData.js +9 -0
  563. package/react/ssr/renderToStringWithData.js.map +1 -0
  564. package/react/ssr/ssr.cjs +151 -0
  565. package/react/ssr/ssr.cjs.map +1 -0
  566. package/react/ssr/ssr.cjs.native.js +151 -0
  567. package/react/types/types.d.ts +130 -0
  568. package/react/types/types.d.ts.map +1 -0
  569. package/react/types/types.js +2 -0
  570. package/react/types/types.js.map +1 -0
  571. package/testing/core/core.cjs +315 -0
  572. package/testing/core/core.cjs.map +1 -0
  573. package/testing/core/core.cjs.native.js +315 -0
  574. package/testing/core/index.d.ts +8 -0
  575. package/testing/core/index.d.ts.map +1 -0
  576. package/testing/core/index.js +8 -0
  577. package/testing/core/index.js.map +1 -0
  578. package/testing/core/itAsync.d.ts +6 -0
  579. package/testing/core/itAsync.d.ts.map +1 -0
  580. package/testing/core/itAsync.js +19 -0
  581. package/testing/core/itAsync.js.map +1 -0
  582. package/testing/core/mocking/mockClient.d.ts +5 -0
  583. package/testing/core/mocking/mockClient.d.ts.map +1 -0
  584. package/testing/core/mocking/mockClient.js +14 -0
  585. package/testing/core/mocking/mockClient.js.map +1 -0
  586. package/testing/core/mocking/mockFetch.d.ts +24 -0
  587. package/testing/core/mocking/mockFetch.d.ts.map +1 -0
  588. package/testing/core/mocking/mockFetch.js +83 -0
  589. package/testing/core/mocking/mockFetch.js.map +1 -0
  590. package/testing/core/mocking/mockLink.d.ts +28 -0
  591. package/testing/core/mocking/mockLink.d.ts.map +1 -0
  592. package/testing/core/mocking/mockLink.js +139 -0
  593. package/testing/core/mocking/mockLink.js.map +1 -0
  594. package/testing/core/mocking/mockQueryManager.d.ts +5 -0
  595. package/testing/core/mocking/mockQueryManager.d.ts.map +1 -0
  596. package/testing/core/mocking/mockQueryManager.js +14 -0
  597. package/testing/core/mocking/mockQueryManager.js.map +1 -0
  598. package/testing/core/mocking/mockSubscriptionLink.d.ts +24 -0
  599. package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -0
  600. package/testing/core/mocking/mockSubscriptionLink.js +62 -0
  601. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -0
  602. package/testing/core/mocking/mockWatchQuery.d.ts +5 -0
  603. package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -0
  604. package/testing/core/mocking/mockWatchQuery.js +15 -0
  605. package/testing/core/mocking/mockWatchQuery.js.map +1 -0
  606. package/testing/core/observableToPromise.d.ts +15 -0
  607. package/testing/core/observableToPromise.d.ts.map +1 -0
  608. package/testing/core/observableToPromise.js +65 -0
  609. package/testing/core/observableToPromise.js.map +1 -0
  610. package/testing/core/package.json +8 -0
  611. package/testing/core/subscribeAndCount.d.ts +3 -0
  612. package/testing/core/subscribeAndCount.d.ts.map +1 -0
  613. package/testing/core/subscribeAndCount.js +16 -0
  614. package/testing/core/subscribeAndCount.js.map +1 -0
  615. package/testing/core/wait.d.ts +3 -0
  616. package/testing/core/wait.d.ts.map +1 -0
  617. package/testing/core/wait.js +16 -0
  618. package/testing/core/wait.js.map +1 -0
  619. package/testing/core/withConsoleSpy.d.ts +4 -0
  620. package/testing/core/withConsoleSpy.d.ts.map +1 -0
  621. package/testing/core/withConsoleSpy.js +39 -0
  622. package/testing/core/withConsoleSpy.js.map +1 -0
  623. package/testing/core/wrap.d.ts +4 -0
  624. package/testing/core/wrap.d.ts.map +1 -0
  625. package/testing/core/wrap.js +26 -0
  626. package/testing/core/wrap.js.map +1 -0
  627. package/testing/index.d.ts +4 -0
  628. package/testing/index.d.ts.map +1 -0
  629. package/testing/index.js +4 -0
  630. package/testing/index.js.map +1 -0
  631. package/testing/package.json +8 -0
  632. package/testing/react/MockedProvider.d.ts +30 -0
  633. package/testing/react/MockedProvider.d.ts.map +1 -0
  634. package/testing/react/MockedProvider.js +39 -0
  635. package/testing/react/MockedProvider.js.map +1 -0
  636. package/testing/testing.cjs +109 -0
  637. package/testing/testing.cjs.map +1 -0
  638. package/testing/testing.cjs.native.js +109 -0
  639. package/utilities/common/arrays.d.ts +2 -0
  640. package/utilities/common/arrays.d.ts.map +1 -0
  641. package/utilities/common/arrays.js +4 -0
  642. package/utilities/common/arrays.js.map +1 -0
  643. package/utilities/common/canUse.d.ts +7 -0
  644. package/utilities/common/canUse.d.ts.map +1 -0
  645. package/utilities/common/canUse.js +11 -0
  646. package/utilities/common/canUse.js.map +1 -0
  647. package/utilities/common/cloneDeep.d.ts +2 -0
  648. package/utilities/common/cloneDeep.d.ts.map +1 -0
  649. package/utilities/common/cloneDeep.js +33 -0
  650. package/utilities/common/cloneDeep.js.map +1 -0
  651. package/utilities/common/compact.d.ts +3 -0
  652. package/utilities/common/compact.d.ts.map +1 -0
  653. package/utilities/common/compact.js +19 -0
  654. package/utilities/common/compact.js.map +1 -0
  655. package/utilities/common/errorHandling.d.ts +4 -0
  656. package/utilities/common/errorHandling.d.ts.map +1 -0
  657. package/utilities/common/errorHandling.js +21 -0
  658. package/utilities/common/errorHandling.js.map +1 -0
  659. package/utilities/common/filterInPlace.d.ts +2 -0
  660. package/utilities/common/filterInPlace.d.ts.map +1 -0
  661. package/utilities/common/filterInPlace.js +11 -0
  662. package/utilities/common/filterInPlace.js.map +1 -0
  663. package/utilities/common/incrementalResult.d.ts +6 -0
  664. package/utilities/common/incrementalResult.d.ts.map +1 -0
  665. package/utilities/common/incrementalResult.js +32 -0
  666. package/utilities/common/incrementalResult.js.map +1 -0
  667. package/utilities/common/makeUniqueId.d.ts +2 -0
  668. package/utilities/common/makeUniqueId.d.ts.map +1 -0
  669. package/utilities/common/makeUniqueId.js +7 -0
  670. package/utilities/common/makeUniqueId.js.map +1 -0
  671. package/utilities/common/maybeDeepFreeze.d.ts +2 -0
  672. package/utilities/common/maybeDeepFreeze.d.ts.map +1 -0
  673. package/utilities/common/maybeDeepFreeze.js +34 -0
  674. package/utilities/common/maybeDeepFreeze.js.map +1 -0
  675. package/utilities/common/mergeDeep.d.ts +14 -0
  676. package/utilities/common/mergeDeep.d.ts.map +1 -0
  677. package/utilities/common/mergeDeep.js +76 -0
  678. package/utilities/common/mergeDeep.js.map +1 -0
  679. package/utilities/common/mergeOptions.d.ts +5 -0
  680. package/utilities/common/mergeOptions.d.ts.map +1 -0
  681. package/utilities/common/mergeOptions.js +8 -0
  682. package/utilities/common/mergeOptions.js.map +1 -0
  683. package/utilities/common/objects.d.ts +2 -0
  684. package/utilities/common/objects.d.ts.map +1 -0
  685. package/utilities/common/objects.js +4 -0
  686. package/utilities/common/objects.js.map +1 -0
  687. package/utilities/common/responseIterator.d.ts +10 -0
  688. package/utilities/common/responseIterator.d.ts.map +1 -0
  689. package/utilities/common/responseIterator.js +21 -0
  690. package/utilities/common/responseIterator.js.map +1 -0
  691. package/utilities/common/stringifyForDisplay.d.ts +2 -0
  692. package/utilities/common/stringifyForDisplay.d.ts.map +1 -0
  693. package/utilities/common/stringifyForDisplay.js +8 -0
  694. package/utilities/common/stringifyForDisplay.js.map +1 -0
  695. package/utilities/globals/DEV.d.ts +3 -0
  696. package/utilities/globals/DEV.d.ts.map +1 -0
  697. package/utilities/globals/DEV.js +9 -0
  698. package/utilities/globals/DEV.js.map +1 -0
  699. package/utilities/globals/fix-graphql.d.ts +2 -0
  700. package/utilities/globals/fix-graphql.d.ts.map +1 -0
  701. package/utilities/globals/fix-graphql.js +6 -0
  702. package/utilities/globals/fix-graphql.js.map +1 -0
  703. package/utilities/globals/global.d.ts +5 -0
  704. package/utilities/globals/global.d.ts.map +1 -0
  705. package/utilities/globals/global.js +6 -0
  706. package/utilities/globals/global.js.map +1 -0
  707. package/utilities/globals/globals.cjs +42 -0
  708. package/utilities/globals/globals.cjs.map +1 -0
  709. package/utilities/globals/globals.cjs.native.js +42 -0
  710. package/utilities/globals/index.d.ts +8 -0
  711. package/utilities/globals/index.d.ts.map +1 -0
  712. package/utilities/globals/index.js +10 -0
  713. package/utilities/globals/index.js.map +1 -0
  714. package/utilities/globals/maybe.d.ts +2 -0
  715. package/utilities/globals/maybe.d.ts.map +1 -0
  716. package/utilities/globals/maybe.js +7 -0
  717. package/utilities/globals/maybe.js.map +1 -0
  718. package/utilities/globals/package.json +8 -0
  719. package/utilities/graphql/directives.d.ts +18 -0
  720. package/utilities/graphql/directives.d.ts.map +1 -0
  721. package/utilities/graphql/directives.js +72 -0
  722. package/utilities/graphql/directives.js.map +1 -0
  723. package/utilities/graphql/fragments.d.ts +9 -0
  724. package/utilities/graphql/fragments.d.ts.map +1 -0
  725. package/utilities/graphql/fragments.js +64 -0
  726. package/utilities/graphql/fragments.js.map +1 -0
  727. package/utilities/graphql/getFromAST.d.ts +10 -0
  728. package/utilities/graphql/getFromAST.d.ts.map +1 -0
  729. package/utilities/graphql/getFromAST.js +76 -0
  730. package/utilities/graphql/getFromAST.js.map +1 -0
  731. package/utilities/graphql/storeUtils.d.ts +32 -0
  732. package/utilities/graphql/storeUtils.d.ts.map +1 -0
  733. package/utilities/graphql/storeUtils.js +208 -0
  734. package/utilities/graphql/storeUtils.js.map +1 -0
  735. package/utilities/graphql/transform.d.ts +27 -0
  736. package/utilities/graphql/transform.d.ts.map +1 -0
  737. package/utilities/graphql/transform.js +281 -0
  738. package/utilities/graphql/transform.js.map +1 -0
  739. package/utilities/index.d.ts +27 -0
  740. package/utilities/index.d.ts.map +1 -0
  741. package/utilities/index.js +27 -0
  742. package/utilities/index.js.map +1 -0
  743. package/utilities/observables/Concast.d.ts +27 -0
  744. package/utilities/observables/Concast.d.ts.map +1 -0
  745. package/utilities/observables/Concast.js +137 -0
  746. package/utilities/observables/Concast.js.map +1 -0
  747. package/utilities/observables/Observable.d.ts +5 -0
  748. package/utilities/observables/Observable.d.ts.map +1 -0
  749. package/utilities/observables/Observable.js +9 -0
  750. package/utilities/observables/Observable.js.map +1 -0
  751. package/utilities/observables/asyncMap.d.ts +3 -0
  752. package/utilities/observables/asyncMap.d.ts.map +1 -0
  753. package/utilities/observables/asyncMap.js +49 -0
  754. package/utilities/observables/asyncMap.js.map +1 -0
  755. package/utilities/observables/iteration.d.ts +3 -0
  756. package/utilities/observables/iteration.d.ts.map +1 -0
  757. package/utilities/observables/iteration.js +6 -0
  758. package/utilities/observables/iteration.js.map +1 -0
  759. package/utilities/observables/subclassing.d.ts +3 -0
  760. package/utilities/observables/subclassing.d.ts.map +1 -0
  761. package/utilities/observables/subclassing.js +13 -0
  762. package/utilities/observables/subclassing.js.map +1 -0
  763. package/utilities/package.json +8 -0
  764. package/utilities/policies/pagination.d.ts +28 -0
  765. package/utilities/policies/pagination.d.ts.map +1 -0
  766. package/utilities/policies/pagination.js +151 -0
  767. package/utilities/policies/pagination.js.map +1 -0
  768. package/utilities/types/IsStrictlyAny.d.ts +5 -0
  769. package/utilities/types/IsStrictlyAny.d.ts.map +1 -0
  770. package/utilities/types/IsStrictlyAny.js +2 -0
  771. package/utilities/types/IsStrictlyAny.js.map +1 -0
  772. package/utilities/utilities.cjs +1371 -0
  773. package/utilities/utilities.cjs.map +1 -0
  774. package/utilities/utilities.cjs.native.js +1371 -0
  775. package/version.d.ts +2 -0
  776. package/version.d.ts.map +1 -0
  777. package/version.js +2 -0
  778. package/version.js.map +1 -0
@@ -0,0 +1,302 @@
1
+ import { __assign, __rest } from "tslib";
2
+ import { invariant, __DEV__ } from "../../utilities/globals/index.js";
3
+ import { useCallback, useContext, useMemo, useRef, useState, } from 'react';
4
+ import { useSyncExternalStore } from "./useSyncExternalStore.js";
5
+ import { equal } from '@wry/equality';
6
+ import { mergeOptions } from "../../core/index.js";
7
+ import { getApolloContext } from "../context/index.js";
8
+ import { ApolloError } from "../../errors/index.js";
9
+ import { NetworkStatus, } from "../../core/index.js";
10
+ import { DocumentType, verifyDocumentType } from "../parser/index.js";
11
+ import { useApolloClient } from "./useApolloClient.js";
12
+ import { canUseWeakMap, canUseWeakSet, compact, isNonEmptyArray, maybeDeepFreeze } from "../../utilities/index.js";
13
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
14
+ export function useQuery(query, options) {
15
+ if (options === void 0) { options = Object.create(null); }
16
+ return useInternalState(useApolloClient(options.client), query).useQuery(options);
17
+ }
18
+ export function useInternalState(client, query) {
19
+ var stateRef = useRef();
20
+ if (!stateRef.current ||
21
+ client !== stateRef.current.client ||
22
+ query !== stateRef.current.query) {
23
+ stateRef.current = new InternalState(client, query, stateRef.current);
24
+ }
25
+ var state = stateRef.current;
26
+ var _a = useState(0), _tick = _a[0], setTick = _a[1];
27
+ state.forceUpdate = function () {
28
+ setTick(function (tick) { return tick + 1; });
29
+ };
30
+ return state;
31
+ }
32
+ var InternalState = (function () {
33
+ function InternalState(client, query, previous) {
34
+ this.client = client;
35
+ this.query = query;
36
+ this.asyncResolveFns = new Set();
37
+ this.optionsToIgnoreOnce = new (canUseWeakSet ? WeakSet : Set)();
38
+ this.ssrDisabledResult = maybeDeepFreeze({
39
+ loading: true,
40
+ data: void 0,
41
+ error: void 0,
42
+ networkStatus: NetworkStatus.loading,
43
+ });
44
+ this.skipStandbyResult = maybeDeepFreeze({
45
+ loading: false,
46
+ data: void 0,
47
+ error: void 0,
48
+ networkStatus: NetworkStatus.ready,
49
+ });
50
+ this.toQueryResultCache = new (canUseWeakMap ? WeakMap : Map)();
51
+ verifyDocumentType(query, DocumentType.Query);
52
+ var previousResult = previous && previous.result;
53
+ var previousData = previousResult && previousResult.data;
54
+ if (previousData) {
55
+ this.previousData = previousData;
56
+ }
57
+ }
58
+ InternalState.prototype.forceUpdate = function () {
59
+ __DEV__ && invariant.warn("Calling default no-op implementation of InternalState#forceUpdate");
60
+ };
61
+ InternalState.prototype.asyncUpdate = function (signal) {
62
+ var _this = this;
63
+ return new Promise(function (resolve, reject) {
64
+ var watchQueryOptions = _this.watchQueryOptions;
65
+ var handleAborted = function () {
66
+ _this.asyncResolveFns.delete(resolve);
67
+ _this.optionsToIgnoreOnce.delete(watchQueryOptions);
68
+ signal.removeEventListener('abort', handleAborted);
69
+ reject(signal.reason);
70
+ };
71
+ _this.asyncResolveFns.add(resolve);
72
+ _this.optionsToIgnoreOnce.add(watchQueryOptions);
73
+ signal.addEventListener('abort', handleAborted);
74
+ _this.forceUpdate();
75
+ });
76
+ };
77
+ InternalState.prototype.useQuery = function (options) {
78
+ var _this = this;
79
+ this.renderPromises = useContext(getApolloContext()).renderPromises;
80
+ this.useOptions(options);
81
+ var obsQuery = this.useObservableQuery();
82
+ var result = useSyncExternalStore(useCallback(function () {
83
+ if (_this.renderPromises) {
84
+ return function () { };
85
+ }
86
+ var onNext = function () {
87
+ var previousResult = _this.result;
88
+ var result = obsQuery.getCurrentResult();
89
+ if (previousResult &&
90
+ previousResult.loading === result.loading &&
91
+ previousResult.networkStatus === result.networkStatus &&
92
+ equal(previousResult.data, result.data)) {
93
+ return;
94
+ }
95
+ _this.setResult(result);
96
+ };
97
+ var onError = function (error) {
98
+ var last = obsQuery["last"];
99
+ subscription.unsubscribe();
100
+ try {
101
+ obsQuery.resetLastResults();
102
+ subscription = obsQuery.subscribe(onNext, onError);
103
+ }
104
+ finally {
105
+ obsQuery["last"] = last;
106
+ }
107
+ if (!hasOwnProperty.call(error, 'graphQLErrors')) {
108
+ throw error;
109
+ }
110
+ var previousResult = _this.result;
111
+ if (!previousResult ||
112
+ (previousResult && previousResult.loading) ||
113
+ !equal(error, previousResult.error)) {
114
+ _this.setResult({
115
+ data: (previousResult && previousResult.data),
116
+ error: error,
117
+ loading: false,
118
+ networkStatus: NetworkStatus.error,
119
+ });
120
+ }
121
+ };
122
+ var subscription = obsQuery.subscribe(onNext, onError);
123
+ return function () { return subscription.unsubscribe(); };
124
+ }, [
125
+ obsQuery,
126
+ this.renderPromises,
127
+ this.client.disableNetworkFetches,
128
+ ]), function () { return _this.getCurrentResult(); }, function () { return _this.getCurrentResult(); });
129
+ this.unsafeHandlePartialRefetch(result);
130
+ var queryResult = this.toQueryResult(result);
131
+ if (!queryResult.loading && this.asyncResolveFns.size) {
132
+ this.asyncResolveFns.forEach(function (resolve) { return resolve(queryResult); });
133
+ this.asyncResolveFns.clear();
134
+ }
135
+ return queryResult;
136
+ };
137
+ InternalState.prototype.useOptions = function (options) {
138
+ var _a;
139
+ var watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
140
+ var currentWatchQueryOptions = this.watchQueryOptions;
141
+ if (this.optionsToIgnoreOnce.has(currentWatchQueryOptions) ||
142
+ !equal(watchQueryOptions, currentWatchQueryOptions)) {
143
+ this.watchQueryOptions = watchQueryOptions;
144
+ if (currentWatchQueryOptions && this.observable) {
145
+ this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);
146
+ this.observable.reobserve(this.getObsQueryOptions());
147
+ this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
148
+ this.result = void 0;
149
+ }
150
+ }
151
+ this.onCompleted = options.onCompleted || InternalState.prototype.onCompleted;
152
+ this.onError = options.onError || InternalState.prototype.onError;
153
+ if ((this.renderPromises || this.client.disableNetworkFetches) &&
154
+ this.queryHookOptions.ssr === false &&
155
+ !this.queryHookOptions.skip) {
156
+ this.result = this.ssrDisabledResult;
157
+ }
158
+ else if (this.queryHookOptions.skip ||
159
+ this.watchQueryOptions.fetchPolicy === 'standby') {
160
+ this.result = this.skipStandbyResult;
161
+ }
162
+ else if (this.result === this.ssrDisabledResult ||
163
+ this.result === this.skipStandbyResult) {
164
+ this.result = void 0;
165
+ }
166
+ };
167
+ InternalState.prototype.getObsQueryOptions = function () {
168
+ var toMerge = [];
169
+ var globalDefaults = this.client.defaultOptions.watchQuery;
170
+ if (globalDefaults)
171
+ toMerge.push(globalDefaults);
172
+ if (this.queryHookOptions.defaultOptions) {
173
+ toMerge.push(this.queryHookOptions.defaultOptions);
174
+ }
175
+ toMerge.push(compact(this.observable && this.observable.options, this.watchQueryOptions));
176
+ return toMerge.reduce(mergeOptions);
177
+ };
178
+ InternalState.prototype.createWatchQueryOptions = function (_a) {
179
+ var _b;
180
+ if (_a === void 0) { _a = {}; }
181
+ var skip = _a.skip, ssr = _a.ssr, onCompleted = _a.onCompleted, onError = _a.onError, defaultOptions = _a.defaultOptions, otherOptions = __rest(_a, ["skip", "ssr", "onCompleted", "onError", "defaultOptions"]);
182
+ var watchQueryOptions = Object.assign(otherOptions, { query: this.query });
183
+ if (this.renderPromises &&
184
+ (watchQueryOptions.fetchPolicy === 'network-only' ||
185
+ watchQueryOptions.fetchPolicy === 'cache-and-network')) {
186
+ watchQueryOptions.fetchPolicy = 'cache-first';
187
+ }
188
+ if (!watchQueryOptions.variables) {
189
+ watchQueryOptions.variables = {};
190
+ }
191
+ if (skip) {
192
+ var _c = watchQueryOptions.fetchPolicy, fetchPolicy = _c === void 0 ? this.getDefaultFetchPolicy() : _c, _d = watchQueryOptions.initialFetchPolicy, initialFetchPolicy = _d === void 0 ? fetchPolicy : _d;
193
+ Object.assign(watchQueryOptions, {
194
+ initialFetchPolicy: initialFetchPolicy,
195
+ fetchPolicy: 'standby',
196
+ });
197
+ }
198
+ else if (!watchQueryOptions.fetchPolicy) {
199
+ watchQueryOptions.fetchPolicy =
200
+ ((_b = this.observable) === null || _b === void 0 ? void 0 : _b.options.initialFetchPolicy) ||
201
+ this.getDefaultFetchPolicy();
202
+ }
203
+ return watchQueryOptions;
204
+ };
205
+ InternalState.prototype.getDefaultFetchPolicy = function () {
206
+ var _a, _b;
207
+ return (((_a = this.queryHookOptions.defaultOptions) === null || _a === void 0 ? void 0 : _a.fetchPolicy) ||
208
+ ((_b = this.client.defaultOptions.watchQuery) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
209
+ "cache-first");
210
+ };
211
+ InternalState.prototype.onCompleted = function (data) { };
212
+ InternalState.prototype.onError = function (error) { };
213
+ InternalState.prototype.useObservableQuery = function () {
214
+ var obsQuery = this.observable =
215
+ this.renderPromises
216
+ && this.renderPromises.getSSRObservable(this.watchQueryOptions)
217
+ || this.observable
218
+ || this.client.watchQuery(this.getObsQueryOptions());
219
+ this.obsQueryFields = useMemo(function () { return ({
220
+ refetch: obsQuery.refetch.bind(obsQuery),
221
+ reobserve: obsQuery.reobserve.bind(obsQuery),
222
+ fetchMore: obsQuery.fetchMore.bind(obsQuery),
223
+ updateQuery: obsQuery.updateQuery.bind(obsQuery),
224
+ startPolling: obsQuery.startPolling.bind(obsQuery),
225
+ stopPolling: obsQuery.stopPolling.bind(obsQuery),
226
+ subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),
227
+ }); }, [obsQuery]);
228
+ var ssrAllowed = !(this.queryHookOptions.ssr === false ||
229
+ this.queryHookOptions.skip);
230
+ if (this.renderPromises && ssrAllowed) {
231
+ this.renderPromises.registerSSRObservable(obsQuery);
232
+ if (obsQuery.getCurrentResult().loading) {
233
+ this.renderPromises.addObservableQueryPromise(obsQuery);
234
+ }
235
+ }
236
+ return obsQuery;
237
+ };
238
+ InternalState.prototype.setResult = function (nextResult) {
239
+ var previousResult = this.result;
240
+ if (previousResult && previousResult.data) {
241
+ this.previousData = previousResult.data;
242
+ }
243
+ this.result = nextResult;
244
+ this.forceUpdate();
245
+ this.handleErrorOrCompleted(nextResult, previousResult);
246
+ };
247
+ InternalState.prototype.handleErrorOrCompleted = function (result, previousResult) {
248
+ var _this = this;
249
+ if (!result.loading) {
250
+ var error_1 = this.toApolloError(result);
251
+ Promise.resolve().then(function () {
252
+ if (error_1) {
253
+ _this.onError(error_1);
254
+ }
255
+ else if (result.data &&
256
+ (previousResult === null || previousResult === void 0 ? void 0 : previousResult.networkStatus) !== result.networkStatus &&
257
+ result.networkStatus === NetworkStatus.ready) {
258
+ _this.onCompleted(result.data);
259
+ }
260
+ }).catch(function (error) {
261
+ __DEV__ && invariant.warn(error);
262
+ });
263
+ }
264
+ };
265
+ InternalState.prototype.toApolloError = function (result) {
266
+ return isNonEmptyArray(result.errors)
267
+ ? new ApolloError({ graphQLErrors: result.errors })
268
+ : result.error;
269
+ };
270
+ InternalState.prototype.getCurrentResult = function () {
271
+ if (!this.result) {
272
+ this.handleErrorOrCompleted(this.result = this.observable.getCurrentResult());
273
+ }
274
+ return this.result;
275
+ };
276
+ InternalState.prototype.toQueryResult = function (result) {
277
+ var queryResult = this.toQueryResultCache.get(result);
278
+ if (queryResult)
279
+ return queryResult;
280
+ var data = result.data, partial = result.partial, resultWithoutPartial = __rest(result, ["data", "partial"]);
281
+ this.toQueryResultCache.set(result, queryResult = __assign(__assign(__assign({ data: data }, resultWithoutPartial), this.obsQueryFields), { client: this.client, observable: this.observable, variables: this.observable.variables, called: !this.queryHookOptions.skip, previousData: this.previousData }));
282
+ if (!queryResult.error && isNonEmptyArray(result.errors)) {
283
+ queryResult.error = new ApolloError({ graphQLErrors: result.errors });
284
+ }
285
+ return queryResult;
286
+ };
287
+ InternalState.prototype.unsafeHandlePartialRefetch = function (result) {
288
+ if (result.partial &&
289
+ this.queryHookOptions.partialRefetch &&
290
+ !result.loading &&
291
+ (!result.data || Object.keys(result.data).length === 0) &&
292
+ this.observable.options.fetchPolicy !== 'cache-only') {
293
+ Object.assign(result, {
294
+ loading: true,
295
+ networkStatus: NetworkStatus.refetch,
296
+ });
297
+ this.observable.refetch();
298
+ }
299
+ };
300
+ return InternalState;
301
+ }());
302
+ //# sourceMappingURL=useQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EACL,WAAW,EACX,UAAU,EACV,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAA6C,MAAM,YAAY,CAAC;AACrF,OAAO,EAAsB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAGL,aAAa,GAKd,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAItG,IAAA,cAAc,GAEd,MAAM,yBAFQ,CAEP;AAEX,MAAM,UAAU,QAAQ,CAItB,KAA0D,EAC1D,OAAkE;IAAlE,wBAAA,EAAA,UAA+C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;IAElE,OAAO,gBAAgB,CACrB,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,EAC/B,KAAK,CACN,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,MAAyB,EACzB,KAA0D;IAE1D,IAAM,QAAQ,GAAG,MAAM,EAAoC,CAAC;IAC5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esContent":["import { invariant } from '../../utilities/globals';\n\nimport {\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useSyncExternalStore } from './useSyncExternalStore';\nimport { equal } from '@wry/equality';\n\nimport { mergeOptions, OperationVariables, WatchQueryFetchPolicy } from '../../core';\nimport { ApolloContextValue, getApolloContext } from '../context';\nimport { ApolloError } from '../../errors';\nimport {\n ApolloClient,\n ApolloQueryResult,\n NetworkStatus,\n ObservableQuery,\n DocumentNode,\n TypedDocumentNode,\n WatchQueryOptions,\n} from '../../core';\nimport {\n QueryHookOptions,\n QueryResult,\n ObservableQueryFields,\n} from '../types/types';\n\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport { useApolloClient } from './useApolloClient';\nimport { canUseWeakMap, canUseWeakSet, compact, isNonEmptyArray, maybeDeepFreeze } from '../../utilities';\n\nconst {\n prototype: {\n hasOwnProperty,\n },\n} = Object;\n\nexport function useQuery<\n TData = any,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: QueryHookOptions<TData, TVariables> = Object.create(null),\n): QueryResult<TData, TVariables> {\n return useInternalState(\n useApolloClient(options.client),\n query,\n ).useQuery(options);\n}\n\nexport function useInternalState<TData, TVariables extends OperationVariables>(\n client: ApolloClient<any>,\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n): InternalState<TData, TVariables> {\n const stateRef = useRef<InternalState<TData, TVariables>>();\n if (\n !stateRef.current ||\n client !== stateRef.current.client ||\n query !== stateRef.current.query\n ) {\n stateRef.current = new InternalState(client, query, stateRef.current);\n }\n const state = stateRef.current;\n\n // By default, InternalState.prototype.forceUpdate is an empty function, but\n // we replace it here (before anyone has had a chance to see this state yet)\n // with a function that unconditionally forces an update, using the latest\n // setTick function. Updating this state by calling state.forceUpdate is the\n // only way we trigger React component updates (no other useState calls within\n // the InternalState class).\n const [_tick, setTick] = useState(0);\n state.forceUpdate = () => {\n setTick(tick => tick + 1);\n };\n\n return state;\n}\n\nclass InternalState<TData, TVariables extends OperationVariables> {\n constructor(\n public readonly client: ReturnType<typeof useApolloClient>,\n public readonly query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n previous?: InternalState<TData, TVariables>,\n ) {\n verifyDocumentType(query, DocumentType.Query);\n\n // Reuse previousData from previous InternalState (if any) to provide\n // continuity of previousData even if/when the query or client changes.\n const previousResult = previous && previous.result;\n const previousData = previousResult && previousResult.data;\n if (previousData) {\n this.previousData = previousData;\n }\n }\n\n forceUpdate() {\n // Replaced (in useInternalState) with a method that triggers an update.\n invariant.warn(\"Calling default no-op implementation of InternalState#forceUpdate\");\n }\n\n asyncUpdate(signal: AbortSignal) {\n return new Promise<QueryResult<TData, TVariables>>((resolve, reject) => {\n const watchQueryOptions = this.watchQueryOptions;\n\n const handleAborted = () => {\n this.asyncResolveFns.delete(resolve)\n this.optionsToIgnoreOnce.delete(watchQueryOptions);\n signal.removeEventListener('abort', handleAborted)\n reject(signal.reason);\n };\n\n this.asyncResolveFns.add(resolve);\n this.optionsToIgnoreOnce.add(watchQueryOptions);\n signal.addEventListener('abort', handleAborted)\n this.forceUpdate();\n });\n }\n\n private asyncResolveFns = new Set<\n (result: QueryResult<TData, TVariables>) => void\n >();\n\n private optionsToIgnoreOnce = new (canUseWeakSet ? WeakSet : Set)<\n WatchQueryOptions<TVariables, TData>\n >();\n\n // Methods beginning with use- should be called according to the standard\n // rules of React hooks: only at the top level of the calling function, and\n // without any dynamic conditional logic.\n useQuery(options: QueryHookOptions<TData, TVariables>) {\n // The renderPromises field gets initialized here in the useQuery method, at\n // the beginning of everything (for a given component rendering, at least),\n // so we can safely use this.renderPromises in other/later InternalState\n // methods without worrying it might be uninitialized. Even after\n // initialization, this.renderPromises is usually undefined (unless SSR is\n // happening), but that's fine as long as it has been initialized that way,\n // rather than left uninitialized.\n this.renderPromises = useContext(getApolloContext()).renderPromises;\n\n this.useOptions(options);\n\n const obsQuery = this.useObservableQuery();\n\n const result = useSyncExternalStore(\n useCallback(() => {\n if (this.renderPromises) {\n return () => {};\n }\n\n const onNext = () => {\n const previousResult = this.result;\n // We use `getCurrentResult()` instead of the onNext argument because\n // the values differ slightly. Specifically, loading results will have\n // an empty object for data instead of `undefined` for some reason.\n const result = obsQuery.getCurrentResult();\n // Make sure we're not attempting to re-render similar results\n if (\n previousResult &&\n previousResult.loading === result.loading &&\n previousResult.networkStatus === result.networkStatus &&\n equal(previousResult.data, result.data)\n ) {\n return;\n }\n\n this.setResult(result);\n };\n\n const onError = (error: Error) => {\n const last = obsQuery[\"last\"];\n subscription.unsubscribe();\n // Unfortunately, if `lastError` is set in the current\n // `observableQuery` when the subscription is re-created,\n // the subscription will immediately receive the error, which will\n // cause it to terminate again. To avoid this, we first clear\n // the last error/result from the `observableQuery` before re-starting\n // the subscription, and restore it afterwards (so the subscription\n // has a chance to stay open).\n try {\n obsQuery.resetLastResults();\n subscription = obsQuery.subscribe(onNext, onError);\n } finally {\n obsQuery[\"last\"] = last;\n }\n\n if (!hasOwnProperty.call(error, 'graphQLErrors')) {\n // The error is not a GraphQL error\n throw error;\n }\n\n const previousResult = this.result;\n if (\n !previousResult ||\n (previousResult && previousResult.loading) ||\n !equal(error, previousResult.error)\n ) {\n this.setResult({\n data: (previousResult && previousResult.data) as TData,\n error: error as ApolloError,\n loading: false,\n networkStatus: NetworkStatus.error,\n });\n }\n };\n\n let subscription = obsQuery.subscribe(onNext, onError);\n\n return () => subscription.unsubscribe();\n }, [\n // We memoize the subscribe function using useCallback and the following\n // dependency keys, because the subscribe function reference is all that\n // useSyncExternalStore uses internally as a dependency key for the\n // useEffect ultimately responsible for the subscription, so we are\n // effectively passing this dependency array to that useEffect buried\n // inside useSyncExternalStore, as desired.\n obsQuery,\n this.renderPromises,\n this.client.disableNetworkFetches,\n ]),\n\n () => this.getCurrentResult(),\n () => this.getCurrentResult(),\n );\n\n // TODO Remove this method when we remove support for options.partialRefetch.\n this.unsafeHandlePartialRefetch(result);\n\n const queryResult = this.toQueryResult(result);\n\n if (!queryResult.loading && this.asyncResolveFns.size) {\n this.asyncResolveFns.forEach(resolve => resolve(queryResult));\n this.asyncResolveFns.clear();\n }\n\n return queryResult;\n }\n\n // These members (except for renderPromises) are all populated by the\n // useOptions method, which is called unconditionally at the beginning of the\n // useQuery method, so we can safely use these members in other/later methods\n // without worrying they might be uninitialized.\n private renderPromises: ApolloContextValue[\"renderPromises\"];\n private queryHookOptions: QueryHookOptions<TData, TVariables>;\n private watchQueryOptions: WatchQueryOptions<TVariables, TData>;\n\n private useOptions(\n options: QueryHookOptions<TData, TVariables>,\n ) {\n const watchQueryOptions = this.createWatchQueryOptions(\n this.queryHookOptions = options,\n );\n\n // Update this.watchQueryOptions, but only when they have changed, which\n // allows us to depend on the referential stability of\n // this.watchQueryOptions elsewhere.\n const currentWatchQueryOptions = this.watchQueryOptions;\n\n // To force this equality test to \"fail,\" thereby reliably triggering\n // observable.reobserve, add any current WatchQueryOptions object(s) you\n // want to be ignored to this.optionsToIgnoreOnce. A similar effect could be\n // achieved by nullifying this.watchQueryOptions so the equality test\n // immediately fails because currentWatchQueryOptions is null, but this way\n // we can promise a truthy this.watchQueryOptions at all times.\n if (\n this.optionsToIgnoreOnce.has(currentWatchQueryOptions) ||\n !equal(watchQueryOptions, currentWatchQueryOptions)\n ) {\n this.watchQueryOptions = watchQueryOptions;\n\n if (currentWatchQueryOptions && this.observable) {\n // As advertised in the -Once of this.optionsToIgnoreOnce, this trick is\n // only good for one forced execution of observable.reobserve per\n // ignored WatchQueryOptions object, though it is unlikely we will ever\n // see this exact currentWatchQueryOptions object again here, since we\n // just replaced this.watchQueryOptions with watchQueryOptions.\n this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);\n\n // Though it might be tempting to postpone this reobserve call to the\n // useEffect block, we need getCurrentResult to return an appropriate\n // loading:true result synchronously (later within the same call to\n // useQuery). Since we already have this.observable here (not true for\n // the very first call to useQuery), we are not initiating any new\n // subscriptions, though it does feel less than ideal that reobserve\n // (potentially) kicks off a network request (for example, when the\n // variables have changed), which is technically a side-effect.\n this.observable.reobserve(this.getObsQueryOptions());\n\n // Make sure getCurrentResult returns a fresh ApolloQueryResult<TData>,\n // but save the current data as this.previousData, just like setResult\n // usually does.\n this.previousData = this.result?.data || this.previousData;\n this.result = void 0;\n }\n }\n\n // Make sure state.onCompleted and state.onError always reflect the latest\n // options.onCompleted and options.onError callbacks provided to useQuery,\n // since those functions are often recreated every time useQuery is called.\n // Like the forceUpdate method, the versions of these methods inherited from\n // InternalState.prototype are empty no-ops, but we can override them on the\n // base state object (without modifying the prototype).\n this.onCompleted = options.onCompleted || InternalState.prototype.onCompleted;\n this.onError = options.onError || InternalState.prototype.onError;\n\n if (\n (this.renderPromises || this.client.disableNetworkFetches) &&\n this.queryHookOptions.ssr === false &&\n !this.queryHookOptions.skip\n ) {\n // If SSR has been explicitly disabled, and this function has been called\n // on the server side, return the default loading state.\n this.result = this.ssrDisabledResult;\n } else if (\n this.queryHookOptions.skip ||\n this.watchQueryOptions.fetchPolicy === 'standby'\n ) {\n // When skipping a query (ie. we're not querying for data but still want to\n // render children), make sure the `data` is cleared out and `loading` is\n // set to `false` (since we aren't loading anything).\n //\n // NOTE: We no longer think this is the correct behavior. Skipping should\n // not automatically set `data` to `undefined`, but instead leave the\n // previous data in place. In other words, skipping should not mandate that\n // previously received data is all of a sudden removed. Unfortunately,\n // changing this is breaking, so we'll have to wait until Apollo Client 4.0\n // to address this.\n this.result = this.skipStandbyResult;\n } else if (\n this.result === this.ssrDisabledResult ||\n this.result === this.skipStandbyResult\n ) {\n this.result = void 0;\n }\n }\n\n private getObsQueryOptions(): WatchQueryOptions<TVariables, TData> {\n const toMerge: Array<\n Partial<WatchQueryOptions<TVariables, TData>>\n > = [];\n\n const globalDefaults = this.client.defaultOptions.watchQuery;\n if (globalDefaults) toMerge.push(globalDefaults);\n\n if (this.queryHookOptions.defaultOptions) {\n toMerge.push(this.queryHookOptions.defaultOptions);\n }\n\n // We use compact rather than mergeOptions for this part of the merge,\n // because we want watchQueryOptions.variables (if defined) to replace\n // this.observable.options.variables whole. This replacement allows\n // removing variables by removing them from the variables input to\n // useQuery. If the variables were always merged together (rather than\n // replaced), there would be no way to remove existing variables.\n // However, the variables from options.defaultOptions and globalDefaults\n // (if provided) should be merged, to ensure individual defaulted\n // variables always have values, if not otherwise defined in\n // observable.options or watchQueryOptions.\n toMerge.push(compact(\n this.observable && this.observable.options,\n this.watchQueryOptions,\n ));\n\n return toMerge.reduce(\n mergeOptions\n ) as WatchQueryOptions<TVariables, TData>;\n }\n\n private ssrDisabledResult = maybeDeepFreeze({\n loading: true,\n data: void 0 as unknown as TData,\n error: void 0,\n networkStatus: NetworkStatus.loading,\n });\n\n private skipStandbyResult = maybeDeepFreeze({\n loading: false,\n data: void 0 as unknown as TData,\n error: void 0,\n networkStatus: NetworkStatus.ready,\n });\n\n // A function to massage options before passing them to ObservableQuery.\n private createWatchQueryOptions({\n skip,\n ssr,\n onCompleted,\n onError,\n defaultOptions,\n // The above options are useQuery-specific, so this ...otherOptions spread\n // makes otherOptions almost a WatchQueryOptions object, except for the\n // query property that we add below.\n ...otherOptions\n }: QueryHookOptions<TData, TVariables> = {}): WatchQueryOptions<TVariables, TData> {\n // This Object.assign is safe because otherOptions is a fresh ...rest object\n // that did not exist until just now, so modifications are still allowed.\n const watchQueryOptions: WatchQueryOptions<TVariables, TData> =\n Object.assign(otherOptions, { query: this.query });\n\n if (\n this.renderPromises &&\n (\n watchQueryOptions.fetchPolicy === 'network-only' ||\n watchQueryOptions.fetchPolicy === 'cache-and-network'\n )\n ) {\n // this behavior was added to react-apollo without explanation in this PR\n // https://github.com/apollographql/react-apollo/pull/1579\n watchQueryOptions.fetchPolicy = 'cache-first';\n }\n\n if (!watchQueryOptions.variables) {\n watchQueryOptions.variables = {} as TVariables;\n }\n\n if (skip) {\n const {\n fetchPolicy = this.getDefaultFetchPolicy(),\n initialFetchPolicy = fetchPolicy,\n } = watchQueryOptions;\n\n // When skipping, we set watchQueryOptions.fetchPolicy initially to\n // \"standby\", but we also need/want to preserve the initial non-standby\n // fetchPolicy that would have been used if not skipping.\n Object.assign(watchQueryOptions, {\n initialFetchPolicy,\n fetchPolicy: 'standby',\n });\n } else if (!watchQueryOptions.fetchPolicy) {\n watchQueryOptions.fetchPolicy =\n this.observable?.options.initialFetchPolicy ||\n this.getDefaultFetchPolicy();\n }\n\n return watchQueryOptions;\n }\n\n getDefaultFetchPolicy(): WatchQueryFetchPolicy {\n return (\n this.queryHookOptions.defaultOptions?.fetchPolicy ||\n this.client.defaultOptions.watchQuery?.fetchPolicy ||\n \"cache-first\"\n );\n }\n\n // Defining these methods as no-ops on the prototype allows us to call\n // state.onCompleted and/or state.onError without worrying about whether a\n // callback was provided.\n private onCompleted(data: TData) {}\n private onError(error: ApolloError) {}\n\n private observable: ObservableQuery<TData, TVariables>;\n private obsQueryFields: Omit<\n ObservableQueryFields<TData, TVariables>,\n \"variables\"\n >;\n\n private useObservableQuery() {\n // See if there is an existing observable that was used to fetch the same\n // data and if so, use it instead since it will contain the proper queryId\n // to fetch the result set. This is used during SSR.\n const obsQuery = this.observable =\n this.renderPromises\n && this.renderPromises.getSSRObservable(this.watchQueryOptions)\n || this.observable // Reuse this.observable if possible (and not SSR)\n || this.client.watchQuery(this.getObsQueryOptions());\n\n this.obsQueryFields = useMemo(() => ({\n refetch: obsQuery.refetch.bind(obsQuery),\n reobserve: obsQuery.reobserve.bind(obsQuery),\n fetchMore: obsQuery.fetchMore.bind(obsQuery),\n updateQuery: obsQuery.updateQuery.bind(obsQuery),\n startPolling: obsQuery.startPolling.bind(obsQuery),\n stopPolling: obsQuery.stopPolling.bind(obsQuery),\n subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),\n }), [obsQuery]);\n\n const ssrAllowed = !(\n this.queryHookOptions.ssr === false ||\n this.queryHookOptions.skip\n );\n\n if (this.renderPromises && ssrAllowed) {\n this.renderPromises.registerSSRObservable(obsQuery);\n\n if (obsQuery.getCurrentResult().loading) {\n // TODO: This is a legacy API which could probably be cleaned up\n this.renderPromises.addObservableQueryPromise(obsQuery);\n }\n }\n\n return obsQuery;\n }\n\n // These members are populated by getCurrentResult and setResult, and it's\n // okay/normal for them to be initially undefined.\n private result: undefined | ApolloQueryResult<TData>;\n private previousData: undefined | TData;\n\n private setResult(nextResult: ApolloQueryResult<TData>) {\n const previousResult = this.result;\n if (previousResult && previousResult.data) {\n this.previousData = previousResult.data;\n }\n this.result = nextResult;\n // Calling state.setResult always triggers an update, though some call sites\n // perform additional equality checks before committing to an update.\n this.forceUpdate();\n this.handleErrorOrCompleted(nextResult, previousResult);\n }\n\n private handleErrorOrCompleted(\n result: ApolloQueryResult<TData>,\n previousResult?: ApolloQueryResult<TData>\n ) {\n if (!result.loading) {\n const error = this.toApolloError(result);\n\n // wait a tick in case we are in the middle of rendering a component\n Promise.resolve().then(() => {\n if (error) {\n this.onError(error);\n } else if (\n result.data &&\n previousResult?.networkStatus !== result.networkStatus &&\n result.networkStatus === NetworkStatus.ready\n ) {\n this.onCompleted(result.data);\n }\n }).catch(error => {\n invariant.warn(error);\n });\n }\n }\n\n private toApolloError(result: ApolloQueryResult<TData>): ApolloError | undefined {\n return isNonEmptyArray(result.errors)\n ? new ApolloError({ graphQLErrors: result.errors })\n : result.error\n }\n\n private getCurrentResult(): ApolloQueryResult<TData> {\n // Using this.result as a cache ensures getCurrentResult continues returning\n // the same (===) result object, unless state.setResult has been called, or\n // we're doing server rendering and therefore override the result below.\n if (!this.result) {\n this.handleErrorOrCompleted(\n this.result = this.observable.getCurrentResult()\n );\n }\n return this.result;\n }\n\n // This cache allows the referential stability of this.result (as returned by\n // getCurrentResult) to translate into referential stability of the resulting\n // QueryResult object returned by toQueryResult.\n private toQueryResultCache = new (canUseWeakMap ? WeakMap : Map)<\n ApolloQueryResult<TData>,\n QueryResult<TData, TVariables>\n >();\n\n toQueryResult(\n result: ApolloQueryResult<TData>,\n ): QueryResult<TData, TVariables> {\n let queryResult = this.toQueryResultCache.get(result);\n if (queryResult) return queryResult;\n\n const { data, partial, ...resultWithoutPartial } = result;\n this.toQueryResultCache.set(result, queryResult = {\n data, // Ensure always defined, even if result.data is missing.\n ...resultWithoutPartial,\n ...this.obsQueryFields,\n client: this.client,\n observable: this.observable,\n variables: this.observable.variables,\n called: !this.queryHookOptions.skip,\n previousData: this.previousData,\n });\n\n if (!queryResult.error && isNonEmptyArray(result.errors)) {\n // Until a set naming convention for networkError and graphQLErrors is\n // decided upon, we map errors (graphQLErrors) to the error options.\n // TODO: Is it possible for both result.error and result.errors to be\n // defined here?\n queryResult.error = new ApolloError({ graphQLErrors: result.errors });\n }\n\n return queryResult;\n }\n\n private unsafeHandlePartialRefetch(result: ApolloQueryResult<TData>) {\n // WARNING: SIDE-EFFECTS IN THE RENDER FUNCTION\n //\n // TODO: This code should be removed when the partialRefetch option is\n // removed. I was unable to get this hook to behave reasonably in certain\n // edge cases when this block was put in an effect.\n if (\n result.partial &&\n this.queryHookOptions.partialRefetch &&\n !result.loading &&\n (!result.data || Object.keys(result.data).length === 0) &&\n this.observable.options.fetchPolicy !== 'cache-only'\n ) {\n Object.assign(result, {\n loading: true,\n networkStatus: NetworkStatus.refetch,\n });\n this.observable.refetch();\n }\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { ReactiveVar } from '../../core';
2
+ export declare function useReactiveVar<T>(rv: ReactiveVar<T>): T;
3
+ //# sourceMappingURL=useReactiveVar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReactiveVar.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useReactiveVar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAAgB,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAsBvD"}
@@ -0,0 +1,16 @@
1
+ import { useEffect, useState } from 'react';
2
+ export function useReactiveVar(rv) {
3
+ var value = rv();
4
+ var setValue = useState(value)[1];
5
+ useEffect(function () {
6
+ var probablySameValue = rv();
7
+ if (value !== probablySameValue) {
8
+ setValue(probablySameValue);
9
+ }
10
+ else {
11
+ return rv.onNextChange(setValue);
12
+ }
13
+ }, [value]);
14
+ return value;
15
+ }
16
+ //# sourceMappingURL=useReactiveVar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReactiveVar.js","sourceRoot":"","sources":["../../../src/react/hooks/useReactiveVar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG5C,MAAM,UAAU,cAAc,CAAI,EAAkB;IAClD,IAAM,KAAK,GAAG,EAAE,EAAE,CAAC;IAInB,IAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAKpC,SAAS,CAAC;QACR,IAAM,iBAAiB,GAAG,EAAE,EAAE,CAAC;QAC/B,IAAI,KAAK,KAAK,iBAAiB,EAAE;YAG/B,QAAQ,CAAC,iBAAiB,CAAC,CAAC;SAC7B;aAAM;YACL,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;SAClC;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport { ReactiveVar } from '../../core';\n\nexport function useReactiveVar<T>(rv: ReactiveVar<T>): T {\n const value = rv();\n\n // We don't actually care what useState thinks the value of the variable\n // is, so we take only the update function from the returned array.\n const setValue = useState(value)[1];\n\n // We subscribe to variable updates on initial mount and when the value has\n // changed. This avoids a subtle bug in React.StrictMode where multiple\n // listeners are added, leading to inconsistent updates.\n useEffect(() => {\n const probablySameValue = rv();\n if (value !== probablySameValue) {\n // If the value of rv has already changed, we don't need to listen for the\n // next change, because we can report this change immediately.\n setValue(probablySameValue);\n } else {\n return rv.onNextChange(setValue);\n }\n }, [value]);\n\n return value;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { DocumentNode } from 'graphql';
2
+ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
+ import { SubscriptionHookOptions, SubscriptionResult } from '../types/types';
4
+ import { OperationVariables } from '../../core';
5
+ export declare function useSubscription<TData = any, TVariables extends OperationVariables = OperationVariables>(subscription: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SubscriptionHookOptions<TData, TVariables>): SubscriptionResult<TData, any>;
6
+ //# sourceMappingURL=useSubscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSubscription.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useSubscription.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAItE,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGhD,wBAAgB,eAAe,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,EACrG,YAAY,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EACjE,OAAO,CAAC,EAAE,uBAAuB,CAAC,KAAK,EAAE,UAAU,CAAC,kCAsJrD"}
@@ -0,0 +1,141 @@
1
+ import { invariant, __DEV__ } from "../../utilities/globals/index.js";
2
+ import { useState, useRef, useEffect } from 'react';
3
+ import { equal } from '@wry/equality';
4
+ import { DocumentType, verifyDocumentType } from "../parser/index.js";
5
+ import { useApolloClient } from "./useApolloClient.js";
6
+ export function useSubscription(subscription, options) {
7
+ var hasIssuedDeprecationWarningRef = useRef(false);
8
+ var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
9
+ verifyDocumentType(subscription, DocumentType.Subscription);
10
+ var _a = useState({
11
+ loading: !(options === null || options === void 0 ? void 0 : options.skip),
12
+ error: void 0,
13
+ data: void 0,
14
+ variables: options === null || options === void 0 ? void 0 : options.variables,
15
+ }), result = _a[0], setResult = _a[1];
16
+ if (!hasIssuedDeprecationWarningRef.current) {
17
+ hasIssuedDeprecationWarningRef.current = true;
18
+ if (options === null || options === void 0 ? void 0 : options.onSubscriptionData) {
19
+ __DEV__ && invariant.warn(options.onData
20
+ ? "'useSubscription' supports only the 'onSubscriptionData' or 'onData' option, but not both. Only the 'onData' option will be used."
21
+ : "'onSubscriptionData' is deprecated and will be removed in a future major version. Please use the 'onData' option instead.");
22
+ }
23
+ if (options === null || options === void 0 ? void 0 : options.onSubscriptionComplete) {
24
+ __DEV__ && invariant.warn(options.onComplete
25
+ ? "'useSubscription' supports only the 'onSubscriptionComplete' or 'onComplete' option, but not both. Only the 'onComplete' option will be used."
26
+ : "'onSubscriptionComplete' is deprecated and will be removed in a future major version. Please use the 'onComplete' option instead.");
27
+ }
28
+ }
29
+ var _b = useState(function () {
30
+ if (options === null || options === void 0 ? void 0 : options.skip) {
31
+ return null;
32
+ }
33
+ return client.subscribe({
34
+ query: subscription,
35
+ variables: options === null || options === void 0 ? void 0 : options.variables,
36
+ fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
37
+ context: options === null || options === void 0 ? void 0 : options.context,
38
+ });
39
+ }), observable = _b[0], setObservable = _b[1];
40
+ var canResetObservableRef = useRef(false);
41
+ useEffect(function () {
42
+ return function () {
43
+ canResetObservableRef.current = true;
44
+ };
45
+ }, []);
46
+ var ref = useRef({ client: client, subscription: subscription, options: options });
47
+ useEffect(function () {
48
+ var _a, _b, _c, _d;
49
+ var shouldResubscribe = options === null || options === void 0 ? void 0 : options.shouldResubscribe;
50
+ if (typeof shouldResubscribe === 'function') {
51
+ shouldResubscribe = !!shouldResubscribe(options);
52
+ }
53
+ if (options === null || options === void 0 ? void 0 : options.skip) {
54
+ if (!(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip) || canResetObservableRef.current) {
55
+ setResult({
56
+ loading: false,
57
+ data: void 0,
58
+ error: void 0,
59
+ variables: options === null || options === void 0 ? void 0 : options.variables,
60
+ });
61
+ setObservable(null);
62
+ canResetObservableRef.current = false;
63
+ }
64
+ }
65
+ else if ((shouldResubscribe !== false &&
66
+ (client !== ref.current.client ||
67
+ subscription !== ref.current.subscription ||
68
+ (options === null || options === void 0 ? void 0 : options.fetchPolicy) !== ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
69
+ !(options === null || options === void 0 ? void 0 : options.skip) !== !((_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.skip) ||
70
+ !equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) ||
71
+ canResetObservableRef.current) {
72
+ setResult({
73
+ loading: true,
74
+ data: void 0,
75
+ error: void 0,
76
+ variables: options === null || options === void 0 ? void 0 : options.variables,
77
+ });
78
+ setObservable(client.subscribe({
79
+ query: subscription,
80
+ variables: options === null || options === void 0 ? void 0 : options.variables,
81
+ fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
82
+ context: options === null || options === void 0 ? void 0 : options.context,
83
+ }));
84
+ canResetObservableRef.current = false;
85
+ }
86
+ Object.assign(ref.current, { client: client, subscription: subscription, options: options });
87
+ }, [client, subscription, options, canResetObservableRef.current]);
88
+ useEffect(function () {
89
+ if (!observable) {
90
+ return;
91
+ }
92
+ var subscription = observable.subscribe({
93
+ next: function (fetchResult) {
94
+ var _a, _b;
95
+ var result = {
96
+ loading: false,
97
+ data: fetchResult.data,
98
+ error: void 0,
99
+ variables: options === null || options === void 0 ? void 0 : options.variables,
100
+ };
101
+ setResult(result);
102
+ if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onData) {
103
+ ref.current.options.onData({
104
+ client: client,
105
+ data: result
106
+ });
107
+ }
108
+ else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionData) {
109
+ ref.current.options.onSubscriptionData({
110
+ client: client,
111
+ subscriptionData: result
112
+ });
113
+ }
114
+ },
115
+ error: function (error) {
116
+ var _a, _b;
117
+ setResult({
118
+ loading: false,
119
+ data: void 0,
120
+ error: error,
121
+ variables: options === null || options === void 0 ? void 0 : options.variables,
122
+ });
123
+ (_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
124
+ },
125
+ complete: function () {
126
+ var _a, _b;
127
+ if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onComplete) {
128
+ ref.current.options.onComplete();
129
+ }
130
+ else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionComplete) {
131
+ ref.current.options.onSubscriptionComplete();
132
+ }
133
+ },
134
+ });
135
+ return function () {
136
+ subscription.unsubscribe();
137
+ };
138
+ }, [observable]);
139
+ return result;
140
+ }
141
+ //# sourceMappingURL=useSubscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSubscription.js","sourceRoot":"","sources":["../../../src/react/hooks/useSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGpD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAM7D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,UAAU,eAAe,CAC7B,YAAiE,EACjE,OAAoD;IAEpD,IAAM,8BAA8B,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACrD,IAAM,MAAM,GAAG,eAAe,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAC,CAAC;IAChD,kBAAkB,CAAC,YA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E,CAAC;iBAC9C;YACH,CAAC;SACF,CAAC,CAAC;QAEH,OAAO;YACL,YAAY,CAAC,WAAW,EAAE,CAAC;QAC7B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals';\nimport { useState, useRef, useEffect } from 'react';\nimport { DocumentNode } from 'graphql';\nimport { TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport { equal } from '@wry/equality';\n\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport {\n SubscriptionHookOptions,\n SubscriptionResult\n} from '../types/types';\nimport { OperationVariables } from '../../core';\nimport { useApolloClient } from './useApolloClient';\n\nexport function useSubscription<TData = any, TVariables extends OperationVariables = OperationVariables>(\n subscription: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SubscriptionHookOptions<TData, TVariables>,\n) {\n const hasIssuedDeprecationWarningRef = useRef(false);\n const client = useApolloClient(options?.client);\n verifyDocumentType(subscription, DocumentType.Subscription);\n const [result, setResult] = useState<SubscriptionResult<TData>>({\n loading: !options?.skip,\n error: void 0,\n data: void 0,\n variables: options?.variables,\n });\n\n if (!hasIssuedDeprecationWarningRef.current) {\n hasIssuedDeprecationWarningRef.current = true;\n\n if (options?.onSubscriptionData) {\n invariant.warn(\n options.onData\n ? \"'useSubscription' supports only the 'onSubscriptionData' or 'onData' option, but not both. Only the 'onData' option will be used.\"\n : \"'onSubscriptionData' is deprecated and will be removed in a future major version. Please use the 'onData' option instead.\"\n );\n }\n\n if (options?.onSubscriptionComplete) {\n invariant.warn(\n options.onComplete\n ? \"'useSubscription' supports only the 'onSubscriptionComplete' or 'onComplete' option, but not both. Only the 'onComplete' option will be used.\"\n : \"'onSubscriptionComplete' is deprecated and will be removed in a future major version. Please use the 'onComplete' option instead.\"\n );\n }\n }\n\n const [observable, setObservable] = useState(() => {\n if (options?.skip) {\n return null;\n }\n\n return client.subscribe({\n query: subscription,\n variables: options?.variables,\n fetchPolicy: options?.fetchPolicy,\n context: options?.context,\n });\n });\n\n const canResetObservableRef = useRef(false);\n useEffect(() => {\n return () => {\n canResetObservableRef.current = true;\n };\n }, []);\n\n const ref = useRef({ client, subscription, options });\n useEffect(() => {\n let shouldResubscribe = options?.shouldResubscribe;\n if (typeof shouldResubscribe === 'function') {\n shouldResubscribe = !!shouldResubscribe(options!);\n }\n\n if (options?.skip) {\n if (!options?.skip !== !ref.current.options?.skip || canResetObservableRef.current) {\n setResult({\n loading: false,\n data: void 0,\n error: void 0,\n variables: options?.variables,\n });\n setObservable(null);\n canResetObservableRef.current = false;\n }\n } else if (\n (shouldResubscribe !== false &&\n (client !== ref.current.client ||\n subscription !== ref.current.subscription ||\n options?.fetchPolicy !== ref.current.options?.fetchPolicy ||\n !options?.skip !== !ref.current.options?.skip ||\n !equal(options?.variables, ref.current.options?.variables))) ||\n canResetObservableRef.current\n ) {\n setResult({\n loading: true,\n data: void 0,\n error: void 0,\n variables: options?.variables,\n });\n setObservable(client.subscribe({\n query: subscription,\n variables: options?.variables,\n fetchPolicy: options?.fetchPolicy,\n context: options?.context,\n }));\n canResetObservableRef.current = false;\n }\n\n Object.assign(ref.current, { client, subscription, options });\n }, [client, subscription, options, canResetObservableRef.current]);\n\n useEffect(() => {\n if (!observable) {\n return;\n }\n\n const subscription = observable.subscribe({\n next(fetchResult) {\n const result = {\n loading: false,\n // TODO: fetchResult.data can be null but SubscriptionResult.data\n // expects TData | undefined only\n data: fetchResult.data!,\n error: void 0,\n variables: options?.variables,\n };\n setResult(result);\n\n if (ref.current.options?.onData) {\n ref.current.options.onData({\n client,\n data: result\n });\n } else if (ref.current.options?.onSubscriptionData) {\n ref.current.options.onSubscriptionData({\n client,\n subscriptionData: result\n });\n }\n },\n error(error) {\n setResult({\n loading: false,\n data: void 0,\n error,\n variables: options?.variables,\n });\n ref.current.options?.onError?.(error);\n },\n complete() {\n if (ref.current.options?.onComplete) {\n ref.current.options.onComplete();\n } else if (ref.current.options?.onSubscriptionComplete) {\n ref.current.options.onSubscriptionComplete();\n }\n },\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [observable]);\n\n return result;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function useSuspenseCache(): import("..").SuspenseCache;
2
+ //# sourceMappingURL=useSuspenseCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSuspenseCache.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseCache.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,+BAU/B"}
@@ -0,0 +1,10 @@
1
+ import { useContext } from 'react';
2
+ import { getApolloContext } from "../context/index.js";
3
+ import { invariant, __DEV__ } from "../../utilities/globals/index.js";
4
+ export function useSuspenseCache() {
5
+ var suspenseCache = useContext(getApolloContext()).suspenseCache;
6
+ __DEV__ ? invariant(suspenseCache, 'Could not find a "suspenseCache" in the context. Wrap the root component ' +
7
+ 'in an <ApolloProvider> and provide a suspenseCache.') : invariant(suspenseCache, 33);
8
+ return suspenseCache;
9
+ }
10
+ //# sourceMappingURL=useSuspenseCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSuspenseCache.js","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,UAAU,gBAAgB;IACtB,IAAA,aAAa,GAAK,UAAU,CAAC,gBAAgB,EAAE,CAAC,cAAnC,CAAoC;IAEzD,SAAS,CACP,aAAa,EACb,2EAA2E;QACzE,qDAAqD,CACxD,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { useContext } from 'react';\nimport { getApolloContext } from '../context';\nimport { invariant } from '../../utilities/globals';\n\nexport function useSuspenseCache() {\n const { suspenseCache } = useContext(getApolloContext());\n\n invariant(\n suspenseCache,\n 'Could not find a \"suspenseCache\" in the context. Wrap the root component ' +\n 'in an <ApolloProvider> and provide a suspenseCache.'\n );\n\n return suspenseCache;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { ApolloClient, ApolloError, DocumentNode, OperationVariables, TypedDocumentNode } from '../../core';
2
+ import { SuspenseQueryHookOptions, ObservableQueryFields } from '../types/types';
3
+ export interface UseSuspenseQueryResult<TData = any, TVariables extends OperationVariables = OperationVariables> {
4
+ client: ApolloClient<any>;
5
+ data: TData;
6
+ error: ApolloError | undefined;
7
+ fetchMore: ObservableQueryFields<TData, TVariables>['fetchMore'];
8
+ refetch: ObservableQueryFields<TData, TVariables>['refetch'];
9
+ subscribeToMore: ObservableQueryFields<TData, TVariables>['subscribeToMore'];
10
+ }
11
+ export declare function useSuspenseQuery_experimental<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SuspenseQueryHookOptions<TData, TVariables>): UseSuspenseQueryResult<TData, TVariables>;
12
+ //# sourceMappingURL=useSuspenseQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSuspenseQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseQuery.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,WAAW,EAEX,YAAY,EAEZ,kBAAkB,EAClB,iBAAiB,EAGlB,MAAM,YAAY,CAAC;AASpB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,sBAAsB,CACrC,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,kBAAkB,GAAG,kBAAkB;IAE1D,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,SAAS,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACjE,OAAO,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC;IAC7D,eAAe,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,iBAAiB,CAAC,CAAC;CAC9E;AAaD,wBAAgB,6BAA6B,CAC3C,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,EAE1D,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC1D,OAAO,GAAE,wBAAwB,CAAC,KAAK,EAAE,UAAU,CAAuB,GACzE,sBAAsB,CAAC,KAAK,EAAE,UAAU,CAAC,CAoH3C"}