@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,913 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var globals = require('../../utilities/globals');
6
+ var React = require('react');
7
+ var context = require('../context');
8
+ var tslib = require('tslib');
9
+ var utilities = require('../../utilities');
10
+ var equality = require('@wry/equality');
11
+ var core = require('../../core');
12
+ var errors = require('../../errors');
13
+ var parser = require('../parser');
14
+
15
+ function _interopNamespace(e) {
16
+ if (e && e.__esModule) return e;
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ for (var k in e) {
20
+ n[k] = e[k];
21
+ }
22
+ }
23
+ n["default"] = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
+
29
+ function useApolloClient(override) {
30
+ var context$1 = React.useContext(context.getApolloContext());
31
+ var client = override || context$1.client;
32
+ globals.__DEV__ ? globals.invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
33
+ 'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +
34
+ 'instance in via options.') : globals.invariant(!!client, 32);
35
+ return client;
36
+ }
37
+
38
+ var didWarnUncachedGetSnapshot = false;
39
+ var uSESKey = "useSyncExternalStore";
40
+ var realHook = React__namespace[uSESKey];
41
+ var useSyncExternalStore = realHook || (function (subscribe, getSnapshot, getServerSnapshot) {
42
+ var value = getSnapshot();
43
+ if (globals.__DEV__ &&
44
+ !didWarnUncachedGetSnapshot &&
45
+ value !== getSnapshot()) {
46
+ didWarnUncachedGetSnapshot = true;
47
+ globals.__DEV__ && globals.invariant.error('The result of getSnapshot should be cached to avoid an infinite loop');
48
+ }
49
+ var _a = React__namespace.useState({ inst: { value: value, getSnapshot: getSnapshot } }), inst = _a[0].inst, forceUpdate = _a[1];
50
+ if (utilities.canUseLayoutEffect) {
51
+ React__namespace.useLayoutEffect(function () {
52
+ Object.assign(inst, { value: value, getSnapshot: getSnapshot });
53
+ if (checkIfSnapshotChanged(inst)) {
54
+ forceUpdate({ inst: inst });
55
+ }
56
+ }, [subscribe, value, getSnapshot]);
57
+ }
58
+ else {
59
+ Object.assign(inst, { value: value, getSnapshot: getSnapshot });
60
+ }
61
+ React__namespace.useEffect(function () {
62
+ if (checkIfSnapshotChanged(inst)) {
63
+ forceUpdate({ inst: inst });
64
+ }
65
+ return subscribe(function handleStoreChange() {
66
+ if (checkIfSnapshotChanged(inst)) {
67
+ forceUpdate({ inst: inst });
68
+ }
69
+ });
70
+ }, [subscribe]);
71
+ return value;
72
+ });
73
+ function checkIfSnapshotChanged(_a) {
74
+ var value = _a.value, getSnapshot = _a.getSnapshot;
75
+ try {
76
+ return value !== getSnapshot();
77
+ }
78
+ catch (_b) {
79
+ return true;
80
+ }
81
+ }
82
+
83
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
84
+ function useQuery(query, options) {
85
+ if (options === void 0) { options = Object.create(null); }
86
+ return useInternalState(useApolloClient(options.client), query).useQuery(options);
87
+ }
88
+ function useInternalState(client, query) {
89
+ var stateRef = React.useRef();
90
+ if (!stateRef.current ||
91
+ client !== stateRef.current.client ||
92
+ query !== stateRef.current.query) {
93
+ stateRef.current = new InternalState(client, query, stateRef.current);
94
+ }
95
+ var state = stateRef.current;
96
+ var _a = React.useState(0); _a[0]; var setTick = _a[1];
97
+ state.forceUpdate = function () {
98
+ setTick(function (tick) { return tick + 1; });
99
+ };
100
+ return state;
101
+ }
102
+ var InternalState = (function () {
103
+ function InternalState(client, query, previous) {
104
+ this.client = client;
105
+ this.query = query;
106
+ this.asyncResolveFns = new Set();
107
+ this.optionsToIgnoreOnce = new (utilities.canUseWeakSet ? WeakSet : Set)();
108
+ this.ssrDisabledResult = utilities.maybeDeepFreeze({
109
+ loading: true,
110
+ data: void 0,
111
+ error: void 0,
112
+ networkStatus: core.NetworkStatus.loading,
113
+ });
114
+ this.skipStandbyResult = utilities.maybeDeepFreeze({
115
+ loading: false,
116
+ data: void 0,
117
+ error: void 0,
118
+ networkStatus: core.NetworkStatus.ready,
119
+ });
120
+ this.toQueryResultCache = new (utilities.canUseWeakMap ? WeakMap : Map)();
121
+ parser.verifyDocumentType(query, parser.DocumentType.Query);
122
+ var previousResult = previous && previous.result;
123
+ var previousData = previousResult && previousResult.data;
124
+ if (previousData) {
125
+ this.previousData = previousData;
126
+ }
127
+ }
128
+ InternalState.prototype.forceUpdate = function () {
129
+ globals.__DEV__ && globals.invariant.warn("Calling default no-op implementation of InternalState#forceUpdate");
130
+ };
131
+ InternalState.prototype.asyncUpdate = function (signal) {
132
+ var _this = this;
133
+ return new Promise(function (resolve, reject) {
134
+ var watchQueryOptions = _this.watchQueryOptions;
135
+ var handleAborted = function () {
136
+ _this.asyncResolveFns.delete(resolve);
137
+ _this.optionsToIgnoreOnce.delete(watchQueryOptions);
138
+ signal.removeEventListener('abort', handleAborted);
139
+ reject(signal.reason);
140
+ };
141
+ _this.asyncResolveFns.add(resolve);
142
+ _this.optionsToIgnoreOnce.add(watchQueryOptions);
143
+ signal.addEventListener('abort', handleAborted);
144
+ _this.forceUpdate();
145
+ });
146
+ };
147
+ InternalState.prototype.useQuery = function (options) {
148
+ var _this = this;
149
+ this.renderPromises = React.useContext(context.getApolloContext()).renderPromises;
150
+ this.useOptions(options);
151
+ var obsQuery = this.useObservableQuery();
152
+ var result = useSyncExternalStore(React.useCallback(function () {
153
+ if (_this.renderPromises) {
154
+ return function () { };
155
+ }
156
+ var onNext = function () {
157
+ var previousResult = _this.result;
158
+ var result = obsQuery.getCurrentResult();
159
+ if (previousResult &&
160
+ previousResult.loading === result.loading &&
161
+ previousResult.networkStatus === result.networkStatus &&
162
+ equality.equal(previousResult.data, result.data)) {
163
+ return;
164
+ }
165
+ _this.setResult(result);
166
+ };
167
+ var onError = function (error) {
168
+ var last = obsQuery["last"];
169
+ subscription.unsubscribe();
170
+ try {
171
+ obsQuery.resetLastResults();
172
+ subscription = obsQuery.subscribe(onNext, onError);
173
+ }
174
+ finally {
175
+ obsQuery["last"] = last;
176
+ }
177
+ if (!hasOwnProperty.call(error, 'graphQLErrors')) {
178
+ throw error;
179
+ }
180
+ var previousResult = _this.result;
181
+ if (!previousResult ||
182
+ (previousResult && previousResult.loading) ||
183
+ !equality.equal(error, previousResult.error)) {
184
+ _this.setResult({
185
+ data: (previousResult && previousResult.data),
186
+ error: error,
187
+ loading: false,
188
+ networkStatus: core.NetworkStatus.error,
189
+ });
190
+ }
191
+ };
192
+ var subscription = obsQuery.subscribe(onNext, onError);
193
+ return function () { return subscription.unsubscribe(); };
194
+ }, [
195
+ obsQuery,
196
+ this.renderPromises,
197
+ this.client.disableNetworkFetches,
198
+ ]), function () { return _this.getCurrentResult(); }, function () { return _this.getCurrentResult(); });
199
+ this.unsafeHandlePartialRefetch(result);
200
+ var queryResult = this.toQueryResult(result);
201
+ if (!queryResult.loading && this.asyncResolveFns.size) {
202
+ this.asyncResolveFns.forEach(function (resolve) { return resolve(queryResult); });
203
+ this.asyncResolveFns.clear();
204
+ }
205
+ return queryResult;
206
+ };
207
+ InternalState.prototype.useOptions = function (options) {
208
+ var _a;
209
+ var watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
210
+ var currentWatchQueryOptions = this.watchQueryOptions;
211
+ if (this.optionsToIgnoreOnce.has(currentWatchQueryOptions) ||
212
+ !equality.equal(watchQueryOptions, currentWatchQueryOptions)) {
213
+ this.watchQueryOptions = watchQueryOptions;
214
+ if (currentWatchQueryOptions && this.observable) {
215
+ this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);
216
+ this.observable.reobserve(this.getObsQueryOptions());
217
+ this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
218
+ this.result = void 0;
219
+ }
220
+ }
221
+ this.onCompleted = options.onCompleted || InternalState.prototype.onCompleted;
222
+ this.onError = options.onError || InternalState.prototype.onError;
223
+ if ((this.renderPromises || this.client.disableNetworkFetches) &&
224
+ this.queryHookOptions.ssr === false &&
225
+ !this.queryHookOptions.skip) {
226
+ this.result = this.ssrDisabledResult;
227
+ }
228
+ else if (this.queryHookOptions.skip ||
229
+ this.watchQueryOptions.fetchPolicy === 'standby') {
230
+ this.result = this.skipStandbyResult;
231
+ }
232
+ else if (this.result === this.ssrDisabledResult ||
233
+ this.result === this.skipStandbyResult) {
234
+ this.result = void 0;
235
+ }
236
+ };
237
+ InternalState.prototype.getObsQueryOptions = function () {
238
+ var toMerge = [];
239
+ var globalDefaults = this.client.defaultOptions.watchQuery;
240
+ if (globalDefaults)
241
+ toMerge.push(globalDefaults);
242
+ if (this.queryHookOptions.defaultOptions) {
243
+ toMerge.push(this.queryHookOptions.defaultOptions);
244
+ }
245
+ toMerge.push(utilities.compact(this.observable && this.observable.options, this.watchQueryOptions));
246
+ return toMerge.reduce(core.mergeOptions);
247
+ };
248
+ InternalState.prototype.createWatchQueryOptions = function (_a) {
249
+ var _b;
250
+ if (_a === void 0) { _a = {}; }
251
+ var skip = _a.skip; _a.ssr; _a.onCompleted; _a.onError; _a.defaultOptions; var otherOptions = tslib.__rest(_a, ["skip", "ssr", "onCompleted", "onError", "defaultOptions"]);
252
+ var watchQueryOptions = Object.assign(otherOptions, { query: this.query });
253
+ if (this.renderPromises &&
254
+ (watchQueryOptions.fetchPolicy === 'network-only' ||
255
+ watchQueryOptions.fetchPolicy === 'cache-and-network')) {
256
+ watchQueryOptions.fetchPolicy = 'cache-first';
257
+ }
258
+ if (!watchQueryOptions.variables) {
259
+ watchQueryOptions.variables = {};
260
+ }
261
+ if (skip) {
262
+ var _c = watchQueryOptions.fetchPolicy, fetchPolicy = _c === void 0 ? this.getDefaultFetchPolicy() : _c, _d = watchQueryOptions.initialFetchPolicy, initialFetchPolicy = _d === void 0 ? fetchPolicy : _d;
263
+ Object.assign(watchQueryOptions, {
264
+ initialFetchPolicy: initialFetchPolicy,
265
+ fetchPolicy: 'standby',
266
+ });
267
+ }
268
+ else if (!watchQueryOptions.fetchPolicy) {
269
+ watchQueryOptions.fetchPolicy =
270
+ ((_b = this.observable) === null || _b === void 0 ? void 0 : _b.options.initialFetchPolicy) ||
271
+ this.getDefaultFetchPolicy();
272
+ }
273
+ return watchQueryOptions;
274
+ };
275
+ InternalState.prototype.getDefaultFetchPolicy = function () {
276
+ var _a, _b;
277
+ return (((_a = this.queryHookOptions.defaultOptions) === null || _a === void 0 ? void 0 : _a.fetchPolicy) ||
278
+ ((_b = this.client.defaultOptions.watchQuery) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
279
+ "cache-first");
280
+ };
281
+ InternalState.prototype.onCompleted = function (data) { };
282
+ InternalState.prototype.onError = function (error) { };
283
+ InternalState.prototype.useObservableQuery = function () {
284
+ var obsQuery = this.observable =
285
+ this.renderPromises
286
+ && this.renderPromises.getSSRObservable(this.watchQueryOptions)
287
+ || this.observable
288
+ || this.client.watchQuery(this.getObsQueryOptions());
289
+ this.obsQueryFields = React.useMemo(function () { return ({
290
+ refetch: obsQuery.refetch.bind(obsQuery),
291
+ reobserve: obsQuery.reobserve.bind(obsQuery),
292
+ fetchMore: obsQuery.fetchMore.bind(obsQuery),
293
+ updateQuery: obsQuery.updateQuery.bind(obsQuery),
294
+ startPolling: obsQuery.startPolling.bind(obsQuery),
295
+ stopPolling: obsQuery.stopPolling.bind(obsQuery),
296
+ subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),
297
+ }); }, [obsQuery]);
298
+ var ssrAllowed = !(this.queryHookOptions.ssr === false ||
299
+ this.queryHookOptions.skip);
300
+ if (this.renderPromises && ssrAllowed) {
301
+ this.renderPromises.registerSSRObservable(obsQuery);
302
+ if (obsQuery.getCurrentResult().loading) {
303
+ this.renderPromises.addObservableQueryPromise(obsQuery);
304
+ }
305
+ }
306
+ return obsQuery;
307
+ };
308
+ InternalState.prototype.setResult = function (nextResult) {
309
+ var previousResult = this.result;
310
+ if (previousResult && previousResult.data) {
311
+ this.previousData = previousResult.data;
312
+ }
313
+ this.result = nextResult;
314
+ this.forceUpdate();
315
+ this.handleErrorOrCompleted(nextResult, previousResult);
316
+ };
317
+ InternalState.prototype.handleErrorOrCompleted = function (result, previousResult) {
318
+ var _this = this;
319
+ if (!result.loading) {
320
+ var error_1 = this.toApolloError(result);
321
+ Promise.resolve().then(function () {
322
+ if (error_1) {
323
+ _this.onError(error_1);
324
+ }
325
+ else if (result.data &&
326
+ (previousResult === null || previousResult === void 0 ? void 0 : previousResult.networkStatus) !== result.networkStatus &&
327
+ result.networkStatus === core.NetworkStatus.ready) {
328
+ _this.onCompleted(result.data);
329
+ }
330
+ }).catch(function (error) {
331
+ globals.__DEV__ && globals.invariant.warn(error);
332
+ });
333
+ }
334
+ };
335
+ InternalState.prototype.toApolloError = function (result) {
336
+ return utilities.isNonEmptyArray(result.errors)
337
+ ? new errors.ApolloError({ graphQLErrors: result.errors })
338
+ : result.error;
339
+ };
340
+ InternalState.prototype.getCurrentResult = function () {
341
+ if (!this.result) {
342
+ this.handleErrorOrCompleted(this.result = this.observable.getCurrentResult());
343
+ }
344
+ return this.result;
345
+ };
346
+ InternalState.prototype.toQueryResult = function (result) {
347
+ var queryResult = this.toQueryResultCache.get(result);
348
+ if (queryResult)
349
+ return queryResult;
350
+ var data = result.data; result.partial; var resultWithoutPartial = tslib.__rest(result, ["data", "partial"]);
351
+ this.toQueryResultCache.set(result, queryResult = tslib.__assign(tslib.__assign(tslib.__assign({ data: data }, resultWithoutPartial), this.obsQueryFields), { client: this.client, observable: this.observable, variables: this.observable.variables, called: !this.queryHookOptions.skip, previousData: this.previousData }));
352
+ if (!queryResult.error && utilities.isNonEmptyArray(result.errors)) {
353
+ queryResult.error = new errors.ApolloError({ graphQLErrors: result.errors });
354
+ }
355
+ return queryResult;
356
+ };
357
+ InternalState.prototype.unsafeHandlePartialRefetch = function (result) {
358
+ if (result.partial &&
359
+ this.queryHookOptions.partialRefetch &&
360
+ !result.loading &&
361
+ (!result.data || Object.keys(result.data).length === 0) &&
362
+ this.observable.options.fetchPolicy !== 'cache-only') {
363
+ Object.assign(result, {
364
+ loading: true,
365
+ networkStatus: core.NetworkStatus.refetch,
366
+ });
367
+ this.observable.refetch();
368
+ }
369
+ };
370
+ return InternalState;
371
+ }());
372
+
373
+ var EAGER_METHODS = [
374
+ 'refetch',
375
+ 'reobserve',
376
+ 'fetchMore',
377
+ 'updateQuery',
378
+ 'startPolling',
379
+ 'subscribeToMore',
380
+ ];
381
+ function useLazyQuery(query, options) {
382
+ var _a;
383
+ var abortControllersRef = React.useRef(new Set());
384
+ var execOptionsRef = React.useRef();
385
+ var merged = execOptionsRef.current ? utilities.mergeOptions(options, execOptionsRef.current) : options;
386
+ var internalState = useInternalState(useApolloClient(options && options.client), (_a = merged === null || merged === void 0 ? void 0 : merged.query) !== null && _a !== void 0 ? _a : query);
387
+ var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign({}, merged), { skip: !execOptionsRef.current }));
388
+ var initialFetchPolicy = useQueryResult.observable.options.initialFetchPolicy ||
389
+ internalState.getDefaultFetchPolicy();
390
+ var result = Object.assign(useQueryResult, {
391
+ called: !!execOptionsRef.current,
392
+ });
393
+ var eagerMethods = React.useMemo(function () {
394
+ var eagerMethods = {};
395
+ var _loop_1 = function (key) {
396
+ var method = result[key];
397
+ eagerMethods[key] = function () {
398
+ if (!execOptionsRef.current) {
399
+ execOptionsRef.current = Object.create(null);
400
+ internalState.forceUpdate();
401
+ }
402
+ return method.apply(this, arguments);
403
+ };
404
+ };
405
+ for (var _i = 0, EAGER_METHODS_1 = EAGER_METHODS; _i < EAGER_METHODS_1.length; _i++) {
406
+ var key = EAGER_METHODS_1[_i];
407
+ _loop_1(key);
408
+ }
409
+ return eagerMethods;
410
+ }, []);
411
+ Object.assign(result, eagerMethods);
412
+ React.useEffect(function () {
413
+ return function () {
414
+ abortControllersRef.current.forEach(function (controller) {
415
+ controller.abort();
416
+ });
417
+ };
418
+ }, []);
419
+ var execute = React.useCallback(function (executeOptions) {
420
+ var controller = new AbortController();
421
+ abortControllersRef.current.add(controller);
422
+ execOptionsRef.current = executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
423
+ fetchPolicy: initialFetchPolicy,
424
+ };
425
+ var promise = internalState
426
+ .asyncUpdate(controller.signal)
427
+ .then(function (queryResult) {
428
+ abortControllersRef.current.delete(controller);
429
+ return Object.assign(queryResult, eagerMethods);
430
+ });
431
+ promise.catch(function () {
432
+ abortControllersRef.current.delete(controller);
433
+ });
434
+ return promise;
435
+ }, []);
436
+ return [execute, result];
437
+ }
438
+
439
+ function useMutation(mutation, options) {
440
+ var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
441
+ parser.verifyDocumentType(mutation, parser.DocumentType.Mutation);
442
+ var _a = React.useState({
443
+ called: false,
444
+ loading: false,
445
+ client: client,
446
+ }), result = _a[0], setResult = _a[1];
447
+ var ref = React.useRef({
448
+ result: result,
449
+ mutationId: 0,
450
+ isMounted: true,
451
+ client: client,
452
+ mutation: mutation,
453
+ options: options,
454
+ });
455
+ {
456
+ Object.assign(ref.current, { client: client, options: options, mutation: mutation });
457
+ }
458
+ var execute = React.useCallback(function (executeOptions) {
459
+ if (executeOptions === void 0) { executeOptions = {}; }
460
+ var _a = ref.current, client = _a.client, options = _a.options, mutation = _a.mutation;
461
+ var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
462
+ if (!ref.current.result.loading && !baseOptions.ignoreResults && ref.current.isMounted) {
463
+ setResult(ref.current.result = {
464
+ loading: true,
465
+ error: void 0,
466
+ data: void 0,
467
+ called: true,
468
+ client: client,
469
+ });
470
+ }
471
+ var mutationId = ++ref.current.mutationId;
472
+ var clientOptions = core.mergeOptions(baseOptions, executeOptions);
473
+ return client.mutate(clientOptions).then(function (response) {
474
+ var _a;
475
+ var data = response.data, errors$1 = response.errors;
476
+ var error = errors$1 && errors$1.length > 0
477
+ ? new errors.ApolloError({ graphQLErrors: errors$1 })
478
+ : void 0;
479
+ if (mutationId === ref.current.mutationId &&
480
+ !clientOptions.ignoreResults) {
481
+ var result_1 = {
482
+ called: true,
483
+ loading: false,
484
+ data: data,
485
+ error: error,
486
+ client: client,
487
+ };
488
+ if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
489
+ setResult(ref.current.result = result_1);
490
+ }
491
+ }
492
+ var onCompleted = executeOptions.onCompleted || ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onCompleted);
493
+ onCompleted === null || onCompleted === void 0 ? void 0 : onCompleted(response.data, clientOptions);
494
+ return response;
495
+ }).catch(function (error) {
496
+ var _a;
497
+ if (mutationId === ref.current.mutationId &&
498
+ ref.current.isMounted) {
499
+ var result_2 = {
500
+ loading: false,
501
+ error: error,
502
+ data: void 0,
503
+ called: true,
504
+ client: client,
505
+ };
506
+ if (!equality.equal(ref.current.result, result_2)) {
507
+ setResult(ref.current.result = result_2);
508
+ }
509
+ }
510
+ var onError = executeOptions.onError || ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError);
511
+ if (onError) {
512
+ onError(error, clientOptions);
513
+ return { data: void 0, errors: error };
514
+ }
515
+ throw error;
516
+ });
517
+ }, []);
518
+ var reset = React.useCallback(function () {
519
+ if (ref.current.isMounted) {
520
+ setResult({ called: false, loading: false, client: client });
521
+ }
522
+ }, []);
523
+ React.useEffect(function () {
524
+ ref.current.isMounted = true;
525
+ return function () {
526
+ ref.current.isMounted = false;
527
+ };
528
+ }, []);
529
+ return [execute, tslib.__assign({ reset: reset }, result)];
530
+ }
531
+
532
+ function useSubscription(subscription, options) {
533
+ var hasIssuedDeprecationWarningRef = React.useRef(false);
534
+ var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
535
+ parser.verifyDocumentType(subscription, parser.DocumentType.Subscription);
536
+ var _a = React.useState({
537
+ loading: !(options === null || options === void 0 ? void 0 : options.skip),
538
+ error: void 0,
539
+ data: void 0,
540
+ variables: options === null || options === void 0 ? void 0 : options.variables,
541
+ }), result = _a[0], setResult = _a[1];
542
+ if (!hasIssuedDeprecationWarningRef.current) {
543
+ hasIssuedDeprecationWarningRef.current = true;
544
+ if (options === null || options === void 0 ? void 0 : options.onSubscriptionData) {
545
+ globals.__DEV__ && globals.invariant.warn(options.onData
546
+ ? "'useSubscription' supports only the 'onSubscriptionData' or 'onData' option, but not both. Only the 'onData' option will be used."
547
+ : "'onSubscriptionData' is deprecated and will be removed in a future major version. Please use the 'onData' option instead.");
548
+ }
549
+ if (options === null || options === void 0 ? void 0 : options.onSubscriptionComplete) {
550
+ globals.__DEV__ && globals.invariant.warn(options.onComplete
551
+ ? "'useSubscription' supports only the 'onSubscriptionComplete' or 'onComplete' option, but not both. Only the 'onComplete' option will be used."
552
+ : "'onSubscriptionComplete' is deprecated and will be removed in a future major version. Please use the 'onComplete' option instead.");
553
+ }
554
+ }
555
+ var _b = React.useState(function () {
556
+ if (options === null || options === void 0 ? void 0 : options.skip) {
557
+ return null;
558
+ }
559
+ return client.subscribe({
560
+ query: subscription,
561
+ variables: options === null || options === void 0 ? void 0 : options.variables,
562
+ fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
563
+ context: options === null || options === void 0 ? void 0 : options.context,
564
+ });
565
+ }), observable = _b[0], setObservable = _b[1];
566
+ var canResetObservableRef = React.useRef(false);
567
+ React.useEffect(function () {
568
+ return function () {
569
+ canResetObservableRef.current = true;
570
+ };
571
+ }, []);
572
+ var ref = React.useRef({ client: client, subscription: subscription, options: options });
573
+ React.useEffect(function () {
574
+ var _a, _b, _c, _d;
575
+ var shouldResubscribe = options === null || options === void 0 ? void 0 : options.shouldResubscribe;
576
+ if (typeof shouldResubscribe === 'function') {
577
+ shouldResubscribe = !!shouldResubscribe(options);
578
+ }
579
+ if (options === null || options === void 0 ? void 0 : options.skip) {
580
+ if (!(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip) || canResetObservableRef.current) {
581
+ setResult({
582
+ loading: false,
583
+ data: void 0,
584
+ error: void 0,
585
+ variables: options === null || options === void 0 ? void 0 : options.variables,
586
+ });
587
+ setObservable(null);
588
+ canResetObservableRef.current = false;
589
+ }
590
+ }
591
+ else if ((shouldResubscribe !== false &&
592
+ (client !== ref.current.client ||
593
+ subscription !== ref.current.subscription ||
594
+ (options === null || options === void 0 ? void 0 : options.fetchPolicy) !== ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
595
+ !(options === null || options === void 0 ? void 0 : options.skip) !== !((_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.skip) ||
596
+ !equality.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) ||
597
+ canResetObservableRef.current) {
598
+ setResult({
599
+ loading: true,
600
+ data: void 0,
601
+ error: void 0,
602
+ variables: options === null || options === void 0 ? void 0 : options.variables,
603
+ });
604
+ setObservable(client.subscribe({
605
+ query: subscription,
606
+ variables: options === null || options === void 0 ? void 0 : options.variables,
607
+ fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
608
+ context: options === null || options === void 0 ? void 0 : options.context,
609
+ }));
610
+ canResetObservableRef.current = false;
611
+ }
612
+ Object.assign(ref.current, { client: client, subscription: subscription, options: options });
613
+ }, [client, subscription, options, canResetObservableRef.current]);
614
+ React.useEffect(function () {
615
+ if (!observable) {
616
+ return;
617
+ }
618
+ var subscription = observable.subscribe({
619
+ next: function (fetchResult) {
620
+ var _a, _b;
621
+ var result = {
622
+ loading: false,
623
+ data: fetchResult.data,
624
+ error: void 0,
625
+ variables: options === null || options === void 0 ? void 0 : options.variables,
626
+ };
627
+ setResult(result);
628
+ if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onData) {
629
+ ref.current.options.onData({
630
+ client: client,
631
+ data: result
632
+ });
633
+ }
634
+ else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionData) {
635
+ ref.current.options.onSubscriptionData({
636
+ client: client,
637
+ subscriptionData: result
638
+ });
639
+ }
640
+ },
641
+ error: function (error) {
642
+ var _a, _b;
643
+ setResult({
644
+ loading: false,
645
+ data: void 0,
646
+ error: error,
647
+ variables: options === null || options === void 0 ? void 0 : options.variables,
648
+ });
649
+ (_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
650
+ },
651
+ complete: function () {
652
+ var _a, _b;
653
+ if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onComplete) {
654
+ ref.current.options.onComplete();
655
+ }
656
+ else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionComplete) {
657
+ ref.current.options.onSubscriptionComplete();
658
+ }
659
+ },
660
+ });
661
+ return function () {
662
+ subscription.unsubscribe();
663
+ };
664
+ }, [observable]);
665
+ return result;
666
+ }
667
+
668
+ function useReactiveVar(rv) {
669
+ var value = rv();
670
+ var setValue = React.useState(value)[1];
671
+ React.useEffect(function () {
672
+ var probablySameValue = rv();
673
+ if (value !== probablySameValue) {
674
+ setValue(probablySameValue);
675
+ }
676
+ else {
677
+ return rv.onNextChange(setValue);
678
+ }
679
+ }, [value]);
680
+ return value;
681
+ }
682
+
683
+ function useFragment_experimental(options) {
684
+ var cache = useApolloClient().cache;
685
+ var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
686
+ var diffOptions = tslib.__assign(tslib.__assign({}, rest), { id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
687
+ var resultRef = React.useRef();
688
+ var latestDiff = cache.diff(diffOptions);
689
+ var getSnapshot = function () {
690
+ var latestDiffToResult = diffToResult(latestDiff);
691
+ return resultRef.current &&
692
+ equality.equal(resultRef.current.data, latestDiffToResult.data)
693
+ ? resultRef.current
694
+ : (resultRef.current = latestDiffToResult);
695
+ };
696
+ return useSyncExternalStore(function (forceUpdate) {
697
+ return cache.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
698
+ if (!equality.equal(diff, latestDiff)) {
699
+ resultRef.current = diffToResult((latestDiff = diff));
700
+ forceUpdate();
701
+ }
702
+ } }));
703
+ }, getSnapshot, getSnapshot);
704
+ }
705
+ function diffToResult(diff) {
706
+ var result = {
707
+ data: diff.result,
708
+ complete: !!diff.complete,
709
+ };
710
+ if (diff.missing) {
711
+ result.missing = utilities.mergeDeepArray(diff.missing.map(function (error) { return error.missing; }));
712
+ }
713
+ return result;
714
+ }
715
+
716
+ function useDeepMemo(memoFn, deps) {
717
+ var ref = React.useRef();
718
+ if (!ref.current || !equality.equal(ref.current.deps, deps)) {
719
+ ref.current = { value: memoFn(), deps: deps };
720
+ }
721
+ return ref.current.value;
722
+ }
723
+
724
+ var useIsomorphicLayoutEffect = utilities.canUseLayoutEffect
725
+ ? React.useLayoutEffect
726
+ : React.useEffect;
727
+
728
+ function useSuspenseCache() {
729
+ var suspenseCache = React.useContext(context.getApolloContext()).suspenseCache;
730
+ globals.__DEV__ ? globals.invariant(suspenseCache, 'Could not find a "suspenseCache" in the context. Wrap the root component ' +
731
+ 'in an <ApolloProvider> and provide a suspenseCache.') : globals.invariant(suspenseCache, 33);
732
+ return suspenseCache;
733
+ }
734
+
735
+ var SUPPORTED_FETCH_POLICIES = [
736
+ 'cache-first',
737
+ 'network-only',
738
+ 'no-cache',
739
+ 'cache-and-network',
740
+ ];
741
+ var DEFAULT_FETCH_POLICY = 'cache-first';
742
+ var DEFAULT_SUSPENSE_POLICY = 'always';
743
+ var DEFAULT_ERROR_POLICY = 'none';
744
+ function useSuspenseQuery_experimental(query, options) {
745
+ if (options === void 0) { options = Object.create(null); }
746
+ var suspenseCache = useSuspenseCache();
747
+ var client = useApolloClient(options.client);
748
+ var watchQueryOptions = useWatchQueryOptions({ query: query, options: options, client: client });
749
+ var previousWatchQueryOptionsRef = React.useRef(watchQueryOptions);
750
+ var deferred = useIsDeferred(query);
751
+ var fetchPolicy = watchQueryOptions.fetchPolicy, errorPolicy = watchQueryOptions.errorPolicy, returnPartialData = watchQueryOptions.returnPartialData, variables = watchQueryOptions.variables;
752
+ var cacheEntry = suspenseCache.lookup(query, variables);
753
+ var observable = React.useState(function () {
754
+ return (cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.observable) || client.watchQuery(watchQueryOptions);
755
+ })[0];
756
+ var result = useObservableQueryResult(observable);
757
+ var hasFullResult = result.data && !result.partial;
758
+ var hasPartialResult = result.data && result.partial;
759
+ var usePartialResult = returnPartialData && hasPartialResult;
760
+ var allowsThrownErrors = errorPolicy === 'none' && (!deferred || !hasPartialResult);
761
+ if (result.error &&
762
+ (result.error.networkError || allowsThrownErrors)) {
763
+ throw result.error;
764
+ }
765
+ if (result.loading) {
766
+ if (!cacheEntry) {
767
+ cacheEntry = suspenseCache.add(query, variables, {
768
+ promise: maybeWrapConcastWithCustomPromise(observable.reobserveAsConcast(watchQueryOptions), { deferred: deferred }),
769
+ observable: observable,
770
+ });
771
+ }
772
+ var hasUsableResult = usePartialResult ||
773
+ (fetchPolicy === 'cache-and-network' && hasFullResult);
774
+ if (!hasUsableResult && !cacheEntry.fulfilled) {
775
+ throw cacheEntry.promise;
776
+ }
777
+ }
778
+ React.useEffect(function () {
779
+ var variables = watchQueryOptions.variables, query = watchQueryOptions.query;
780
+ var previousOpts = previousWatchQueryOptionsRef.current;
781
+ if (variables !== previousOpts.variables || query !== previousOpts.query) {
782
+ suspenseCache.remove(previousOpts.query, previousOpts.variables);
783
+ suspenseCache.add(query, variables, {
784
+ promise: observable.reobserve({ query: query, variables: variables }),
785
+ observable: observable,
786
+ });
787
+ previousWatchQueryOptionsRef.current = watchQueryOptions;
788
+ }
789
+ }, [watchQueryOptions]);
790
+ React.useEffect(function () {
791
+ return function () {
792
+ suspenseCache.remove(query, variables);
793
+ };
794
+ }, []);
795
+ return React.useMemo(function () {
796
+ return {
797
+ client: client,
798
+ data: result.data,
799
+ error: errorPolicy === 'ignore' ? void 0 : toApolloError(result),
800
+ fetchMore: function (options) {
801
+ var promise = observable.fetchMore(options);
802
+ suspenseCache.add(query, watchQueryOptions.variables, {
803
+ promise: promise,
804
+ observable: observable,
805
+ });
806
+ return promise;
807
+ },
808
+ refetch: function (variables) {
809
+ var promise = observable.refetch(variables);
810
+ suspenseCache.add(query, watchQueryOptions.variables, {
811
+ promise: promise,
812
+ observable: observable,
813
+ });
814
+ return promise;
815
+ },
816
+ subscribeToMore: function (options) { return observable.subscribeToMore(options); },
817
+ };
818
+ }, [client, result, observable, errorPolicy]);
819
+ }
820
+ function validateOptions(options) {
821
+ var query = options.query, _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? DEFAULT_FETCH_POLICY : _a, returnPartialData = options.returnPartialData;
822
+ parser.verifyDocumentType(query, parser.DocumentType.Query);
823
+ validateFetchPolicy(fetchPolicy);
824
+ validatePartialDataReturn(fetchPolicy, returnPartialData);
825
+ }
826
+ function validateFetchPolicy(fetchPolicy) {
827
+ globals.__DEV__ ? globals.invariant(SUPPORTED_FETCH_POLICIES.includes(fetchPolicy), "The fetch policy `".concat(fetchPolicy, "` is not supported with suspense.")) : globals.invariant(SUPPORTED_FETCH_POLICIES.includes(fetchPolicy), 34);
828
+ }
829
+ function validatePartialDataReturn(fetchPolicy, returnPartialData) {
830
+ if (fetchPolicy === 'no-cache' && returnPartialData) {
831
+ globals.__DEV__ && globals.invariant.warn('Using `returnPartialData` with a `no-cache` fetch policy has no effect. To read partial data from the cache, consider using an alternate fetch policy.');
832
+ }
833
+ }
834
+ function toApolloError(result) {
835
+ return utilities.isNonEmptyArray(result.errors)
836
+ ? new core.ApolloError({ graphQLErrors: result.errors })
837
+ : result.error;
838
+ }
839
+ function maybeWrapConcastWithCustomPromise(concast, _a) {
840
+ var deferred = _a.deferred;
841
+ if (deferred) {
842
+ return new Promise(function (resolve, reject) {
843
+ var subscription = concast.subscribe({
844
+ next: function (value) {
845
+ resolve(value);
846
+ subscription.unsubscribe();
847
+ },
848
+ error: reject,
849
+ });
850
+ });
851
+ }
852
+ return concast.promise;
853
+ }
854
+ function useWatchQueryOptions(_a) {
855
+ var query = _a.query, options = _a.options, client = _a.client;
856
+ var defaultOptions = client.defaultOptions.watchQuery;
857
+ var watchQueryOptions = useDeepMemo(function () {
858
+ var errorPolicy = options.errorPolicy, fetchPolicy = options.fetchPolicy, _a = options.suspensePolicy, suspensePolicy = _a === void 0 ? DEFAULT_SUSPENSE_POLICY : _a, variables = options.variables, watchQueryOptions = tslib.__rest(options, ["errorPolicy", "fetchPolicy", "suspensePolicy", "variables"]);
859
+ return tslib.__assign(tslib.__assign({}, watchQueryOptions), { query: query, errorPolicy: errorPolicy || (defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.errorPolicy) || DEFAULT_ERROR_POLICY, fetchPolicy: fetchPolicy || (defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.fetchPolicy) || DEFAULT_FETCH_POLICY, notifyOnNetworkStatusChange: suspensePolicy === 'always', fetchOnFirstSubscribe: false, variables: utilities.compact(tslib.__assign(tslib.__assign({}, defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.variables), variables)) });
860
+ }, [options, query, defaultOptions]);
861
+ if (globals.__DEV__) {
862
+ validateOptions(watchQueryOptions);
863
+ }
864
+ return watchQueryOptions;
865
+ }
866
+ function useIsDeferred(query) {
867
+ return React.useMemo(function () { return utilities.hasDirectives(['defer'], query); }, [query]);
868
+ }
869
+ function useObservableQueryResult(observable) {
870
+ var resultRef = React.useRef();
871
+ var isMountedRef = React.useRef(false);
872
+ if (!resultRef.current) {
873
+ resultRef.current = observable.getCurrentResult();
874
+ }
875
+ useIsomorphicLayoutEffect(function () {
876
+ isMountedRef.current = true;
877
+ return function () {
878
+ isMountedRef.current = false;
879
+ };
880
+ }, []);
881
+ return useSyncExternalStore(React.useCallback(function (forceUpdate) {
882
+ function handleUpdate() {
883
+ var previousResult = resultRef.current;
884
+ var result = observable.getCurrentResult();
885
+ if (previousResult.loading === result.loading &&
886
+ previousResult.networkStatus === result.networkStatus &&
887
+ equality.equal(previousResult.data, result.data)) {
888
+ return;
889
+ }
890
+ resultRef.current = result;
891
+ if (isMountedRef.current) {
892
+ forceUpdate();
893
+ }
894
+ }
895
+ var subscription = observable.subscribe({
896
+ next: handleUpdate,
897
+ error: handleUpdate,
898
+ });
899
+ return function () {
900
+ subscription.unsubscribe();
901
+ };
902
+ }, [observable]), function () { return resultRef.current; }, function () { return resultRef.current; });
903
+ }
904
+
905
+ exports.useApolloClient = useApolloClient;
906
+ exports.useFragment_experimental = useFragment_experimental;
907
+ exports.useLazyQuery = useLazyQuery;
908
+ exports.useMutation = useMutation;
909
+ exports.useQuery = useQuery;
910
+ exports.useReactiveVar = useReactiveVar;
911
+ exports.useSubscription = useSubscription;
912
+ exports.useSuspenseQuery_experimental = useSuspenseQuery_experimental;
913
+ //# sourceMappingURL=hooks.cjs.map