@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,890 @@
1
+ import { __assign, __awaiter, __generator } from "tslib";
2
+ import { invariant, InvariantError, __DEV__ } from "../utilities/globals/index.js";
3
+ import { equal } from '@wry/equality';
4
+ import { execute } from "../link/core/index.js";
5
+ import { isExecutionPatchIncrementalResult, isExecutionPatchResult, } from "../utilities/index.js";
6
+ import { canonicalStringify } from "../cache/index.js";
7
+ import { getDefaultValues, getOperationDefinition, getOperationName, hasClientExports, graphQLResultHasError, getGraphQLErrorsFromResult, removeConnectionDirectiveFromDocument, canUseWeakMap, Observable, asyncMap, isNonEmptyArray, Concast, makeUniqueId, isDocumentNode, isNonNullObject, } from "../utilities/index.js";
8
+ import { mergeIncrementalData } from "../utilities/common/incrementalResult.js";
9
+ import { ApolloError, isApolloError } from "../errors/index.js";
10
+ import { ObservableQuery, logMissingFieldErrors } from "./ObservableQuery.js";
11
+ import { NetworkStatus, isNetworkRequestInFlight } from "./networkStatus.js";
12
+ import { LocalState } from "./LocalState.js";
13
+ import { QueryInfo, shouldWriteResult, } from "./QueryInfo.js";
14
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
15
+ var QueryManager = (function () {
16
+ function QueryManager(_a) {
17
+ var cache = _a.cache, link = _a.link, defaultOptions = _a.defaultOptions, _b = _a.queryDeduplication, queryDeduplication = _b === void 0 ? false : _b, onBroadcast = _a.onBroadcast, _c = _a.ssrMode, ssrMode = _c === void 0 ? false : _c, _d = _a.clientAwareness, clientAwareness = _d === void 0 ? {} : _d, localState = _a.localState, assumeImmutableResults = _a.assumeImmutableResults;
18
+ this.clientAwareness = {};
19
+ this.queries = new Map();
20
+ this.fetchCancelFns = new Map();
21
+ this.transformCache = new (canUseWeakMap ? WeakMap : Map)();
22
+ this.queryIdCounter = 1;
23
+ this.requestIdCounter = 1;
24
+ this.mutationIdCounter = 1;
25
+ this.inFlightLinkObservables = new Map();
26
+ this.cache = cache;
27
+ this.link = link;
28
+ this.defaultOptions = defaultOptions || Object.create(null);
29
+ this.queryDeduplication = queryDeduplication;
30
+ this.clientAwareness = clientAwareness;
31
+ this.localState = localState || new LocalState({ cache: cache });
32
+ this.ssrMode = ssrMode;
33
+ this.assumeImmutableResults = !!assumeImmutableResults;
34
+ if ((this.onBroadcast = onBroadcast)) {
35
+ this.mutationStore = Object.create(null);
36
+ }
37
+ }
38
+ QueryManager.prototype.stop = function () {
39
+ var _this = this;
40
+ this.queries.forEach(function (_info, queryId) {
41
+ _this.stopQueryNoBroadcast(queryId);
42
+ });
43
+ this.cancelPendingFetches(__DEV__ ? new InvariantError('QueryManager stopped while query was in flight') : new InvariantError(14));
44
+ };
45
+ QueryManager.prototype.cancelPendingFetches = function (error) {
46
+ this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
47
+ this.fetchCancelFns.clear();
48
+ };
49
+ QueryManager.prototype.mutate = function (_a) {
50
+ var _b, _c;
51
+ var mutation = _a.mutation, variables = _a.variables, optimisticResponse = _a.optimisticResponse, updateQueries = _a.updateQueries, _d = _a.refetchQueries, refetchQueries = _d === void 0 ? [] : _d, _e = _a.awaitRefetchQueries, awaitRefetchQueries = _e === void 0 ? false : _e, updateWithProxyFn = _a.update, onQueryUpdated = _a.onQueryUpdated, _f = _a.fetchPolicy, fetchPolicy = _f === void 0 ? ((_b = this.defaultOptions.mutate) === null || _b === void 0 ? void 0 : _b.fetchPolicy) || "network-only" : _f, _g = _a.errorPolicy, errorPolicy = _g === void 0 ? ((_c = this.defaultOptions.mutate) === null || _c === void 0 ? void 0 : _c.errorPolicy) || "none" : _g, keepRootFields = _a.keepRootFields, context = _a.context;
52
+ return __awaiter(this, void 0, void 0, function () {
53
+ var mutationId, _h, document, hasClientExports, mutationStoreValue, self;
54
+ return __generator(this, function (_j) {
55
+ switch (_j.label) {
56
+ case 0:
57
+ __DEV__ ? invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : invariant(mutation, 15);
58
+ __DEV__ ? invariant(fetchPolicy === 'network-only' ||
59
+ fetchPolicy === 'no-cache', "Mutations support only 'network-only' or 'no-cache' fetchPolicy strings. The default `network-only` behavior automatically writes mutation results to the cache. Passing `no-cache` skips the cache write.") : invariant(fetchPolicy === 'network-only' ||
60
+ fetchPolicy === 'no-cache', 16);
61
+ mutationId = this.generateMutationId();
62
+ _h = this.transform(mutation), document = _h.document, hasClientExports = _h.hasClientExports;
63
+ mutation = this.cache.transformForLink(document);
64
+ variables = this.getVariables(mutation, variables);
65
+ if (!hasClientExports) return [3, 2];
66
+ return [4, this.localState.addExportedVariables(mutation, variables, context)];
67
+ case 1:
68
+ variables = (_j.sent());
69
+ _j.label = 2;
70
+ case 2:
71
+ mutationStoreValue = this.mutationStore &&
72
+ (this.mutationStore[mutationId] = {
73
+ mutation: mutation,
74
+ variables: variables,
75
+ loading: true,
76
+ error: null,
77
+ });
78
+ if (optimisticResponse) {
79
+ this.markMutationOptimistic(optimisticResponse, {
80
+ mutationId: mutationId,
81
+ document: mutation,
82
+ variables: variables,
83
+ fetchPolicy: fetchPolicy,
84
+ errorPolicy: errorPolicy,
85
+ context: context,
86
+ updateQueries: updateQueries,
87
+ update: updateWithProxyFn,
88
+ keepRootFields: keepRootFields,
89
+ });
90
+ }
91
+ this.broadcastQueries();
92
+ self = this;
93
+ return [2, new Promise(function (resolve, reject) {
94
+ return asyncMap(self.getObservableFromLink(mutation, __assign(__assign({}, context), { optimisticResponse: optimisticResponse }), variables, false), function (result) {
95
+ if (graphQLResultHasError(result) && errorPolicy === 'none') {
96
+ throw new ApolloError({
97
+ graphQLErrors: getGraphQLErrorsFromResult(result),
98
+ });
99
+ }
100
+ if (mutationStoreValue) {
101
+ mutationStoreValue.loading = false;
102
+ mutationStoreValue.error = null;
103
+ }
104
+ var storeResult = __assign({}, result);
105
+ if (typeof refetchQueries === "function") {
106
+ refetchQueries = refetchQueries(storeResult);
107
+ }
108
+ if (errorPolicy === 'ignore' &&
109
+ graphQLResultHasError(storeResult)) {
110
+ delete storeResult.errors;
111
+ }
112
+ return self.markMutationResult({
113
+ mutationId: mutationId,
114
+ result: storeResult,
115
+ document: mutation,
116
+ variables: variables,
117
+ fetchPolicy: fetchPolicy,
118
+ errorPolicy: errorPolicy,
119
+ context: context,
120
+ update: updateWithProxyFn,
121
+ updateQueries: updateQueries,
122
+ awaitRefetchQueries: awaitRefetchQueries,
123
+ refetchQueries: refetchQueries,
124
+ removeOptimistic: optimisticResponse ? mutationId : void 0,
125
+ onQueryUpdated: onQueryUpdated,
126
+ keepRootFields: keepRootFields,
127
+ });
128
+ }).subscribe({
129
+ next: function (storeResult) {
130
+ self.broadcastQueries();
131
+ if (!('hasNext' in storeResult) || storeResult.hasNext === false) {
132
+ resolve(storeResult);
133
+ }
134
+ },
135
+ error: function (err) {
136
+ if (mutationStoreValue) {
137
+ mutationStoreValue.loading = false;
138
+ mutationStoreValue.error = err;
139
+ }
140
+ if (optimisticResponse) {
141
+ self.cache.removeOptimistic(mutationId);
142
+ }
143
+ self.broadcastQueries();
144
+ reject(err instanceof ApolloError ? err : new ApolloError({
145
+ networkError: err,
146
+ }));
147
+ },
148
+ });
149
+ })];
150
+ }
151
+ });
152
+ });
153
+ };
154
+ QueryManager.prototype.markMutationResult = function (mutation, cache) {
155
+ var _this = this;
156
+ if (cache === void 0) { cache = this.cache; }
157
+ var result = mutation.result;
158
+ var cacheWrites = [];
159
+ var skipCache = mutation.fetchPolicy === "no-cache";
160
+ if (!skipCache && shouldWriteResult(result, mutation.errorPolicy)) {
161
+ if (!isExecutionPatchIncrementalResult(result)) {
162
+ cacheWrites.push({
163
+ result: result.data,
164
+ dataId: 'ROOT_MUTATION',
165
+ query: mutation.document,
166
+ variables: mutation.variables,
167
+ });
168
+ }
169
+ if (isExecutionPatchIncrementalResult(result) && isNonEmptyArray(result.incremental)) {
170
+ var diff = cache.diff({
171
+ id: "ROOT_MUTATION",
172
+ query: this.transform(mutation.document).asQuery,
173
+ variables: mutation.variables,
174
+ optimistic: false,
175
+ returnPartialData: true,
176
+ });
177
+ var mergedData = void 0;
178
+ if (diff.result) {
179
+ mergedData = mergeIncrementalData(diff.result, result);
180
+ }
181
+ if (typeof mergedData !== 'undefined') {
182
+ result.data = mergedData;
183
+ cacheWrites.push({
184
+ result: mergedData,
185
+ dataId: 'ROOT_MUTATION',
186
+ query: mutation.document,
187
+ variables: mutation.variables,
188
+ });
189
+ }
190
+ }
191
+ var updateQueries_1 = mutation.updateQueries;
192
+ if (updateQueries_1) {
193
+ this.queries.forEach(function (_a, queryId) {
194
+ var observableQuery = _a.observableQuery;
195
+ var queryName = observableQuery && observableQuery.queryName;
196
+ if (!queryName || !hasOwnProperty.call(updateQueries_1, queryName)) {
197
+ return;
198
+ }
199
+ var updater = updateQueries_1[queryName];
200
+ var _b = _this.queries.get(queryId), document = _b.document, variables = _b.variables;
201
+ var _c = cache.diff({
202
+ query: document,
203
+ variables: variables,
204
+ returnPartialData: true,
205
+ optimistic: false,
206
+ }), currentQueryResult = _c.result, complete = _c.complete;
207
+ if (complete && currentQueryResult) {
208
+ var nextQueryResult = updater(currentQueryResult, {
209
+ mutationResult: result,
210
+ queryName: document && getOperationName(document) || void 0,
211
+ queryVariables: variables,
212
+ });
213
+ if (nextQueryResult) {
214
+ cacheWrites.push({
215
+ result: nextQueryResult,
216
+ dataId: 'ROOT_QUERY',
217
+ query: document,
218
+ variables: variables,
219
+ });
220
+ }
221
+ }
222
+ });
223
+ }
224
+ }
225
+ if (cacheWrites.length > 0 ||
226
+ mutation.refetchQueries ||
227
+ mutation.update ||
228
+ mutation.onQueryUpdated ||
229
+ mutation.removeOptimistic) {
230
+ var results_1 = [];
231
+ this.refetchQueries({
232
+ updateCache: function (cache) {
233
+ if (!skipCache) {
234
+ cacheWrites.forEach(function (write) { return cache.write(write); });
235
+ }
236
+ var update = mutation.update;
237
+ var isFinalResult = !isExecutionPatchResult(result) ||
238
+ (isExecutionPatchIncrementalResult(result) && !result.hasNext);
239
+ if (update) {
240
+ if (!skipCache) {
241
+ var diff = cache.diff({
242
+ id: "ROOT_MUTATION",
243
+ query: _this.transform(mutation.document).asQuery,
244
+ variables: mutation.variables,
245
+ optimistic: false,
246
+ returnPartialData: true,
247
+ });
248
+ if (diff.complete) {
249
+ result = __assign(__assign({}, result), { data: diff.result });
250
+ if ('incremental' in result) {
251
+ delete result.incremental;
252
+ }
253
+ if ('hasNext' in result) {
254
+ delete result.hasNext;
255
+ }
256
+ }
257
+ }
258
+ if (isFinalResult) {
259
+ update(cache, result, {
260
+ context: mutation.context,
261
+ variables: mutation.variables,
262
+ });
263
+ }
264
+ }
265
+ if (!skipCache && !mutation.keepRootFields && isFinalResult) {
266
+ cache.modify({
267
+ id: 'ROOT_MUTATION',
268
+ fields: function (value, _a) {
269
+ var fieldName = _a.fieldName, DELETE = _a.DELETE;
270
+ return fieldName === "__typename" ? value : DELETE;
271
+ },
272
+ });
273
+ }
274
+ },
275
+ include: mutation.refetchQueries,
276
+ optimistic: false,
277
+ removeOptimistic: mutation.removeOptimistic,
278
+ onQueryUpdated: mutation.onQueryUpdated || null,
279
+ }).forEach(function (result) { return results_1.push(result); });
280
+ if (mutation.awaitRefetchQueries || mutation.onQueryUpdated) {
281
+ return Promise.all(results_1).then(function () { return result; });
282
+ }
283
+ }
284
+ return Promise.resolve(result);
285
+ };
286
+ QueryManager.prototype.markMutationOptimistic = function (optimisticResponse, mutation) {
287
+ var _this = this;
288
+ var data = typeof optimisticResponse === "function"
289
+ ? optimisticResponse(mutation.variables)
290
+ : optimisticResponse;
291
+ return this.cache.recordOptimisticTransaction(function (cache) {
292
+ try {
293
+ _this.markMutationResult(__assign(__assign({}, mutation), { result: { data: data } }), cache);
294
+ }
295
+ catch (error) {
296
+ __DEV__ && invariant.error(error);
297
+ }
298
+ }, mutation.mutationId);
299
+ };
300
+ QueryManager.prototype.fetchQuery = function (queryId, options, networkStatus) {
301
+ return this.fetchQueryObservable(queryId, options, networkStatus).promise;
302
+ };
303
+ QueryManager.prototype.getQueryStore = function () {
304
+ var store = Object.create(null);
305
+ this.queries.forEach(function (info, queryId) {
306
+ store[queryId] = {
307
+ variables: info.variables,
308
+ networkStatus: info.networkStatus,
309
+ networkError: info.networkError,
310
+ graphQLErrors: info.graphQLErrors,
311
+ };
312
+ });
313
+ return store;
314
+ };
315
+ QueryManager.prototype.resetErrors = function (queryId) {
316
+ var queryInfo = this.queries.get(queryId);
317
+ if (queryInfo) {
318
+ queryInfo.networkError = undefined;
319
+ queryInfo.graphQLErrors = [];
320
+ }
321
+ };
322
+ QueryManager.prototype.transform = function (document) {
323
+ var transformCache = this.transformCache;
324
+ var _a = (this.defaultOptions.transformQuery || Object.create(null)).removeClientFields, removeClientFields = _a === void 0 ? true : _a;
325
+ if (!transformCache.has(document)) {
326
+ var transformed = this.cache.transformDocument(document);
327
+ var noConnection = removeConnectionDirectiveFromDocument(transformed);
328
+ var clientQuery = this.localState.clientQuery(transformed);
329
+ var serverQuery = noConnection &&
330
+ this.localState.serverQuery(noConnection, { removeClientFields: removeClientFields });
331
+ var cacheEntry_1 = {
332
+ document: transformed,
333
+ hasClientExports: hasClientExports(transformed),
334
+ hasForcedResolvers: this.localState.shouldForceResolvers(transformed),
335
+ clientQuery: clientQuery,
336
+ serverQuery: serverQuery,
337
+ defaultVars: getDefaultValues(getOperationDefinition(transformed)),
338
+ asQuery: __assign(__assign({}, transformed), { definitions: transformed.definitions.map(function (def) {
339
+ if (def.kind === "OperationDefinition" &&
340
+ def.operation !== "query") {
341
+ return __assign(__assign({}, def), { operation: "query" });
342
+ }
343
+ return def;
344
+ }) })
345
+ };
346
+ var add = function (doc) {
347
+ if (doc && !transformCache.has(doc)) {
348
+ transformCache.set(doc, cacheEntry_1);
349
+ }
350
+ };
351
+ add(document);
352
+ add(transformed);
353
+ add(clientQuery);
354
+ add(serverQuery);
355
+ }
356
+ return transformCache.get(document);
357
+ };
358
+ QueryManager.prototype.getVariables = function (document, variables) {
359
+ return __assign(__assign({}, this.transform(document).defaultVars), variables);
360
+ };
361
+ QueryManager.prototype.watchQuery = function (options) {
362
+ options = __assign(__assign({}, options), { variables: this.getVariables(options.query, options.variables) });
363
+ if (typeof options.notifyOnNetworkStatusChange === 'undefined') {
364
+ options.notifyOnNetworkStatusChange = false;
365
+ }
366
+ var queryInfo = new QueryInfo(this);
367
+ var observable = new ObservableQuery({
368
+ queryManager: this,
369
+ queryInfo: queryInfo,
370
+ options: options,
371
+ });
372
+ this.queries.set(observable.queryId, queryInfo);
373
+ queryInfo.init({
374
+ document: observable.query,
375
+ observableQuery: observable,
376
+ variables: observable.variables,
377
+ });
378
+ return observable;
379
+ };
380
+ QueryManager.prototype.query = function (options, queryId) {
381
+ var _this = this;
382
+ if (queryId === void 0) { queryId = this.generateQueryId(); }
383
+ __DEV__ ? invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
384
+ 'in the query option.') : invariant(options.query, 17);
385
+ __DEV__ ? invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : invariant(options.query.kind === 'Document', 18);
386
+ __DEV__ ? invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : invariant(!options.returnPartialData, 19);
387
+ __DEV__ ? invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : invariant(!options.pollInterval, 20);
388
+ return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
389
+ };
390
+ QueryManager.prototype.generateQueryId = function () {
391
+ return String(this.queryIdCounter++);
392
+ };
393
+ QueryManager.prototype.generateRequestId = function () {
394
+ return this.requestIdCounter++;
395
+ };
396
+ QueryManager.prototype.generateMutationId = function () {
397
+ return String(this.mutationIdCounter++);
398
+ };
399
+ QueryManager.prototype.stopQueryInStore = function (queryId) {
400
+ this.stopQueryInStoreNoBroadcast(queryId);
401
+ this.broadcastQueries();
402
+ };
403
+ QueryManager.prototype.stopQueryInStoreNoBroadcast = function (queryId) {
404
+ var queryInfo = this.queries.get(queryId);
405
+ if (queryInfo)
406
+ queryInfo.stop();
407
+ };
408
+ QueryManager.prototype.clearStore = function (options) {
409
+ if (options === void 0) { options = {
410
+ discardWatches: true,
411
+ }; }
412
+ this.cancelPendingFetches(__DEV__ ? new InvariantError('Store reset while query was in flight (not completed in link chain)') : new InvariantError(21));
413
+ this.queries.forEach(function (queryInfo) {
414
+ if (queryInfo.observableQuery) {
415
+ queryInfo.networkStatus = NetworkStatus.loading;
416
+ }
417
+ else {
418
+ queryInfo.stop();
419
+ }
420
+ });
421
+ if (this.mutationStore) {
422
+ this.mutationStore = Object.create(null);
423
+ }
424
+ return this.cache.reset(options);
425
+ };
426
+ QueryManager.prototype.getObservableQueries = function (include) {
427
+ var _this = this;
428
+ if (include === void 0) { include = "active"; }
429
+ var queries = new Map();
430
+ var queryNamesAndDocs = new Map();
431
+ var legacyQueryOptions = new Set();
432
+ if (Array.isArray(include)) {
433
+ include.forEach(function (desc) {
434
+ if (typeof desc === "string") {
435
+ queryNamesAndDocs.set(desc, false);
436
+ }
437
+ else if (isDocumentNode(desc)) {
438
+ queryNamesAndDocs.set(_this.transform(desc).document, false);
439
+ }
440
+ else if (isNonNullObject(desc) && desc.query) {
441
+ legacyQueryOptions.add(desc);
442
+ }
443
+ });
444
+ }
445
+ this.queries.forEach(function (_a, queryId) {
446
+ var oq = _a.observableQuery, document = _a.document;
447
+ if (oq) {
448
+ if (include === "all") {
449
+ queries.set(queryId, oq);
450
+ return;
451
+ }
452
+ var queryName = oq.queryName, fetchPolicy = oq.options.fetchPolicy;
453
+ if (fetchPolicy === "standby" ||
454
+ (include === "active" && !oq.hasObservers())) {
455
+ return;
456
+ }
457
+ if (include === "active" ||
458
+ (queryName && queryNamesAndDocs.has(queryName)) ||
459
+ (document && queryNamesAndDocs.has(document))) {
460
+ queries.set(queryId, oq);
461
+ if (queryName)
462
+ queryNamesAndDocs.set(queryName, true);
463
+ if (document)
464
+ queryNamesAndDocs.set(document, true);
465
+ }
466
+ }
467
+ });
468
+ if (legacyQueryOptions.size) {
469
+ legacyQueryOptions.forEach(function (options) {
470
+ var queryId = makeUniqueId("legacyOneTimeQuery");
471
+ var queryInfo = _this.getQuery(queryId).init({
472
+ document: options.query,
473
+ variables: options.variables,
474
+ });
475
+ var oq = new ObservableQuery({
476
+ queryManager: _this,
477
+ queryInfo: queryInfo,
478
+ options: __assign(__assign({}, options), { fetchPolicy: "network-only" }),
479
+ });
480
+ invariant(oq.queryId === queryId);
481
+ queryInfo.setObservableQuery(oq);
482
+ queries.set(queryId, oq);
483
+ });
484
+ }
485
+ if (__DEV__ && queryNamesAndDocs.size) {
486
+ queryNamesAndDocs.forEach(function (included, nameOrDoc) {
487
+ if (!included) {
488
+ __DEV__ && invariant.warn("Unknown query ".concat(typeof nameOrDoc === "string" ? "named " : "").concat(JSON.stringify(nameOrDoc, null, 2), " requested in refetchQueries options.include array"));
489
+ }
490
+ });
491
+ }
492
+ return queries;
493
+ };
494
+ QueryManager.prototype.reFetchObservableQueries = function (includeStandby) {
495
+ var _this = this;
496
+ if (includeStandby === void 0) { includeStandby = false; }
497
+ var observableQueryPromises = [];
498
+ this.getObservableQueries(includeStandby ? "all" : "active").forEach(function (observableQuery, queryId) {
499
+ var fetchPolicy = observableQuery.options.fetchPolicy;
500
+ observableQuery.resetLastResults();
501
+ if (includeStandby ||
502
+ (fetchPolicy !== "standby" &&
503
+ fetchPolicy !== "cache-only")) {
504
+ observableQueryPromises.push(observableQuery.refetch());
505
+ }
506
+ _this.getQuery(queryId).setDiff(null);
507
+ });
508
+ this.broadcastQueries();
509
+ return Promise.all(observableQueryPromises);
510
+ };
511
+ QueryManager.prototype.setObservableQuery = function (observableQuery) {
512
+ this.getQuery(observableQuery.queryId).setObservableQuery(observableQuery);
513
+ };
514
+ QueryManager.prototype.startGraphQLSubscription = function (_a) {
515
+ var _this = this;
516
+ var query = _a.query, fetchPolicy = _a.fetchPolicy, errorPolicy = _a.errorPolicy, variables = _a.variables, _b = _a.context, context = _b === void 0 ? {} : _b;
517
+ query = this.transform(query).document;
518
+ variables = this.getVariables(query, variables);
519
+ var makeObservable = function (variables) {
520
+ return _this.getObservableFromLink(query, context, variables).map(function (result) {
521
+ if (fetchPolicy !== 'no-cache') {
522
+ if (shouldWriteResult(result, errorPolicy)) {
523
+ _this.cache.write({
524
+ query: query,
525
+ result: result.data,
526
+ dataId: 'ROOT_SUBSCRIPTION',
527
+ variables: variables,
528
+ });
529
+ }
530
+ _this.broadcastQueries();
531
+ }
532
+ if (graphQLResultHasError(result)) {
533
+ throw new ApolloError({
534
+ graphQLErrors: result.errors,
535
+ });
536
+ }
537
+ return result;
538
+ });
539
+ };
540
+ if (this.transform(query).hasClientExports) {
541
+ var observablePromise_1 = this.localState.addExportedVariables(query, variables, context).then(makeObservable);
542
+ return new Observable(function (observer) {
543
+ var sub = null;
544
+ observablePromise_1.then(function (observable) { return sub = observable.subscribe(observer); }, observer.error);
545
+ return function () { return sub && sub.unsubscribe(); };
546
+ });
547
+ }
548
+ return makeObservable(variables);
549
+ };
550
+ QueryManager.prototype.stopQuery = function (queryId) {
551
+ this.stopQueryNoBroadcast(queryId);
552
+ this.broadcastQueries();
553
+ };
554
+ QueryManager.prototype.stopQueryNoBroadcast = function (queryId) {
555
+ this.stopQueryInStoreNoBroadcast(queryId);
556
+ this.removeQuery(queryId);
557
+ };
558
+ QueryManager.prototype.removeQuery = function (queryId) {
559
+ this.fetchCancelFns.delete(queryId);
560
+ if (this.queries.has(queryId)) {
561
+ this.getQuery(queryId).stop();
562
+ this.queries.delete(queryId);
563
+ }
564
+ };
565
+ QueryManager.prototype.broadcastQueries = function () {
566
+ if (this.onBroadcast)
567
+ this.onBroadcast();
568
+ this.queries.forEach(function (info) { return info.notify(); });
569
+ };
570
+ QueryManager.prototype.getLocalState = function () {
571
+ return this.localState;
572
+ };
573
+ QueryManager.prototype.getObservableFromLink = function (query, context, variables, deduplication) {
574
+ var _this = this;
575
+ var _a;
576
+ if (deduplication === void 0) { deduplication = (_a = context === null || context === void 0 ? void 0 : context.queryDeduplication) !== null && _a !== void 0 ? _a : this.queryDeduplication; }
577
+ var observable;
578
+ var serverQuery = this.transform(query).serverQuery;
579
+ if (serverQuery) {
580
+ var _b = this, inFlightLinkObservables_1 = _b.inFlightLinkObservables, link = _b.link;
581
+ var operation = {
582
+ query: serverQuery,
583
+ variables: variables,
584
+ operationName: getOperationName(serverQuery) || void 0,
585
+ context: this.prepareContext(__assign(__assign({}, context), { forceFetch: !deduplication })),
586
+ };
587
+ context = operation.context;
588
+ if (deduplication) {
589
+ var byVariables_1 = inFlightLinkObservables_1.get(serverQuery) || new Map();
590
+ inFlightLinkObservables_1.set(serverQuery, byVariables_1);
591
+ var varJson_1 = canonicalStringify(variables);
592
+ observable = byVariables_1.get(varJson_1);
593
+ if (!observable) {
594
+ var concast = new Concast([
595
+ execute(link, operation)
596
+ ]);
597
+ byVariables_1.set(varJson_1, observable = concast);
598
+ concast.beforeNext(function () {
599
+ if (byVariables_1.delete(varJson_1) &&
600
+ byVariables_1.size < 1) {
601
+ inFlightLinkObservables_1.delete(serverQuery);
602
+ }
603
+ });
604
+ }
605
+ }
606
+ else {
607
+ observable = new Concast([
608
+ execute(link, operation)
609
+ ]);
610
+ }
611
+ }
612
+ else {
613
+ observable = new Concast([
614
+ Observable.of({ data: {} })
615
+ ]);
616
+ context = this.prepareContext(context);
617
+ }
618
+ var clientQuery = this.transform(query).clientQuery;
619
+ if (clientQuery) {
620
+ observable = asyncMap(observable, function (result) {
621
+ return _this.localState.runResolvers({
622
+ document: clientQuery,
623
+ remoteResult: result,
624
+ context: context,
625
+ variables: variables,
626
+ });
627
+ });
628
+ }
629
+ return observable;
630
+ };
631
+ QueryManager.prototype.getResultsFromLink = function (queryInfo, cacheWriteBehavior, options) {
632
+ var requestId = queryInfo.lastRequestId = this.generateRequestId();
633
+ var linkDocument = this.cache.transformForLink(this.transform(queryInfo.document).document);
634
+ return asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
635
+ var graphQLErrors = getGraphQLErrorsFromResult(result);
636
+ var hasErrors = graphQLErrors.length > 0;
637
+ if (requestId >= queryInfo.lastRequestId) {
638
+ if (hasErrors && options.errorPolicy === "none") {
639
+ throw queryInfo.markError(new ApolloError({
640
+ graphQLErrors: graphQLErrors,
641
+ }));
642
+ }
643
+ queryInfo.markResult(result, linkDocument, options, cacheWriteBehavior);
644
+ queryInfo.markReady();
645
+ }
646
+ var aqr = {
647
+ data: result.data,
648
+ loading: false,
649
+ networkStatus: NetworkStatus.ready,
650
+ };
651
+ if (hasErrors && options.errorPolicy !== "ignore") {
652
+ aqr.errors = graphQLErrors;
653
+ aqr.networkStatus = NetworkStatus.error;
654
+ }
655
+ return aqr;
656
+ }, function (networkError) {
657
+ var error = isApolloError(networkError)
658
+ ? networkError
659
+ : new ApolloError({ networkError: networkError });
660
+ if (requestId >= queryInfo.lastRequestId) {
661
+ queryInfo.markError(error);
662
+ }
663
+ throw error;
664
+ });
665
+ };
666
+ QueryManager.prototype.fetchQueryObservable = function (queryId, options, networkStatus) {
667
+ var _this = this;
668
+ if (networkStatus === void 0) { networkStatus = NetworkStatus.loading; }
669
+ var query = this.transform(options.query).document;
670
+ var variables = this.getVariables(query, options.variables);
671
+ var queryInfo = this.getQuery(queryId);
672
+ var defaults = this.defaultOptions.watchQuery;
673
+ var _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? defaults && defaults.fetchPolicy || "cache-first" : _a, _b = options.errorPolicy, errorPolicy = _b === void 0 ? defaults && defaults.errorPolicy || "none" : _b, _c = options.returnPartialData, returnPartialData = _c === void 0 ? false : _c, _d = options.notifyOnNetworkStatusChange, notifyOnNetworkStatusChange = _d === void 0 ? false : _d, _e = options.context, context = _e === void 0 ? {} : _e;
674
+ var normalized = Object.assign({}, options, {
675
+ query: query,
676
+ variables: variables,
677
+ fetchPolicy: fetchPolicy,
678
+ errorPolicy: errorPolicy,
679
+ returnPartialData: returnPartialData,
680
+ notifyOnNetworkStatusChange: notifyOnNetworkStatusChange,
681
+ context: context,
682
+ });
683
+ var fromVariables = function (variables) {
684
+ normalized.variables = variables;
685
+ var concastSources = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
686
+ if (normalized.fetchPolicy !== "standby" &&
687
+ concastSources.length > 0 &&
688
+ queryInfo.observableQuery) {
689
+ queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
690
+ }
691
+ return concastSources;
692
+ };
693
+ var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
694
+ this.fetchCancelFns.set(queryId, function (reason) {
695
+ cleanupCancelFn();
696
+ setTimeout(function () { return concast.cancel(reason); });
697
+ });
698
+ var concast = new Concast(this.transform(normalized.query).hasClientExports
699
+ ? this.localState.addExportedVariables(normalized.query, normalized.variables, normalized.context).then(fromVariables)
700
+ : fromVariables(normalized.variables));
701
+ concast.promise.then(cleanupCancelFn, cleanupCancelFn);
702
+ return concast;
703
+ };
704
+ QueryManager.prototype.refetchQueries = function (_a) {
705
+ var _this = this;
706
+ var updateCache = _a.updateCache, include = _a.include, _b = _a.optimistic, optimistic = _b === void 0 ? false : _b, _c = _a.removeOptimistic, removeOptimistic = _c === void 0 ? optimistic ? makeUniqueId("refetchQueries") : void 0 : _c, onQueryUpdated = _a.onQueryUpdated;
707
+ var includedQueriesById = new Map();
708
+ if (include) {
709
+ this.getObservableQueries(include).forEach(function (oq, queryId) {
710
+ includedQueriesById.set(queryId, {
711
+ oq: oq,
712
+ lastDiff: _this.getQuery(queryId).getDiff(),
713
+ });
714
+ });
715
+ }
716
+ var results = new Map;
717
+ if (updateCache) {
718
+ this.cache.batch({
719
+ update: updateCache,
720
+ optimistic: optimistic && removeOptimistic || false,
721
+ removeOptimistic: removeOptimistic,
722
+ onWatchUpdated: function (watch, diff, lastDiff) {
723
+ var oq = watch.watcher instanceof QueryInfo &&
724
+ watch.watcher.observableQuery;
725
+ if (oq) {
726
+ if (onQueryUpdated) {
727
+ includedQueriesById.delete(oq.queryId);
728
+ var result = onQueryUpdated(oq, diff, lastDiff);
729
+ if (result === true) {
730
+ result = oq.refetch();
731
+ }
732
+ if (result !== false) {
733
+ results.set(oq, result);
734
+ }
735
+ return result;
736
+ }
737
+ if (onQueryUpdated !== null) {
738
+ includedQueriesById.set(oq.queryId, { oq: oq, lastDiff: lastDiff, diff: diff });
739
+ }
740
+ }
741
+ },
742
+ });
743
+ }
744
+ if (includedQueriesById.size) {
745
+ includedQueriesById.forEach(function (_a, queryId) {
746
+ var oq = _a.oq, lastDiff = _a.lastDiff, diff = _a.diff;
747
+ var result;
748
+ if (onQueryUpdated) {
749
+ if (!diff) {
750
+ var info = oq["queryInfo"];
751
+ info.reset();
752
+ diff = info.getDiff();
753
+ }
754
+ result = onQueryUpdated(oq, diff, lastDiff);
755
+ }
756
+ if (!onQueryUpdated || result === true) {
757
+ result = oq.refetch();
758
+ }
759
+ if (result !== false) {
760
+ results.set(oq, result);
761
+ }
762
+ if (queryId.indexOf("legacyOneTimeQuery") >= 0) {
763
+ _this.stopQueryNoBroadcast(queryId);
764
+ }
765
+ });
766
+ }
767
+ if (removeOptimistic) {
768
+ this.cache.removeOptimistic(removeOptimistic);
769
+ }
770
+ return results;
771
+ };
772
+ QueryManager.prototype.fetchQueryByPolicy = function (queryInfo, _a, networkStatus) {
773
+ var _this = this;
774
+ var query = _a.query, variables = _a.variables, fetchPolicy = _a.fetchPolicy, refetchWritePolicy = _a.refetchWritePolicy, errorPolicy = _a.errorPolicy, returnPartialData = _a.returnPartialData, context = _a.context, notifyOnNetworkStatusChange = _a.notifyOnNetworkStatusChange;
775
+ var oldNetworkStatus = queryInfo.networkStatus;
776
+ queryInfo.init({
777
+ document: this.transform(query).document,
778
+ variables: variables,
779
+ networkStatus: networkStatus,
780
+ });
781
+ var readCache = function () { return queryInfo.getDiff(variables); };
782
+ var resultsFromCache = function (diff, networkStatus) {
783
+ if (networkStatus === void 0) { networkStatus = queryInfo.networkStatus || NetworkStatus.loading; }
784
+ var data = diff.result;
785
+ if (__DEV__ &&
786
+ !returnPartialData &&
787
+ !equal(data, {})) {
788
+ logMissingFieldErrors(diff.missing);
789
+ }
790
+ var fromData = function (data) { return Observable.of(__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true }))); };
791
+ if (data && _this.transform(query).hasForcedResolvers) {
792
+ return _this.localState.runResolvers({
793
+ document: query,
794
+ remoteResult: { data: data },
795
+ context: context,
796
+ variables: variables,
797
+ onlyRunForcedResolvers: true,
798
+ }).then(function (resolved) { return fromData(resolved.data || void 0); });
799
+ }
800
+ if (errorPolicy === 'none' &&
801
+ networkStatus === NetworkStatus.refetch &&
802
+ Array.isArray(diff.missing)) {
803
+ return fromData(void 0);
804
+ }
805
+ return fromData(data);
806
+ };
807
+ var cacheWriteBehavior = fetchPolicy === "no-cache" ? 0 :
808
+ (networkStatus === NetworkStatus.refetch &&
809
+ refetchWritePolicy !== "merge") ? 1
810
+ : 2;
811
+ var resultsFromLink = function () { return _this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
812
+ variables: variables,
813
+ context: context,
814
+ fetchPolicy: fetchPolicy,
815
+ errorPolicy: errorPolicy,
816
+ }); };
817
+ var shouldNotify = notifyOnNetworkStatusChange &&
818
+ typeof oldNetworkStatus === "number" &&
819
+ oldNetworkStatus !== networkStatus &&
820
+ isNetworkRequestInFlight(networkStatus);
821
+ switch (fetchPolicy) {
822
+ default:
823
+ case "cache-first": {
824
+ var diff = readCache();
825
+ if (diff.complete) {
826
+ return [
827
+ resultsFromCache(diff, queryInfo.markReady()),
828
+ ];
829
+ }
830
+ if (returnPartialData || shouldNotify) {
831
+ return [
832
+ resultsFromCache(diff),
833
+ resultsFromLink(),
834
+ ];
835
+ }
836
+ return [
837
+ resultsFromLink(),
838
+ ];
839
+ }
840
+ case "cache-and-network": {
841
+ var diff = readCache();
842
+ if (diff.complete || returnPartialData || shouldNotify) {
843
+ return [
844
+ resultsFromCache(diff),
845
+ resultsFromLink(),
846
+ ];
847
+ }
848
+ return [
849
+ resultsFromLink(),
850
+ ];
851
+ }
852
+ case "cache-only":
853
+ return [
854
+ resultsFromCache(readCache(), queryInfo.markReady()),
855
+ ];
856
+ case "network-only":
857
+ if (shouldNotify) {
858
+ return [
859
+ resultsFromCache(readCache()),
860
+ resultsFromLink(),
861
+ ];
862
+ }
863
+ return [resultsFromLink()];
864
+ case "no-cache":
865
+ if (shouldNotify) {
866
+ return [
867
+ resultsFromCache(queryInfo.getDiff()),
868
+ resultsFromLink(),
869
+ ];
870
+ }
871
+ return [resultsFromLink()];
872
+ case "standby":
873
+ return [];
874
+ }
875
+ };
876
+ QueryManager.prototype.getQuery = function (queryId) {
877
+ if (queryId && !this.queries.has(queryId)) {
878
+ this.queries.set(queryId, new QueryInfo(this, queryId));
879
+ }
880
+ return this.queries.get(queryId);
881
+ };
882
+ QueryManager.prototype.prepareContext = function (context) {
883
+ if (context === void 0) { context = {}; }
884
+ var newContext = this.localState.prepareContext(context);
885
+ return __assign(__assign({}, newContext), { clientAwareness: this.clientAwareness });
886
+ };
887
+ return QueryManager;
888
+ }());
889
+ export { QueryManager };
890
+ //# sourceMappingURL=QueryManager.js.map