@apollo/client 3.9.0-alpha.4 → 3.9.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (738) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/beige-geese-wink.md +5 -0
  3. package/.changeset/breezy-spiders-tap.md +38 -0
  4. package/.changeset/clean-items-smash.md +5 -0
  5. package/.changeset/cold-llamas-turn.md +8 -0
  6. package/.changeset/config.json +14 -0
  7. package/.changeset/dirty-kids-crash.md +5 -0
  8. package/.changeset/dirty-tigers-matter.md +13 -0
  9. package/.changeset/forty-cups-shop.md +5 -0
  10. package/.changeset/friendly-clouds-laugh.md +7 -0
  11. package/.changeset/hot-ducks-burn.md +5 -0
  12. package/.changeset/mighty-coats-check.md +47 -0
  13. package/.changeset/polite-avocados-warn.md +5 -0
  14. package/.changeset/pre.json +37 -0
  15. package/.changeset/quick-hats-marry.md +5 -0
  16. package/.changeset/rare-snakes-melt.md +24 -0
  17. package/.changeset/shaggy-ears-scream.md +5 -0
  18. package/.changeset/shaggy-sheep-pull.md +5 -0
  19. package/.changeset/sixty-boxes-rest.md +8 -0
  20. package/.changeset/sour-sheep-walk.md +7 -0
  21. package/.changeset/strong-terms-perform.md +46 -0
  22. package/.changeset/swift-zoos-collect.md +19 -0
  23. package/.changeset/thick-mice-collect.md +5 -0
  24. package/.changeset/thick-tips-cry.md +9 -0
  25. package/.changeset/thirty-ties-arrive.md +26 -0
  26. package/.changeset/tough-timers-begin.md +8 -0
  27. package/.changeset/unlucky-rats-decide.md +5 -0
  28. package/.changeset/violet-lions-draw.md +5 -0
  29. package/.changeset/wet-forks-rhyme.md +5 -0
  30. package/.changeset/wild-dolphins-jog.md +5 -0
  31. package/.changeset/yellow-flies-repeat.md +5 -0
  32. package/CHANGELOG.md +3649 -0
  33. package/apollo-client.cjs +775 -451
  34. package/apollo-client.cjs.map +1 -1
  35. package/apollo-client.min.cjs +1 -1
  36. package/cache/cache.cjs +210 -156
  37. package/cache/cache.cjs.map +1 -1
  38. package/cache/cache.cjs.native.js +210 -156
  39. package/cache/core/cache.d.ts +19 -0
  40. package/cache/core/cache.js +28 -7
  41. package/cache/core/cache.js.map +1 -1
  42. package/cache/core/types/Cache.d.ts +8 -1
  43. package/cache/core/types/Cache.js.map +1 -1
  44. package/cache/core/types/DataProxy.d.ts +104 -0
  45. package/cache/core/types/DataProxy.js.map +1 -1
  46. package/cache/core/types/common.d.ts +5 -1
  47. package/cache/core/types/common.js +4 -1
  48. package/cache/core/types/common.js.map +1 -1
  49. package/cache/inmemory/entityStore.d.ts +10 -1
  50. package/cache/inmemory/entityStore.js +190 -29
  51. package/cache/inmemory/entityStore.js.map +1 -1
  52. package/cache/inmemory/fixPolyfills.js +9 -0
  53. package/cache/inmemory/fixPolyfills.js.map +1 -1
  54. package/cache/inmemory/fixPolyfills.native.js +12 -0
  55. package/cache/inmemory/fixPolyfills.native.js.map +1 -1
  56. package/cache/inmemory/fragmentRegistry.d.ts +1 -0
  57. package/cache/inmemory/fragmentRegistry.js +39 -14
  58. package/cache/inmemory/fragmentRegistry.js.map +1 -1
  59. package/cache/inmemory/helpers.js +20 -11
  60. package/cache/inmemory/helpers.js.map +1 -1
  61. package/cache/inmemory/inMemoryCache.d.ts +9 -0
  62. package/cache/inmemory/inMemoryCache.js +172 -10
  63. package/cache/inmemory/inMemoryCache.js.map +1 -1
  64. package/cache/inmemory/key-extractor.js +72 -4
  65. package/cache/inmemory/key-extractor.js.map +1 -1
  66. package/cache/inmemory/object-canon.js +87 -3
  67. package/cache/inmemory/object-canon.js.map +1 -1
  68. package/cache/inmemory/policies.js +190 -43
  69. package/cache/inmemory/policies.js.map +1 -1
  70. package/cache/inmemory/reactiveVars.js +20 -2
  71. package/cache/inmemory/reactiveVars.js.map +1 -1
  72. package/cache/inmemory/readFromStore.d.ts +4 -0
  73. package/cache/inmemory/readFromStore.js +65 -12
  74. package/cache/inmemory/readFromStore.js.map +1 -1
  75. package/cache/inmemory/types.d.ts +46 -0
  76. package/cache/inmemory/types.js.map +1 -1
  77. package/cache/inmemory/writeToStore.js +152 -25
  78. package/cache/inmemory/writeToStore.js.map +1 -1
  79. package/config/jest/setup.js +2 -0
  80. package/config/jest/setup.js.map +1 -1
  81. package/core/ApolloClient.d.ts +273 -3
  82. package/core/ApolloClient.js +239 -7
  83. package/core/ApolloClient.js.map +1 -1
  84. package/core/LocalState.d.ts +4 -6
  85. package/core/LocalState.js +56 -18
  86. package/core/LocalState.js.map +1 -1
  87. package/core/ObservableQuery.d.ts +27 -0
  88. package/core/ObservableQuery.js +246 -31
  89. package/core/ObservableQuery.js.map +1 -1
  90. package/core/QueryInfo.d.ts +4 -3
  91. package/core/QueryInfo.js +122 -13
  92. package/core/QueryInfo.js.map +1 -1
  93. package/core/QueryManager.d.ts +9 -2
  94. package/core/QueryManager.js +259 -53
  95. package/core/QueryManager.js.map +1 -1
  96. package/core/core.cjs +222 -122
  97. package/core/core.cjs.map +1 -1
  98. package/core/core.cjs.native.js +222 -122
  99. package/core/equalByQuery.js +20 -1
  100. package/core/equalByQuery.js.map +1 -1
  101. package/core/index.d.ts +1 -1
  102. package/core/index.js +19 -0
  103. package/core/index.js.map +1 -1
  104. package/core/networkStatus.d.ts +39 -0
  105. package/core/networkStatus.js +39 -0
  106. package/core/networkStatus.js.map +1 -1
  107. package/core/types.d.ts +9 -0
  108. package/core/types.js.map +1 -1
  109. package/core/watchQueryOptions.d.ts +245 -2
  110. package/core/watchQueryOptions.js.map +1 -1
  111. package/dev/dev.cjs +10 -119
  112. package/dev/dev.cjs.map +1 -1
  113. package/dev/dev.cjs.native.js +10 -119
  114. package/dev/loadErrorMessageHandler.js.map +1 -1
  115. package/errors/errors.cjs +1 -1
  116. package/errors/errors.cjs.map +1 -1
  117. package/errors/errors.cjs.native.js +1 -1
  118. package/errors/index.js +14 -1
  119. package/errors/index.js.map +1 -1
  120. package/invariantErrorCodes.js +6 -8
  121. package/link/batch/batch.cjs +2 -2
  122. package/link/batch/batch.cjs.map +1 -1
  123. package/link/batch/batch.cjs.native.js +2 -2
  124. package/link/batch/batchLink.d.ts +21 -0
  125. package/link/batch/batchLink.js +2 -1
  126. package/link/batch/batchLink.js.map +1 -1
  127. package/link/batch/batching.js +24 -1
  128. package/link/batch/batching.js.map +1 -1
  129. package/link/batch-http/batch-http.cjs +3 -2
  130. package/link/batch-http/batch-http.cjs.map +1 -1
  131. package/link/batch-http/batch-http.cjs.native.js +3 -2
  132. package/link/batch-http/batchHttpLink.d.ts +4 -0
  133. package/link/batch-http/batchHttpLink.js +53 -2
  134. package/link/batch-http/batchHttpLink.js.map +1 -1
  135. package/link/context/context.cjs.map +1 -1
  136. package/link/context/index.js +1 -0
  137. package/link/context/index.js.map +1 -1
  138. package/link/core/ApolloLink.d.ts +15 -0
  139. package/link/core/ApolloLink.js +20 -9
  140. package/link/core/ApolloLink.js.map +1 -1
  141. package/link/core/core.cjs +13 -9
  142. package/link/core/core.cjs.map +1 -1
  143. package/link/core/core.cjs.native.js +13 -9
  144. package/link/error/error.cjs +1 -1
  145. package/link/error/error.cjs.map +1 -1
  146. package/link/error/error.cjs.native.js +1 -1
  147. package/link/error/index.d.ts +3 -0
  148. package/link/error/index.js +4 -1
  149. package/link/error/index.js.map +1 -1
  150. package/link/http/HttpLink.d.ts +0 -2
  151. package/link/http/HttpLink.js +1 -1
  152. package/link/http/HttpLink.js.map +1 -1
  153. package/link/http/checkFetcher.js.map +1 -1
  154. package/link/http/createHttpLink.js +23 -1
  155. package/link/http/createHttpLink.js.map +1 -1
  156. package/link/http/createSignalIfSupported.d.ts +5 -0
  157. package/link/http/createSignalIfSupported.js +5 -0
  158. package/link/http/createSignalIfSupported.js.map +1 -1
  159. package/link/http/http.cjs +14 -12
  160. package/link/http/http.cjs.map +1 -1
  161. package/link/http/http.cjs.native.js +14 -12
  162. package/link/http/index.js +2 -1
  163. package/link/http/index.js.map +1 -1
  164. package/link/http/iterators/async.d.ts +4 -0
  165. package/link/http/iterators/async.js +4 -0
  166. package/link/http/iterators/async.js.map +1 -1
  167. package/link/http/iterators/nodeStream.d.ts +4 -0
  168. package/link/http/iterators/nodeStream.js +4 -0
  169. package/link/http/iterators/nodeStream.js.map +1 -1
  170. package/link/http/iterators/promise.d.ts +4 -0
  171. package/link/http/iterators/promise.js +4 -0
  172. package/link/http/iterators/promise.js.map +1 -1
  173. package/link/http/iterators/reader.d.ts +4 -0
  174. package/link/http/iterators/reader.js +4 -0
  175. package/link/http/iterators/reader.js.map +1 -1
  176. package/link/http/parseAndCheckHttpResponse.js +51 -10
  177. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  178. package/link/http/responseIterator.d.ts +4 -0
  179. package/link/http/responseIterator.js +6 -0
  180. package/link/http/responseIterator.js.map +1 -1
  181. package/link/http/rewriteURIForGET.d.ts +1 -1
  182. package/link/http/rewriteURIForGET.js +10 -0
  183. package/link/http/rewriteURIForGET.js.map +1 -1
  184. package/link/http/selectHttpOptionsAndBody.d.ts +45 -0
  185. package/link/http/selectHttpOptionsAndBody.js +23 -0
  186. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  187. package/link/http/selectURI.js.map +1 -1
  188. package/link/http/serializeFetchParameter.js.map +1 -1
  189. package/link/persisted-queries/index.d.ts +11 -1
  190. package/link/persisted-queries/index.js +62 -7
  191. package/link/persisted-queries/index.js.map +1 -1
  192. package/link/persisted-queries/persisted-queries.cjs +30 -7
  193. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  194. package/link/persisted-queries/persisted-queries.cjs.native.js +30 -7
  195. package/link/remove-typename/remove-typename.cjs +30 -11
  196. package/link/remove-typename/remove-typename.cjs.map +1 -1
  197. package/link/remove-typename/remove-typename.cjs.native.js +30 -11
  198. package/link/remove-typename/removeTypenameFromVariables.d.ts +9 -1
  199. package/link/remove-typename/removeTypenameFromVariables.js +31 -12
  200. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  201. package/link/retry/delayFunction.d.ts +29 -0
  202. package/link/retry/delayFunction.js +6 -0
  203. package/link/retry/delayFunction.js.map +1 -1
  204. package/link/retry/retry.cjs +5 -5
  205. package/link/retry/retry.cjs.map +1 -1
  206. package/link/retry/retry.cjs.native.js +5 -5
  207. package/link/retry/retryFunction.d.ts +20 -0
  208. package/link/retry/retryLink.d.ts +6 -0
  209. package/link/retry/retryLink.js +31 -6
  210. package/link/retry/retryLink.js.map +1 -1
  211. package/link/schema/index.d.ts +13 -0
  212. package/link/schema/index.js +3 -3
  213. package/link/schema/index.js.map +1 -1
  214. package/link/schema/schema.cjs +3 -3
  215. package/link/schema/schema.cjs.map +1 -1
  216. package/link/schema/schema.cjs.native.js +3 -3
  217. package/link/subscriptions/index.js +35 -2
  218. package/link/subscriptions/index.js.map +1 -1
  219. package/link/subscriptions/subscriptions.cjs +3 -2
  220. package/link/subscriptions/subscriptions.cjs.map +1 -1
  221. package/link/subscriptions/subscriptions.cjs.native.js +3 -2
  222. package/link/utils/createOperation.js.map +1 -1
  223. package/link/utils/filterOperationVariables.js +4 -0
  224. package/link/utils/filterOperationVariables.js.map +1 -1
  225. package/link/utils/toPromise.js.map +1 -1
  226. package/link/utils/transformOperation.js +3 -2
  227. package/link/utils/transformOperation.js.map +1 -1
  228. package/link/utils/utils.cjs +2 -2
  229. package/link/utils/utils.cjs.map +1 -1
  230. package/link/utils/utils.cjs.native.js +2 -2
  231. package/link/utils/validateOperation.js.map +1 -1
  232. package/link/ws/index.d.ts +12 -0
  233. package/link/ws/index.js +1 -1
  234. package/link/ws/index.js.map +1 -1
  235. package/link/ws/ws.cjs +1 -1
  236. package/link/ws/ws.cjs.map +1 -1
  237. package/link/ws/ws.cjs.native.js +1 -1
  238. package/package.json +53 -41
  239. package/react/cache/QueryReference.d.ts +27 -13
  240. package/react/cache/QueryReference.js +122 -42
  241. package/react/cache/QueryReference.js.map +1 -1
  242. package/react/cache/SuspenseCache.d.ts +10 -0
  243. package/react/cache/SuspenseCache.js +1 -2
  244. package/react/cache/SuspenseCache.js.map +1 -1
  245. package/react/cache/getSuspenseCache.js.map +1 -1
  246. package/react/cache/types.d.ts +3 -0
  247. package/react/cache/types.js.map +1 -1
  248. package/react/context/ApolloContext.d.ts +5 -0
  249. package/react/context/ApolloContext.js +10 -3
  250. package/react/context/ApolloContext.js.map +1 -1
  251. package/react/context/context.cjs +1 -3
  252. package/react/context/context.cjs.map +1 -1
  253. package/react/context/context.cjs.native.js +1 -3
  254. package/react/hoc/graphql.js.map +1 -1
  255. package/react/hoc/hoc-utils.js +3 -1
  256. package/react/hoc/hoc-utils.js.map +1 -1
  257. package/react/hoc/hoc.cjs +9 -17
  258. package/react/hoc/hoc.cjs.map +1 -1
  259. package/react/hoc/hoc.cjs.native.js +9 -17
  260. package/react/hoc/mutation-hoc.js +9 -4
  261. package/react/hoc/mutation-hoc.js.map +1 -1
  262. package/react/hoc/query-hoc.js +10 -4
  263. package/react/hoc/query-hoc.js.map +1 -1
  264. package/react/hoc/subscription-hoc.js +10 -4
  265. package/react/hoc/subscription-hoc.js.map +1 -1
  266. package/react/hoc/withApollo.js +3 -4
  267. package/react/hoc/withApollo.js.map +1 -1
  268. package/react/hooks/hooks.cjs +230 -98
  269. package/react/hooks/hooks.cjs.map +1 -1
  270. package/react/hooks/hooks.cjs.native.js +230 -98
  271. package/react/hooks/index.d.ts +4 -0
  272. package/react/hooks/index.js +2 -0
  273. package/react/hooks/index.js.map +1 -1
  274. package/react/hooks/internal/__use.js +5 -0
  275. package/react/hooks/internal/__use.js.map +1 -1
  276. package/react/hooks/internal/index.d.ts +1 -0
  277. package/react/hooks/internal/index.js +2 -0
  278. package/react/hooks/internal/index.js.map +1 -1
  279. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  280. package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -3
  281. package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
  282. package/react/hooks/internal/useRenderGuard.d.ts +2 -0
  283. package/react/hooks/internal/useRenderGuard.js +17 -0
  284. package/react/hooks/internal/useRenderGuard.js.map +1 -0
  285. package/react/hooks/useBackgroundQuery.d.ts +12 -9
  286. package/react/hooks/useBackgroundQuery.js +14 -11
  287. package/react/hooks/useBackgroundQuery.js.map +1 -1
  288. package/react/hooks/useFragment.js +4 -3
  289. package/react/hooks/useFragment.js.map +1 -1
  290. package/react/hooks/useLazyQuery.js +13 -4
  291. package/react/hooks/useLazyQuery.js.map +1 -1
  292. package/react/hooks/useLoadableQuery.d.ts +30 -0
  293. package/react/hooks/useLoadableQuery.js +61 -0
  294. package/react/hooks/useLoadableQuery.js.map +1 -0
  295. package/react/hooks/useMutation.js +8 -3
  296. package/react/hooks/useMutation.js.map +1 -1
  297. package/react/hooks/useQuery.d.ts +11 -0
  298. package/react/hooks/useQuery.js +138 -6
  299. package/react/hooks/useQuery.js.map +1 -1
  300. package/react/hooks/useQueryRefHandlers.d.ts +35 -0
  301. package/react/hooks/useQueryRefHandlers.js +48 -0
  302. package/react/hooks/useQueryRefHandlers.js.map +1 -0
  303. package/react/hooks/useReactiveVar.js +5 -0
  304. package/react/hooks/useReactiveVar.js.map +1 -1
  305. package/react/hooks/useReadQuery.d.ts +19 -0
  306. package/react/hooks/useReadQuery.js +9 -9
  307. package/react/hooks/useReadQuery.js.map +1 -1
  308. package/react/hooks/useSubscription.js +5 -0
  309. package/react/hooks/useSubscription.js.map +1 -1
  310. package/react/hooks/useSuspenseQuery.js +22 -22
  311. package/react/hooks/useSuspenseQuery.js.map +1 -1
  312. package/react/hooks/useSyncExternalStore.js +53 -1
  313. package/react/hooks/useSyncExternalStore.js.map +1 -1
  314. package/react/index.d.ts +2 -0
  315. package/react/index.js +1 -0
  316. package/react/index.js.map +1 -1
  317. package/react/parser/index.d.ts +3 -0
  318. package/react/parser/index.js +16 -6
  319. package/react/parser/index.js.map +1 -1
  320. package/react/parser/parser.cjs +19 -5
  321. package/react/parser/parser.cjs.map +1 -1
  322. package/react/parser/parser.cjs.native.js +19 -5
  323. package/react/query-preloader/createQueryPreloader.d.ts +253 -0
  324. package/react/query-preloader/createQueryPreloader.js +29 -0
  325. package/react/query-preloader/createQueryPreloader.js.map +1 -0
  326. package/react/react.cjs +248 -1
  327. package/react/react.cjs.map +1 -1
  328. package/react/react.cjs.native.js +248 -1
  329. package/react/ssr/RenderPromises.js +21 -1
  330. package/react/ssr/RenderPromises.js.map +1 -1
  331. package/react/ssr/getDataFromTree.js +18 -3
  332. package/react/ssr/getDataFromTree.js.map +1 -1
  333. package/react/ssr/ssr.cjs +6 -4
  334. package/react/ssr/ssr.cjs.map +1 -1
  335. package/react/ssr/ssr.cjs.native.js +6 -4
  336. package/react/types/types.d.ts +129 -1
  337. package/react/types/types.js.map +1 -1
  338. package/testing/core/core.cjs +14 -11
  339. package/testing/core/core.cjs.map +1 -1
  340. package/testing/core/core.cjs.native.js +14 -11
  341. package/testing/core/itAsync.d.ts +1 -1
  342. package/testing/core/itAsync.js.map +1 -1
  343. package/testing/core/mocking/mockFetch.d.ts +2 -2
  344. package/testing/core/mocking/mockFetch.js +8 -4
  345. package/testing/core/mocking/mockFetch.js.map +1 -1
  346. package/testing/core/mocking/mockLink.d.ts +1 -1
  347. package/testing/core/mocking/mockLink.js +17 -7
  348. package/testing/core/mocking/mockLink.js.map +1 -1
  349. package/testing/core/mocking/mockQueryManager.js +2 -0
  350. package/testing/core/mocking/mockQueryManager.js.map +1 -1
  351. package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
  352. package/testing/core/mocking/mockSubscriptionLink.js +1 -1
  353. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  354. package/testing/core/mocking/mockWatchQuery.js +1 -1
  355. package/testing/core/mocking/mockWatchQuery.js.map +1 -1
  356. package/testing/core/observableToPromise.d.ts +17 -3
  357. package/testing/core/observableToPromise.js +5 -0
  358. package/testing/core/observableToPromise.js.map +1 -1
  359. package/testing/core/subscribeAndCount.js +3 -0
  360. package/testing/core/subscribeAndCount.js.map +1 -1
  361. package/testing/core/wait.js +2 -2
  362. package/testing/core/wait.js.map +1 -1
  363. package/testing/core/withConsoleSpy.d.ts +3 -0
  364. package/testing/core/withConsoleSpy.js +7 -1
  365. package/testing/core/withConsoleSpy.js.map +1 -1
  366. package/testing/core/wrap.js +2 -0
  367. package/testing/core/wrap.js.map +1 -1
  368. package/testing/internal/ObservableStream.js +14 -14
  369. package/testing/internal/ObservableStream.js.map +1 -1
  370. package/testing/internal/disposables/disableActWarnings.d.ts +10 -0
  371. package/testing/internal/disposables/disableActWarnings.js +15 -0
  372. package/testing/internal/disposables/disableActWarnings.js.map +1 -0
  373. package/testing/internal/disposables/index.d.ts +1 -0
  374. package/testing/internal/disposables/index.js +1 -0
  375. package/testing/internal/disposables/index.js.map +1 -1
  376. package/testing/internal/disposables/spyOnConsole.d.ts +1 -0
  377. package/testing/internal/disposables/spyOnConsole.js +2 -0
  378. package/testing/internal/disposables/spyOnConsole.js.map +1 -1
  379. package/testing/internal/disposables/withCleanup.d.ts +1 -0
  380. package/testing/internal/disposables/withCleanup.js +3 -0
  381. package/testing/internal/disposables/withCleanup.js.map +1 -1
  382. package/testing/internal/index.d.ts +4 -0
  383. package/testing/internal/index.js +2 -0
  384. package/testing/internal/index.js.map +1 -1
  385. package/testing/internal/profile/Render.d.ts +32 -1
  386. package/testing/internal/profile/Render.js +14 -2
  387. package/testing/internal/profile/Render.js.map +1 -1
  388. package/testing/internal/profile/context.d.ts +10 -0
  389. package/testing/internal/profile/context.js +14 -0
  390. package/testing/internal/profile/context.js.map +1 -0
  391. package/testing/internal/profile/index.d.ts +2 -2
  392. package/testing/internal/profile/index.js +1 -1
  393. package/testing/internal/profile/index.js.map +1 -1
  394. package/testing/internal/profile/profile.d.ts +67 -13
  395. package/testing/internal/profile/profile.js +153 -79
  396. package/testing/internal/profile/profile.js.map +1 -1
  397. package/testing/internal/profile/traces.d.ts +4 -0
  398. package/testing/internal/profile/traces.js +9 -5
  399. package/testing/internal/profile/traces.js.map +1 -1
  400. package/testing/internal/renderHelpers.d.ts +12 -0
  401. package/testing/internal/renderHelpers.js +22 -0
  402. package/testing/internal/renderHelpers.js.map +1 -0
  403. package/testing/internal/scenarios/index.d.ts +41 -0
  404. package/testing/internal/scenarios/index.js +46 -0
  405. package/testing/internal/scenarios/index.js.map +1 -0
  406. package/testing/matchers/ProfiledComponent.js +29 -26
  407. package/testing/matchers/ProfiledComponent.js.map +1 -1
  408. package/testing/matchers/index.js +4 -0
  409. package/testing/matchers/index.js.map +1 -1
  410. package/testing/matchers/toBeDisposed.d.ts +3 -0
  411. package/testing/matchers/toBeDisposed.js +26 -0
  412. package/testing/matchers/toBeDisposed.js.map +1 -0
  413. package/testing/matchers/toBeGarbageCollected.d.ts +8 -0
  414. package/testing/matchers/toBeGarbageCollected.js +48 -0
  415. package/testing/matchers/toBeGarbageCollected.js.map +1 -0
  416. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
  417. package/testing/matchers/toMatchDocument.js.map +1 -1
  418. package/testing/react/MockedProvider.d.ts +5 -1
  419. package/testing/react/MockedProvider.js +6 -2
  420. package/testing/react/MockedProvider.js.map +1 -1
  421. package/testing/testing.cjs +4 -2
  422. package/testing/testing.cjs.map +1 -1
  423. package/testing/testing.cjs.native.js +4 -2
  424. package/utilities/caching/caches.d.ts +34 -0
  425. package/utilities/caching/caches.js +64 -0
  426. package/utilities/caching/caches.js.map +1 -0
  427. package/utilities/caching/getMemoryInternals.d.ts +76 -0
  428. package/utilities/caching/getMemoryInternals.js +112 -0
  429. package/utilities/caching/getMemoryInternals.js.map +1 -0
  430. package/utilities/caching/index.d.ts +4 -0
  431. package/utilities/caching/index.js +3 -0
  432. package/utilities/caching/index.js.map +1 -0
  433. package/utilities/caching/sizes.d.ts +261 -0
  434. package/utilities/caching/sizes.js +27 -0
  435. package/utilities/caching/sizes.js.map +1 -0
  436. package/utilities/common/arrays.js +1 -0
  437. package/utilities/common/arrays.js.map +1 -1
  438. package/utilities/common/canUse.js +17 -2
  439. package/utilities/common/canUse.js.map +1 -1
  440. package/utilities/common/canonicalStringify.d.ts +17 -0
  441. package/utilities/common/canonicalStringify.js +49 -2
  442. package/utilities/common/canonicalStringify.js.map +1 -1
  443. package/utilities/common/cloneDeep.d.ts +3 -0
  444. package/utilities/common/cloneDeep.js +5 -0
  445. package/utilities/common/cloneDeep.js.map +1 -1
  446. package/utilities/common/compact.d.ts +4 -0
  447. package/utilities/common/compact.js +4 -0
  448. package/utilities/common/compact.js.map +1 -1
  449. package/utilities/common/errorHandling.js +1 -3
  450. package/utilities/common/errorHandling.js.map +1 -1
  451. package/utilities/common/incrementalResult.js +3 -0
  452. package/utilities/common/incrementalResult.js.map +1 -1
  453. package/utilities/common/makeUniqueId.js +2 -0
  454. package/utilities/common/makeUniqueId.js.map +1 -1
  455. package/utilities/common/maybeDeepFreeze.js +3 -0
  456. package/utilities/common/maybeDeepFreeze.js.map +1 -1
  457. package/utilities/common/mergeDeep.js +12 -1
  458. package/utilities/common/mergeDeep.js.map +1 -1
  459. package/utilities/common/mergeOptions.d.ts +1 -1
  460. package/utilities/common/mergeOptions.js.map +1 -1
  461. package/utilities/common/omitDeep.js.map +1 -1
  462. package/utilities/globals/global.js +7 -1
  463. package/utilities/globals/global.js.map +1 -1
  464. package/utilities/globals/globals.cjs +4 -5
  465. package/utilities/globals/globals.cjs.map +1 -1
  466. package/utilities/globals/globals.cjs.native.js +4 -5
  467. package/utilities/globals/index.d.ts +4 -0
  468. package/utilities/globals/index.js +7 -0
  469. package/utilities/globals/index.js.map +1 -1
  470. package/utilities/globals/invariantWrappers.d.ts +40 -0
  471. package/utilities/globals/invariantWrappers.js +11 -3
  472. package/utilities/globals/invariantWrappers.js.map +1 -1
  473. package/utilities/globals/maybe.js.map +1 -1
  474. package/utilities/graphql/DocumentTransform.d.ts +20 -6
  475. package/utilities/graphql/DocumentTransform.js +54 -29
  476. package/utilities/graphql/DocumentTransform.js.map +1 -1
  477. package/utilities/graphql/directives.js +3 -0
  478. package/utilities/graphql/directives.js.map +1 -1
  479. package/utilities/graphql/fragments.d.ts +25 -0
  480. package/utilities/graphql/fragments.js +36 -0
  481. package/utilities/graphql/fragments.js.map +1 -1
  482. package/utilities/graphql/getFromAST.d.ts +5 -0
  483. package/utilities/graphql/getFromAST.js +9 -0
  484. package/utilities/graphql/getFromAST.js.map +1 -1
  485. package/utilities/graphql/print.js +8 -5
  486. package/utilities/graphql/print.js.map +1 -1
  487. package/utilities/graphql/storeUtils.d.ts +14 -0
  488. package/utilities/graphql/storeUtils.js +8 -2
  489. package/utilities/graphql/storeUtils.js.map +1 -1
  490. package/utilities/graphql/transform.js +106 -7
  491. package/utilities/graphql/transform.js.map +1 -1
  492. package/utilities/index.d.ts +4 -0
  493. package/utilities/index.js +1 -0
  494. package/utilities/index.js.map +1 -1
  495. package/utilities/observables/Concast.d.ts +1 -1
  496. package/utilities/observables/Concast.js +85 -2
  497. package/utilities/observables/Concast.js.map +1 -1
  498. package/utilities/observables/Observable.js +6 -0
  499. package/utilities/observables/Observable.js.map +1 -1
  500. package/utilities/observables/asyncMap.js +12 -3
  501. package/utilities/observables/asyncMap.js.map +1 -1
  502. package/utilities/observables/iteration.js +3 -0
  503. package/utilities/observables/iteration.js.map +1 -1
  504. package/utilities/observables/subclassing.js +14 -0
  505. package/utilities/observables/subclassing.js.map +1 -1
  506. package/utilities/policies/pagination.js +47 -3
  507. package/utilities/policies/pagination.js.map +1 -1
  508. package/utilities/promises/decoration.js +1 -0
  509. package/utilities/promises/decoration.js.map +1 -1
  510. package/utilities/subscriptions/relay/index.js.map +1 -1
  511. package/utilities/subscriptions/relay/relay.cjs +9 -8
  512. package/utilities/subscriptions/relay/relay.cjs.map +1 -1
  513. package/utilities/subscriptions/relay/relay.cjs.native.js +9 -8
  514. package/utilities/subscriptions/urql/index.js.map +1 -1
  515. package/utilities/subscriptions/urql/urql.cjs +9 -8
  516. package/utilities/subscriptions/urql/urql.cjs.map +1 -1
  517. package/utilities/subscriptions/urql/urql.cjs.native.js +9 -8
  518. package/utilities/types/DeepOmit.js.map +1 -1
  519. package/utilities/types/DeepPartial.d.ts +1 -1
  520. package/utilities/types/DeepPartial.js +4 -0
  521. package/utilities/types/DeepPartial.js.map +1 -1
  522. package/utilities/types/IsStrictlyAny.js.map +1 -1
  523. package/utilities/types/OnlyRequiredProperties.d.ts +7 -0
  524. package/utilities/types/OnlyRequiredProperties.js +2 -0
  525. package/utilities/types/OnlyRequiredProperties.js.map +1 -0
  526. package/utilities/types/TODO.d.ts +3 -0
  527. package/utilities/types/TODO.js +2 -0
  528. package/utilities/types/TODO.js.map +1 -0
  529. package/utilities/utilities.cjs +114 -58
  530. package/utilities/utilities.cjs.map +1 -1
  531. package/utilities/utilities.cjs.native.js +114 -58
  532. package/version.js +1 -1
  533. package/cache/core/cache.d.ts.map +0 -1
  534. package/cache/core/types/Cache.d.ts.map +0 -1
  535. package/cache/core/types/DataProxy.d.ts.map +0 -1
  536. package/cache/core/types/common.d.ts.map +0 -1
  537. package/cache/index.d.ts.map +0 -1
  538. package/cache/inmemory/entityStore.d.ts.map +0 -1
  539. package/cache/inmemory/fixPolyfills.d.ts.map +0 -1
  540. package/cache/inmemory/fixPolyfills.native.d.ts.map +0 -1
  541. package/cache/inmemory/fragmentRegistry.d.ts.map +0 -1
  542. package/cache/inmemory/helpers.d.ts.map +0 -1
  543. package/cache/inmemory/inMemoryCache.d.ts.map +0 -1
  544. package/cache/inmemory/key-extractor.d.ts.map +0 -1
  545. package/cache/inmemory/object-canon.d.ts.map +0 -1
  546. package/cache/inmemory/policies.d.ts.map +0 -1
  547. package/cache/inmemory/reactiveVars.d.ts.map +0 -1
  548. package/cache/inmemory/readFromStore.d.ts.map +0 -1
  549. package/cache/inmemory/types.d.ts.map +0 -1
  550. package/cache/inmemory/writeToStore.d.ts.map +0 -1
  551. package/config/jest/setup.d.ts.map +0 -1
  552. package/core/ApolloClient.d.ts.map +0 -1
  553. package/core/LocalState.d.ts.map +0 -1
  554. package/core/ObservableQuery.d.ts.map +0 -1
  555. package/core/QueryInfo.d.ts.map +0 -1
  556. package/core/QueryManager.d.ts.map +0 -1
  557. package/core/equalByQuery.d.ts.map +0 -1
  558. package/core/index.d.ts.map +0 -1
  559. package/core/networkStatus.d.ts.map +0 -1
  560. package/core/types.d.ts.map +0 -1
  561. package/core/watchQueryOptions.d.ts.map +0 -1
  562. package/dev/index.d.ts.map +0 -1
  563. package/dev/loadDevMessages.d.ts.map +0 -1
  564. package/dev/loadErrorMessageHandler.d.ts.map +0 -1
  565. package/dev/loadErrorMessages.d.ts.map +0 -1
  566. package/errors/index.d.ts.map +0 -1
  567. package/index.d.ts.map +0 -1
  568. package/invariantErrorCodes.d.ts.map +0 -1
  569. package/link/batch/batchLink.d.ts.map +0 -1
  570. package/link/batch/batching.d.ts.map +0 -1
  571. package/link/batch/index.d.ts.map +0 -1
  572. package/link/batch-http/batchHttpLink.d.ts.map +0 -1
  573. package/link/batch-http/index.d.ts.map +0 -1
  574. package/link/context/index.d.ts.map +0 -1
  575. package/link/core/ApolloLink.d.ts.map +0 -1
  576. package/link/core/concat.d.ts.map +0 -1
  577. package/link/core/empty.d.ts.map +0 -1
  578. package/link/core/execute.d.ts.map +0 -1
  579. package/link/core/from.d.ts.map +0 -1
  580. package/link/core/index.d.ts.map +0 -1
  581. package/link/core/split.d.ts.map +0 -1
  582. package/link/core/types.d.ts.map +0 -1
  583. package/link/error/index.d.ts.map +0 -1
  584. package/link/http/HttpLink.d.ts.map +0 -1
  585. package/link/http/checkFetcher.d.ts.map +0 -1
  586. package/link/http/createHttpLink.d.ts.map +0 -1
  587. package/link/http/createSignalIfSupported.d.ts.map +0 -1
  588. package/link/http/index.d.ts.map +0 -1
  589. package/link/http/iterators/async.d.ts.map +0 -1
  590. package/link/http/iterators/nodeStream.d.ts.map +0 -1
  591. package/link/http/iterators/promise.d.ts.map +0 -1
  592. package/link/http/iterators/reader.d.ts.map +0 -1
  593. package/link/http/parseAndCheckHttpResponse.d.ts.map +0 -1
  594. package/link/http/responseIterator.d.ts.map +0 -1
  595. package/link/http/rewriteURIForGET.d.ts.map +0 -1
  596. package/link/http/selectHttpOptionsAndBody.d.ts.map +0 -1
  597. package/link/http/selectURI.d.ts.map +0 -1
  598. package/link/http/serializeFetchParameter.d.ts.map +0 -1
  599. package/link/persisted-queries/index.d.ts.map +0 -1
  600. package/link/remove-typename/index.d.ts.map +0 -1
  601. package/link/remove-typename/removeTypenameFromVariables.d.ts.map +0 -1
  602. package/link/retry/delayFunction.d.ts.map +0 -1
  603. package/link/retry/index.d.ts.map +0 -1
  604. package/link/retry/retryFunction.d.ts.map +0 -1
  605. package/link/retry/retryLink.d.ts.map +0 -1
  606. package/link/schema/index.d.ts.map +0 -1
  607. package/link/subscriptions/index.d.ts.map +0 -1
  608. package/link/utils/createOperation.d.ts.map +0 -1
  609. package/link/utils/filterOperationVariables.d.ts.map +0 -1
  610. package/link/utils/fromError.d.ts.map +0 -1
  611. package/link/utils/fromPromise.d.ts.map +0 -1
  612. package/link/utils/index.d.ts.map +0 -1
  613. package/link/utils/throwServerError.d.ts.map +0 -1
  614. package/link/utils/toPromise.d.ts.map +0 -1
  615. package/link/utils/transformOperation.d.ts.map +0 -1
  616. package/link/utils/validateOperation.d.ts.map +0 -1
  617. package/link/ws/index.d.ts.map +0 -1
  618. package/react/cache/QueryReference.d.ts.map +0 -1
  619. package/react/cache/SuspenseCache.d.ts.map +0 -1
  620. package/react/cache/getSuspenseCache.d.ts.map +0 -1
  621. package/react/cache/index.d.ts.map +0 -1
  622. package/react/cache/types.d.ts.map +0 -1
  623. package/react/components/Mutation.d.ts.map +0 -1
  624. package/react/components/Query.d.ts.map +0 -1
  625. package/react/components/Subscription.d.ts.map +0 -1
  626. package/react/components/index.d.ts.map +0 -1
  627. package/react/components/types.d.ts.map +0 -1
  628. package/react/context/ApolloConsumer.d.ts.map +0 -1
  629. package/react/context/ApolloContext.d.ts.map +0 -1
  630. package/react/context/ApolloProvider.d.ts.map +0 -1
  631. package/react/context/index.d.ts.map +0 -1
  632. package/react/hoc/graphql.d.ts.map +0 -1
  633. package/react/hoc/hoc-utils.d.ts.map +0 -1
  634. package/react/hoc/index.d.ts.map +0 -1
  635. package/react/hoc/mutation-hoc.d.ts.map +0 -1
  636. package/react/hoc/query-hoc.d.ts.map +0 -1
  637. package/react/hoc/subscription-hoc.d.ts.map +0 -1
  638. package/react/hoc/types.d.ts.map +0 -1
  639. package/react/hoc/withApollo.d.ts.map +0 -1
  640. package/react/hooks/constants.d.ts.map +0 -1
  641. package/react/hooks/index.d.ts.map +0 -1
  642. package/react/hooks/internal/__use.d.ts.map +0 -1
  643. package/react/hooks/internal/index.d.ts.map +0 -1
  644. package/react/hooks/internal/useDeepMemo.d.ts.map +0 -1
  645. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +0 -1
  646. package/react/hooks/useApolloClient.d.ts.map +0 -1
  647. package/react/hooks/useBackgroundQuery.d.ts.map +0 -1
  648. package/react/hooks/useFragment.d.ts.map +0 -1
  649. package/react/hooks/useLazyQuery.d.ts.map +0 -1
  650. package/react/hooks/useMutation.d.ts.map +0 -1
  651. package/react/hooks/useQuery.d.ts.map +0 -1
  652. package/react/hooks/useReactiveVar.d.ts.map +0 -1
  653. package/react/hooks/useReadQuery.d.ts.map +0 -1
  654. package/react/hooks/useSubscription.d.ts.map +0 -1
  655. package/react/hooks/useSuspenseQuery.d.ts.map +0 -1
  656. package/react/hooks/useSyncExternalStore.d.ts.map +0 -1
  657. package/react/index.d.ts.map +0 -1
  658. package/react/parser/index.d.ts.map +0 -1
  659. package/react/ssr/RenderPromises.d.ts.map +0 -1
  660. package/react/ssr/getDataFromTree.d.ts.map +0 -1
  661. package/react/ssr/index.d.ts.map +0 -1
  662. package/react/ssr/renderToStringWithData.d.ts.map +0 -1
  663. package/react/types/types.d.ts.map +0 -1
  664. package/testing/core/index.d.ts.map +0 -1
  665. package/testing/core/itAsync.d.ts.map +0 -1
  666. package/testing/core/mocking/mockClient.d.ts.map +0 -1
  667. package/testing/core/mocking/mockFetch.d.ts.map +0 -1
  668. package/testing/core/mocking/mockLink.d.ts.map +0 -1
  669. package/testing/core/mocking/mockQueryManager.d.ts.map +0 -1
  670. package/testing/core/mocking/mockSubscriptionLink.d.ts.map +0 -1
  671. package/testing/core/mocking/mockWatchQuery.d.ts.map +0 -1
  672. package/testing/core/observableToPromise.d.ts.map +0 -1
  673. package/testing/core/subscribeAndCount.d.ts.map +0 -1
  674. package/testing/core/wait.d.ts.map +0 -1
  675. package/testing/core/withConsoleSpy.d.ts.map +0 -1
  676. package/testing/core/wrap.d.ts.map +0 -1
  677. package/testing/index.d.ts.map +0 -1
  678. package/testing/internal/ObservableStream.d.ts.map +0 -1
  679. package/testing/internal/disposables/index.d.ts.map +0 -1
  680. package/testing/internal/disposables/spyOnConsole.d.ts.map +0 -1
  681. package/testing/internal/disposables/withCleanup.d.ts.map +0 -1
  682. package/testing/internal/index.d.ts.map +0 -1
  683. package/testing/internal/profile/Render.d.ts.map +0 -1
  684. package/testing/internal/profile/index.d.ts.map +0 -1
  685. package/testing/internal/profile/profile.d.ts.map +0 -1
  686. package/testing/internal/profile/traces.d.ts.map +0 -1
  687. package/testing/matchers/ProfiledComponent.d.ts.map +0 -1
  688. package/testing/matchers/index.d.ts.map +0 -1
  689. package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts.map +0 -1
  690. package/testing/matchers/toMatchDocument.d.ts.map +0 -1
  691. package/testing/react/MockedProvider.d.ts.map +0 -1
  692. package/utilities/common/arrays.d.ts.map +0 -1
  693. package/utilities/common/canUse.d.ts.map +0 -1
  694. package/utilities/common/canonicalStringify.d.ts.map +0 -1
  695. package/utilities/common/cloneDeep.d.ts.map +0 -1
  696. package/utilities/common/compact.d.ts.map +0 -1
  697. package/utilities/common/errorHandling.d.ts.map +0 -1
  698. package/utilities/common/filterInPlace.d.ts +0 -2
  699. package/utilities/common/filterInPlace.d.ts.map +0 -1
  700. package/utilities/common/filterInPlace.js +0 -11
  701. package/utilities/common/filterInPlace.js.map +0 -1
  702. package/utilities/common/incrementalResult.d.ts.map +0 -1
  703. package/utilities/common/makeUniqueId.d.ts.map +0 -1
  704. package/utilities/common/maybeDeepFreeze.d.ts.map +0 -1
  705. package/utilities/common/mergeDeep.d.ts.map +0 -1
  706. package/utilities/common/mergeOptions.d.ts.map +0 -1
  707. package/utilities/common/objects.d.ts.map +0 -1
  708. package/utilities/common/omitDeep.d.ts.map +0 -1
  709. package/utilities/common/stringifyForDisplay.d.ts.map +0 -1
  710. package/utilities/common/stripTypename.d.ts.map +0 -1
  711. package/utilities/globals/global.d.ts.map +0 -1
  712. package/utilities/globals/index.d.ts.map +0 -1
  713. package/utilities/globals/invariantWrappers.d.ts.map +0 -1
  714. package/utilities/globals/maybe.d.ts.map +0 -1
  715. package/utilities/graphql/DocumentTransform.d.ts.map +0 -1
  716. package/utilities/graphql/directives.d.ts.map +0 -1
  717. package/utilities/graphql/fragments.d.ts.map +0 -1
  718. package/utilities/graphql/getFromAST.d.ts.map +0 -1
  719. package/utilities/graphql/operations.d.ts.map +0 -1
  720. package/utilities/graphql/print.d.ts.map +0 -1
  721. package/utilities/graphql/storeUtils.d.ts.map +0 -1
  722. package/utilities/graphql/transform.d.ts.map +0 -1
  723. package/utilities/index.d.ts.map +0 -1
  724. package/utilities/observables/Concast.d.ts.map +0 -1
  725. package/utilities/observables/Observable.d.ts.map +0 -1
  726. package/utilities/observables/asyncMap.d.ts.map +0 -1
  727. package/utilities/observables/iteration.d.ts.map +0 -1
  728. package/utilities/observables/subclassing.d.ts.map +0 -1
  729. package/utilities/policies/pagination.d.ts.map +0 -1
  730. package/utilities/promises/decoration.d.ts.map +0 -1
  731. package/utilities/subscriptions/relay/index.d.ts.map +0 -1
  732. package/utilities/subscriptions/shared.d.ts.map +0 -1
  733. package/utilities/subscriptions/urql/index.d.ts.map +0 -1
  734. package/utilities/types/DeepOmit.d.ts.map +0 -1
  735. package/utilities/types/DeepPartial.d.ts.map +0 -1
  736. package/utilities/types/IsStrictlyAny.d.ts.map +0 -1
  737. package/utilities/types/Primitive.d.ts.map +0 -1
  738. package/version.d.ts.map +0 -1
@@ -4,28 +4,166 @@ import type { FetchResult } from "../link/core/index.js";
4
4
  import type { DefaultContext, MutationQueryReducersMap, OperationVariables, MutationUpdaterFunction, OnQueryUpdated, InternalRefetchQueriesInclude } from "./types.js";
5
5
  import type { ApolloCache } from "../cache/index.js";
6
6
  import type { ObservableQuery } from "./ObservableQuery.js";
7
+ import type { IgnoreModifier } from "../cache/core/types/common.js";
8
+ /**
9
+ * fetchPolicy determines where the client may return a result from. The options are:
10
+ * - cache-first (default): return result from cache. Only fetch from network if cached result is not available.
11
+ * - cache-and-network: return result from cache first (if it exists), then return network result once it's available.
12
+ * - cache-only: return result from cache if available, fail otherwise.
13
+ * - no-cache: return result from network, fail if network call doesn't succeed, don't save to cache
14
+ * - network-only: return result from network, fail if network call doesn't succeed, save to cache
15
+ * - standby: only for queries that aren't actively watched, but should be available for refetch and updateQueries.
16
+ */
7
17
  export type FetchPolicy = "cache-first" | "network-only" | "cache-only" | "no-cache" | "standby";
8
18
  export type WatchQueryFetchPolicy = FetchPolicy | "cache-and-network";
9
19
  export type MutationFetchPolicy = Extract<FetchPolicy, "network-only" | "no-cache">;
10
20
  export type RefetchWritePolicy = "merge" | "overwrite";
21
+ /**
22
+ * errorPolicy determines the level of events for errors in the execution result. The options are:
23
+ * - none (default): any errors from the request are treated like runtime errors and the observable is stopped
24
+ * - ignore: errors from the request do not stop the observable, but also don't call `next`
25
+ * - all: errors are treated like data and will notify observables
26
+ */
11
27
  export type ErrorPolicy = "none" | "ignore" | "all";
28
+ /**
29
+ * Query options.
30
+ */
12
31
  export interface QueryOptions<TVariables = OperationVariables, TData = any> {
32
+ /**
33
+ * A GraphQL document that consists of a single query to be sent down to the
34
+ * server.
35
+ */
13
36
  query: DocumentNode | TypedDocumentNode<TData, TVariables>;
37
+ /**
38
+ * A map going from variable name to variable value, where the variables are used
39
+ * within the GraphQL query.
40
+ */
14
41
  variables?: TVariables;
42
+ /**
43
+ * Specifies the {@link ErrorPolicy} to be used for this query
44
+ */
15
45
  errorPolicy?: ErrorPolicy;
46
+ /**
47
+ * Context to be passed to link execution chain
48
+ */
16
49
  context?: DefaultContext;
50
+ /**
51
+ * Specifies the {@link FetchPolicy} to be used for this query
52
+ */
17
53
  fetchPolicy?: FetchPolicy;
54
+ /**
55
+ * The time interval (in milliseconds) on which this query should be
56
+ * refetched from the server.
57
+ */
18
58
  pollInterval?: number;
59
+ /**
60
+ * Whether or not updates to the network status should trigger next on the observer of this query
61
+ */
19
62
  notifyOnNetworkStatusChange?: boolean;
63
+ /**
64
+ * Allow returning incomplete data from the cache when a larger query cannot
65
+ * be fully satisfied by the cache, instead of returning nothing.
66
+ */
20
67
  returnPartialData?: boolean;
68
+ /**
69
+ * If `true`, perform a query `refetch` if the query result is marked as
70
+ * being partial, and the returned data is reset to an empty Object by the
71
+ * Apollo Client `QueryManager` (due to a cache miss).
72
+ */
21
73
  partialRefetch?: boolean;
74
+ /**
75
+ * @deprecated
76
+ * Using `canonizeResults` can result in memory leaks so we generally do not
77
+ * recommend using this option anymore.
78
+ * A future version of Apollo Client will contain a similar feature without
79
+ * the risk of memory leaks.
80
+ *
81
+ * Whether to canonize cache results before returning them. Canonization
82
+ * takes some extra time, but it speeds up future deep equality comparisons.
83
+ * Defaults to false.
84
+ */
22
85
  canonizeResults?: boolean;
23
86
  }
24
- export interface WatchQueryOptions<TVariables extends OperationVariables = OperationVariables, TData = any> extends Omit<QueryOptions<TVariables, TData>, "fetchPolicy"> {
87
+ /**
88
+ * Watched query options.
89
+ */
90
+ export interface WatchQueryOptions<TVariables extends OperationVariables = OperationVariables, TData = any> {
91
+ /**
92
+ * Specifies the {@link FetchPolicy} to be used for this query.
93
+ */
25
94
  fetchPolicy?: WatchQueryFetchPolicy;
95
+ /**
96
+ * Specifies the {@link FetchPolicy} to be used after this query has completed.
97
+ */
26
98
  nextFetchPolicy?: WatchQueryFetchPolicy | ((this: WatchQueryOptions<TVariables, TData>, currentFetchPolicy: WatchQueryFetchPolicy, context: NextFetchPolicyContext<TData, TVariables>) => WatchQueryFetchPolicy);
99
+ /**
100
+ * Defaults to the initial value of options.fetchPolicy, but can be explicitly
101
+ * configured to specify the WatchQueryFetchPolicy to revert back to whenever
102
+ * variables change (unless nextFetchPolicy intervenes).
103
+ */
27
104
  initialFetchPolicy?: WatchQueryFetchPolicy;
105
+ /**
106
+ * Specifies whether a {@link NetworkStatus.refetch} operation should merge
107
+ * incoming field data with existing data, or overwrite the existing data.
108
+ * Overwriting is probably preferable, but merging is currently the default
109
+ * behavior, for backwards compatibility with Apollo Client 3.x.
110
+ */
28
111
  refetchWritePolicy?: RefetchWritePolicy;
112
+ /**
113
+ * A GraphQL document that consists of a single query to be sent down to the server.
114
+ */
115
+
116
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>;
117
+ /**
118
+ * A map going from variable name to variable value, where the variables are used within the GraphQL query.
119
+ */
120
+
121
+ variables?: TVariables;
122
+ /**
123
+ * Specifies the {@link ErrorPolicy} to be used for this query
124
+ */
125
+
126
+ errorPolicy?: ErrorPolicy;
127
+ /**
128
+ * Context to be passed to link execution chain
129
+ */
130
+
131
+ context?: DefaultContext;
132
+ /**
133
+ * The time interval (in milliseconds) on which this query should be refetched from the server.
134
+ */
135
+
136
+ pollInterval?: number;
137
+ /**
138
+ * Whether or not updates to the network status should trigger next on the observer of this query
139
+ */
140
+
141
+ notifyOnNetworkStatusChange?: boolean;
142
+ /**
143
+ * Allow returning incomplete data from the cache when a larger query cannot be fully satisfied by the cache, instead of returning nothing.
144
+ */
145
+
146
+ returnPartialData?: boolean;
147
+ /**
148
+ * If `true`, perform a query `refetch` if the query result is marked as being partial, and the returned data is reset to an empty Object by the Apollo Client `QueryManager` (due to a cache miss).
149
+ */
150
+
151
+ partialRefetch?: boolean;
152
+ /**
153
+ * @deprecated
154
+ *
155
+ * Using `canonizeResults` can result in memory leaks so we generally do not recommend using this option anymore. A future version of Apollo Client will contain a similar feature without the risk of memory leaks.
156
+ *
157
+ * Whether to canonize cache results before returning them. Canonization takes some extra time, but it speeds up future deep equality comparisons. Defaults to false.
158
+ */
159
+
160
+ canonizeResults?: boolean;
161
+ /**
162
+ * A callback function that's called whenever a refetch attempt occurs
163
+ * while polling. If the function returns `true`, the refetch is
164
+ * skipped and not reattempted until the next poll interval.
165
+ */
166
+ skipPollAttempt?: () => boolean;
29
167
  }
30
168
  export interface NextFetchPolicyContext<TData, TVariables extends OperationVariables> {
31
169
  reason: "after-fetch" | "variables-changed";
@@ -52,26 +190,131 @@ export type SubscribeToMoreOptions<TData = any, TSubscriptionVariables = Operati
52
190
  context?: DefaultContext;
53
191
  };
54
192
  export interface SubscriptionOptions<TVariables = OperationVariables, TData = any> {
193
+ /**
194
+ * A GraphQL document, often created with `gql` from the `graphql-tag`
195
+ * package, that contains a single subscription inside of it.
196
+ */
55
197
  query: DocumentNode | TypedDocumentNode<TData, TVariables>;
198
+ /**
199
+ * An object that maps from the name of a variable as used in the subscription
200
+ * GraphQL document to that variable's value.
201
+ */
56
202
  variables?: TVariables;
203
+ /**
204
+ * Specifies the {@link FetchPolicy} to be used for this subscription.
205
+ */
57
206
  fetchPolicy?: FetchPolicy;
207
+ /**
208
+ * Specifies the {@link ErrorPolicy} to be used for this operation
209
+ */
58
210
  errorPolicy?: ErrorPolicy;
211
+ /**
212
+ * Context object to be passed through the link execution chain.
213
+ */
59
214
  context?: DefaultContext;
60
215
  }
61
216
  export interface MutationBaseOptions<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>> {
62
- optimisticResponse?: TData | ((vars: TVariables) => TData);
217
+ /**
218
+ * An object that represents the result of this mutation that will be
219
+ * optimistically stored before the server has actually returned a result.
220
+ * This is most often used for optimistic UI, where we want to be able to see
221
+ * the result of a mutation immediately, and update the UI later if any errors
222
+ * appear.
223
+ */
224
+ optimisticResponse?: TData | ((vars: TVariables, { IGNORE }: {
225
+ IGNORE: IgnoreModifier;
226
+ }) => TData);
227
+ /**
228
+ * A {@link MutationQueryReducersMap}, which is map from query names to
229
+ * mutation query reducers. Briefly, this map defines how to incorporate the
230
+ * results of the mutation into the results of queries that are currently
231
+ * being watched by your application.
232
+ */
63
233
  updateQueries?: MutationQueryReducersMap<TData>;
234
+ /**
235
+ * A list of query names which will be refetched once this mutation has
236
+ * returned. This is often used if you have a set of queries which may be
237
+ * affected by a mutation and will have to update. Rather than writing a
238
+ * mutation query reducer (i.e. `updateQueries`) for this, you can simply
239
+ * refetch the queries that will be affected and achieve a consistent store
240
+ * once these queries return.
241
+ */
64
242
  refetchQueries?: ((result: FetchResult<TData>) => InternalRefetchQueriesInclude) | InternalRefetchQueriesInclude;
243
+ /**
244
+ * By default, `refetchQueries` does not wait for the refetched queries to
245
+ * be completed, before resolving the mutation `Promise`. This ensures that
246
+ * query refetching does not hold up mutation response handling (query
247
+ * refetching is handled asynchronously). Set `awaitRefetchQueries` to
248
+ * `true` if you would like to wait for the refetched queries to complete,
249
+ * before the mutation can be marked as resolved.
250
+ */
65
251
  awaitRefetchQueries?: boolean;
252
+ /**
253
+ * A function which provides an {@link ApolloCache} instance, and the result
254
+ * of the mutation, to allow the user to update the store based on the
255
+ * results of the mutation.
256
+ *
257
+ * This function will be called twice over the lifecycle of a mutation. Once
258
+ * at the very beginning if an `optimisticResponse` was provided. The writes
259
+ * created from the optimistic data will be rolled back before the second time
260
+ * this function is called which is when the mutation has successfully
261
+ * resolved. At that point `update` will be called with the *actual* mutation
262
+ * result and those writes will not be rolled back.
263
+ *
264
+ * Note that since this function is intended to be used to update the
265
+ * store, it cannot be used with a `no-cache` fetch policy. If you're
266
+ * interested in performing some action after a mutation has completed,
267
+ * and you don't need to update the store, use the Promise returned from
268
+ * `client.mutate` instead.
269
+ */
66
270
  update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;
271
+ /**
272
+ * A function that will be called for each ObservableQuery affected by
273
+ * this mutation, after the mutation has completed.
274
+ */
67
275
  onQueryUpdated?: OnQueryUpdated<any>;
276
+ /**
277
+ * Specifies the {@link ErrorPolicy} to be used for this operation
278
+ */
68
279
  errorPolicy?: ErrorPolicy;
280
+ /**
281
+ * An object that maps from the name of a variable as used in the mutation
282
+ * GraphQL document to that variable's value.
283
+ */
69
284
  variables?: TVariables;
285
+ /**
286
+ * The context to be passed to the link execution chain. This context will
287
+ * only be used with this mutation. It will not be used with
288
+ * `refetchQueries`. Refetched queries use the context they were
289
+ * initialized with (since the initial context is stored as part of the
290
+ * `ObservableQuery` instance). If a specific context is needed when
291
+ * refetching queries, make sure it is configured (via the
292
+ * [query `context` option](https://www.apollographql.com/docs/react/api/apollo-client#ApolloClient.query))
293
+ * when the query is first initialized/run.
294
+ */
70
295
  context?: TContext;
71
296
  }
72
297
  export interface MutationOptions<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>> extends MutationBaseOptions<TData, TVariables, TContext, TCache> {
298
+ /**
299
+ * A GraphQL document, often created with `gql` from the `graphql-tag`
300
+ * package, that contains a single mutation inside of it.
301
+ */
73
302
  mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;
303
+ /**
304
+ * Specifies the {@link MutationFetchPolicy} to be used for this query.
305
+ * Mutations support only 'network-only' and 'no-cache' fetchPolicy strings.
306
+ * If fetchPolicy is not provided, it defaults to 'network-only'.
307
+ */
74
308
  fetchPolicy?: MutationFetchPolicy;
309
+ /**
310
+ * To avoid retaining sensitive information from mutation root field
311
+ * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`
312
+ * fields from the cache after each mutation finishes. If you need this
313
+ * information to remain in the cache, you can prevent the removal by passing
314
+ * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are
315
+ * also passed to the mutation `update` function, so we recommend obtaining
316
+ * the results that way, rather than using this option, if possible.
317
+ */
75
318
  keepRootFields?: boolean;
76
319
  }
77
320
  //# sourceMappingURL=watchQueryOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"watchQueryOptions.js","sourceRoot":"","sources":["../../src/core/watchQueryOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { DocumentNode } from \"graphql\";\nimport type { TypedDocumentNode } from \"@graphql-typed-document-node/core\";\n\nimport type { FetchResult } from \"../link/core/index.js\";\nimport type {\n DefaultContext,\n MutationQueryReducersMap,\n OperationVariables,\n MutationUpdaterFunction,\n OnQueryUpdated,\n InternalRefetchQueriesInclude,\n} from \"./types.js\";\nimport type { ApolloCache } from \"../cache/index.js\";\nimport type { ObservableQuery } from \"./ObservableQuery.js\";\n\n/**\n * fetchPolicy determines where the client may return a result from. The options are:\n * - cache-first (default): return result from cache. Only fetch from network if cached result is not available.\n * - cache-and-network: return result from cache first (if it exists), then return network result once it's available.\n * - cache-only: return result from cache if available, fail otherwise.\n * - no-cache: return result from network, fail if network call doesn't succeed, don't save to cache\n * - network-only: return result from network, fail if network call doesn't succeed, save to cache\n * - standby: only for queries that aren't actively watched, but should be available for refetch and updateQueries.\n */\nexport type FetchPolicy =\n | \"cache-first\"\n | \"network-only\"\n | \"cache-only\"\n | \"no-cache\"\n | \"standby\";\n\nexport type WatchQueryFetchPolicy = FetchPolicy | \"cache-and-network\";\n\nexport type MutationFetchPolicy = Extract<\n FetchPolicy,\n | \"network-only\" // default behavior (mutation results written to cache)\n | \"no-cache\" // alternate behavior (results not written to cache)\n>;\n\nexport type RefetchWritePolicy = \"merge\" | \"overwrite\";\n\n/**\n * errorPolicy determines the level of events for errors in the execution result. The options are:\n * - none (default): any errors from the request are treated like runtime errors and the observable is stopped (XXX this is default to lower breaking changes going from AC 1.0 => 2.0)\n * - ignore: errors from the request do not stop the observable, but also don't call `next`\n * - all: errors are treated like data and will notify observables\n */\nexport type ErrorPolicy = \"none\" | \"ignore\" | \"all\";\n\n/**\n * Query options.\n */\nexport interface QueryOptions<TVariables = OperationVariables, TData = any> {\n /**\n * A GraphQL document that consists of a single query to be sent down to the\n * server.\n */\n // TODO REFACTOR: rename this to document. Didn't do it yet because it's in a\n // lot of tests.\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * A map going from variable name to variable value, where the variables are used\n * within the GraphQL query.\n */\n variables?: TVariables;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this query\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * Context to be passed to link execution chain\n */\n context?: DefaultContext;\n\n /**\n * Specifies the {@link FetchPolicy} to be used for this query\n */\n fetchPolicy?: FetchPolicy;\n\n /**\n * The time interval (in milliseconds) on which this query should be\n * refetched from the server.\n */\n pollInterval?: number;\n\n /**\n * Whether or not updates to the network status should trigger next on the observer of this query\n */\n notifyOnNetworkStatusChange?: boolean;\n\n /**\n * Allow returning incomplete data from the cache when a larger query cannot\n * be fully satisfied by the cache, instead of returning nothing.\n */\n returnPartialData?: boolean;\n\n /**\n * If `true`, perform a query `refetch` if the query result is marked as\n * being partial, and the returned data is reset to an empty Object by the\n * Apollo Client `QueryManager` (due to a cache miss).\n */\n partialRefetch?: boolean;\n\n /**\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n */\n canonizeResults?: boolean;\n}\n\n/**\n * Watched query options.\n */\nexport interface WatchQueryOptions<\n TVariables extends OperationVariables = OperationVariables,\n TData = any,\n> extends Omit<QueryOptions<TVariables, TData>, \"fetchPolicy\"> {\n /**\n * Specifies the {@link FetchPolicy} to be used for this query.\n */\n fetchPolicy?: WatchQueryFetchPolicy;\n\n /**\n * Specifies the {@link FetchPolicy} to be used after this query has completed.\n */\n nextFetchPolicy?:\n | WatchQueryFetchPolicy\n | ((\n this: WatchQueryOptions<TVariables, TData>,\n currentFetchPolicy: WatchQueryFetchPolicy,\n context: NextFetchPolicyContext<TData, TVariables>\n ) => WatchQueryFetchPolicy);\n\n /**\n * Defaults to the initial value of options.fetchPolicy, but can be explicitly\n * configured to specify the WatchQueryFetchPolicy to revert back to whenever\n * variables change (unless nextFetchPolicy intervenes).\n */\n initialFetchPolicy?: WatchQueryFetchPolicy;\n\n /**\n * Specifies whether a {@link NetworkStatus.refetch} operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n */\n refetchWritePolicy?: RefetchWritePolicy;\n}\n\nexport interface NextFetchPolicyContext<\n TData,\n TVariables extends OperationVariables,\n> {\n reason: \"after-fetch\" | \"variables-changed\";\n observable: ObservableQuery<TData, TVariables>;\n options: WatchQueryOptions<TVariables, TData>;\n initialFetchPolicy: WatchQueryFetchPolicy;\n}\n\nexport interface FetchMoreQueryOptions<TVariables, TData = any> {\n query?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n variables?: Partial<TVariables>;\n context?: DefaultContext;\n}\n\nexport type UpdateQueryFn<\n TData = any,\n TSubscriptionVariables = OperationVariables,\n TSubscriptionData = TData,\n> = (\n previousQueryResult: TData,\n options: {\n subscriptionData: { data: TSubscriptionData };\n variables?: TSubscriptionVariables;\n }\n) => TData;\n\nexport type SubscribeToMoreOptions<\n TData = any,\n TSubscriptionVariables = OperationVariables,\n TSubscriptionData = TData,\n> = {\n document:\n | DocumentNode\n | TypedDocumentNode<TSubscriptionData, TSubscriptionVariables>;\n variables?: TSubscriptionVariables;\n updateQuery?: UpdateQueryFn<TData, TSubscriptionVariables, TSubscriptionData>;\n onError?: (error: Error) => void;\n context?: DefaultContext;\n};\n\nexport interface SubscriptionOptions<\n TVariables = OperationVariables,\n TData = any,\n> {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * An object that maps from the name of a variable as used in the subscription\n * GraphQL document to that variable's value.\n */\n variables?: TVariables;\n\n /**\n * Specifies the {@link FetchPolicy} to be used for this subscription.\n */\n fetchPolicy?: FetchPolicy;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * Context object to be passed through the link execution chain.\n */\n context?: DefaultContext;\n}\n\nexport interface MutationBaseOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> {\n /**\n * An object that represents the result of this mutation that will be\n * optimistically stored before the server has actually returned a result.\n * This is most often used for optimistic UI, where we want to be able to see\n * the result of a mutation immediately, and update the UI later if any errors\n * appear.\n */\n optimisticResponse?: TData | ((vars: TVariables) => TData);\n\n /**\n * A {@link MutationQueryReducersMap}, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries?: MutationQueryReducersMap<TData>;\n\n /**\n * A list of query names which will be refetched once this mutation has\n * returned. This is often used if you have a set of queries which may be\n * affected by a mutation and will have to update. Rather than writing a\n * mutation query reducer (i.e. `updateQueries`) for this, you can simply\n * refetch the queries that will be affected and achieve a consistent store\n * once these queries return.\n */\n refetchQueries?:\n | ((result: FetchResult<TData>) => InternalRefetchQueriesInclude)\n | InternalRefetchQueriesInclude;\n\n /**\n * By default, `refetchQueries` does not wait for the refetched queries to\n * be completed, before resolving the mutation `Promise`. This ensures that\n * query refetching does not hold up mutation response handling (query\n * refetching is handled asynchronously). Set `awaitRefetchQueries` to\n * `true` if you would like to wait for the refetched queries to complete,\n * before the mutation can be marked as resolved.\n */\n awaitRefetchQueries?: boolean;\n\n /**\n * A function which provides an {@link ApolloCache} instance, and the result\n * of the mutation, to allow the user to update the store based on the\n * results of the mutation.\n *\n * This function will be called twice over the lifecycle of a mutation. Once\n * at the very beginning if an `optimisticResponse` was provided. The writes\n * created from the optimistic data will be rolled back before the second time\n * this function is called which is when the mutation has successfully\n * resolved. At that point `update` will be called with the *actual* mutation\n * result and those writes will not be rolled back.\n *\n * Note that since this function is intended to be used to update the\n * store, it cannot be used with a `no-cache` fetch policy. If you're\n * interested in performing some action after a mutation has completed,\n * and you don't need to update the store, use the Promise returned from\n * `client.mutate` instead.\n */\n update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;\n\n /**\n * A function that will be called for each ObservableQuery affected by\n * this mutation, after the mutation has completed.\n */\n onQueryUpdated?: OnQueryUpdated<any>;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * An object that maps from the name of a variable as used in the mutation\n * GraphQL document to that variable's value.\n */\n variables?: TVariables;\n\n /**\n * The context to be passed to the link execution chain. This context will\n * only be used with this mutation. It will not be used with\n * `refetchQueries`. Refetched queries use the context they were\n * initialized with (since the initial context is stored as part of the\n * `ObservableQuery` instance). If a specific context is needed when\n * refetching queries, make sure it is configured (via the\n * [query `context` option](https://www.apollographql.com/docs/react/api/apollo-client#ApolloClient.query))\n * when the query is first initialized/run.\n */\n context?: TContext;\n}\n\nexport interface MutationOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> extends MutationBaseOptions<TData, TVariables, TContext, TCache> {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n */\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * Specifies the {@link MutationFetchPolicy} to be used for this query.\n * Mutations support only 'network-only' and 'no-cache' fetchPolicy strings.\n * If fetchPolicy is not provided, it defaults to 'network-only'.\n */\n fetchPolicy?: MutationFetchPolicy;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields?: boolean;\n}\n"]}
1
+ {"version":3,"file":"watchQueryOptions.js","sourceRoot":"","sources":["../../src/core/watchQueryOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { DocumentNode } from \"graphql\";\nimport type { TypedDocumentNode } from \"@graphql-typed-document-node/core\";\n\nimport type { FetchResult } from \"../link/core/index.js\";\nimport type {\n DefaultContext,\n MutationQueryReducersMap,\n OperationVariables,\n MutationUpdaterFunction,\n OnQueryUpdated,\n InternalRefetchQueriesInclude,\n} from \"./types.js\";\nimport type { ApolloCache } from \"../cache/index.js\";\nimport type { ObservableQuery } from \"./ObservableQuery.js\";\nimport type { IgnoreModifier } from \"../cache/core/types/common.js\";\n\n/**\n * fetchPolicy determines where the client may return a result from. The options are:\n * - cache-first (default): return result from cache. Only fetch from network if cached result is not available.\n * - cache-and-network: return result from cache first (if it exists), then return network result once it's available.\n * - cache-only: return result from cache if available, fail otherwise.\n * - no-cache: return result from network, fail if network call doesn't succeed, don't save to cache\n * - network-only: return result from network, fail if network call doesn't succeed, save to cache\n * - standby: only for queries that aren't actively watched, but should be available for refetch and updateQueries.\n */\nexport type FetchPolicy =\n | \"cache-first\"\n | \"network-only\"\n | \"cache-only\"\n | \"no-cache\"\n | \"standby\";\n\nexport type WatchQueryFetchPolicy = FetchPolicy | \"cache-and-network\";\n\nexport type MutationFetchPolicy = Extract<\n FetchPolicy,\n | \"network-only\" // default behavior (mutation results written to cache)\n | \"no-cache\" // alternate behavior (results not written to cache)\n>;\n\nexport type RefetchWritePolicy = \"merge\" | \"overwrite\";\n\n/**\n * errorPolicy determines the level of events for errors in the execution result. The options are:\n * - none (default): any errors from the request are treated like runtime errors and the observable is stopped\n * - ignore: errors from the request do not stop the observable, but also don't call `next`\n * - all: errors are treated like data and will notify observables\n */\nexport type ErrorPolicy = \"none\" | \"ignore\" | \"all\";\n\n/**\n * Query options.\n */\nexport interface QueryOptions<TVariables = OperationVariables, TData = any> {\n /**\n * A GraphQL document that consists of a single query to be sent down to the\n * server.\n */\n // TODO REFACTOR: rename this to document. Didn't do it yet because it's in a\n // lot of tests.\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * A map going from variable name to variable value, where the variables are used\n * within the GraphQL query.\n */\n variables?: TVariables;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this query\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * Context to be passed to link execution chain\n */\n context?: DefaultContext;\n\n /**\n * Specifies the {@link FetchPolicy} to be used for this query\n */\n fetchPolicy?: FetchPolicy;\n\n /**\n * The time interval (in milliseconds) on which this query should be\n * refetched from the server.\n */\n pollInterval?: number;\n\n /**\n * Whether or not updates to the network status should trigger next on the observer of this query\n */\n notifyOnNetworkStatusChange?: boolean;\n\n /**\n * Allow returning incomplete data from the cache when a larger query cannot\n * be fully satisfied by the cache, instead of returning nothing.\n */\n returnPartialData?: boolean;\n\n /**\n * If `true`, perform a query `refetch` if the query result is marked as\n * being partial, and the returned data is reset to an empty Object by the\n * Apollo Client `QueryManager` (due to a cache miss).\n */\n partialRefetch?: boolean;\n\n /**\n * @deprecated\n * Using `canonizeResults` can result in memory leaks so we generally do not\n * recommend using this option anymore.\n * A future version of Apollo Client will contain a similar feature without\n * the risk of memory leaks.\n *\n * Whether to canonize cache results before returning them. Canonization\n * takes some extra time, but it speeds up future deep equality comparisons.\n * Defaults to false.\n */\n canonizeResults?: boolean;\n}\n\n/**\n * Watched query options.\n */\nexport interface WatchQueryOptions<\n TVariables extends OperationVariables = OperationVariables,\n TData = any,\n> {\n /**\n * Specifies the {@link FetchPolicy} to be used for this query.\n */\n fetchPolicy?: WatchQueryFetchPolicy;\n\n /**\n * Specifies the {@link FetchPolicy} to be used after this query has completed.\n */\n nextFetchPolicy?:\n | WatchQueryFetchPolicy\n | ((\n this: WatchQueryOptions<TVariables, TData>,\n currentFetchPolicy: WatchQueryFetchPolicy,\n context: NextFetchPolicyContext<TData, TVariables>\n ) => WatchQueryFetchPolicy);\n\n /**\n * Defaults to the initial value of options.fetchPolicy, but can be explicitly\n * configured to specify the WatchQueryFetchPolicy to revert back to whenever\n * variables change (unless nextFetchPolicy intervenes).\n */\n initialFetchPolicy?: WatchQueryFetchPolicy;\n\n /**\n * Specifies whether a {@link NetworkStatus.refetch} operation should merge\n * incoming field data with existing data, or overwrite the existing data.\n * Overwriting is probably preferable, but merging is currently the default\n * behavior, for backwards compatibility with Apollo Client 3.x.\n */\n refetchWritePolicy?: RefetchWritePolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptions#query:member} */\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /** {@inheritDoc @apollo/client!QueryOptions#variables:member} */\n variables?: TVariables;\n\n /** {@inheritDoc @apollo/client!QueryOptions#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptions#context:member} */\n context?: DefaultContext;\n\n /** {@inheritDoc @apollo/client!QueryOptions#pollInterval:member} */\n pollInterval?: number;\n\n /** {@inheritDoc @apollo/client!QueryOptions#notifyOnNetworkStatusChange:member} */\n notifyOnNetworkStatusChange?: boolean;\n\n /** {@inheritDoc @apollo/client!QueryOptions#returnPartialData:member} */\n returnPartialData?: boolean;\n\n /** {@inheritDoc @apollo/client!QueryOptions#partialRefetch:member} */\n partialRefetch?: boolean;\n\n /** {@inheritDoc @apollo/client!QueryOptions#canonizeResults:member} */\n canonizeResults?: boolean;\n\n /**\n * A callback function that's called whenever a refetch attempt occurs\n * while polling. If the function returns `true`, the refetch is\n * skipped and not reattempted until the next poll interval.\n */\n skipPollAttempt?: () => boolean;\n}\n\nexport interface NextFetchPolicyContext<\n TData,\n TVariables extends OperationVariables,\n> {\n reason: \"after-fetch\" | \"variables-changed\";\n observable: ObservableQuery<TData, TVariables>;\n options: WatchQueryOptions<TVariables, TData>;\n initialFetchPolicy: WatchQueryFetchPolicy;\n}\n\nexport interface FetchMoreQueryOptions<TVariables, TData = any> {\n query?: DocumentNode | TypedDocumentNode<TData, TVariables>;\n variables?: Partial<TVariables>;\n context?: DefaultContext;\n}\n\nexport type UpdateQueryFn<\n TData = any,\n TSubscriptionVariables = OperationVariables,\n TSubscriptionData = TData,\n> = (\n previousQueryResult: TData,\n options: {\n subscriptionData: { data: TSubscriptionData };\n variables?: TSubscriptionVariables;\n }\n) => TData;\n\nexport type SubscribeToMoreOptions<\n TData = any,\n TSubscriptionVariables = OperationVariables,\n TSubscriptionData = TData,\n> = {\n document:\n | DocumentNode\n | TypedDocumentNode<TSubscriptionData, TSubscriptionVariables>;\n variables?: TSubscriptionVariables;\n updateQuery?: UpdateQueryFn<TData, TSubscriptionVariables, TSubscriptionData>;\n onError?: (error: Error) => void;\n context?: DefaultContext;\n};\n\nexport interface SubscriptionOptions<\n TVariables = OperationVariables,\n TData = any,\n> {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single subscription inside of it.\n */\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * An object that maps from the name of a variable as used in the subscription\n * GraphQL document to that variable's value.\n */\n variables?: TVariables;\n\n /**\n * Specifies the {@link FetchPolicy} to be used for this subscription.\n */\n fetchPolicy?: FetchPolicy;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * Context object to be passed through the link execution chain.\n */\n context?: DefaultContext;\n}\n\nexport interface MutationBaseOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> {\n /**\n * An object that represents the result of this mutation that will be\n * optimistically stored before the server has actually returned a result.\n * This is most often used for optimistic UI, where we want to be able to see\n * the result of a mutation immediately, and update the UI later if any errors\n * appear.\n */\n optimisticResponse?:\n | TData\n | ((vars: TVariables, { IGNORE }: { IGNORE: IgnoreModifier }) => TData);\n\n /**\n * A {@link MutationQueryReducersMap}, which is map from query names to\n * mutation query reducers. Briefly, this map defines how to incorporate the\n * results of the mutation into the results of queries that are currently\n * being watched by your application.\n */\n updateQueries?: MutationQueryReducersMap<TData>;\n\n /**\n * A list of query names which will be refetched once this mutation has\n * returned. This is often used if you have a set of queries which may be\n * affected by a mutation and will have to update. Rather than writing a\n * mutation query reducer (i.e. `updateQueries`) for this, you can simply\n * refetch the queries that will be affected and achieve a consistent store\n * once these queries return.\n */\n refetchQueries?:\n | ((result: FetchResult<TData>) => InternalRefetchQueriesInclude)\n | InternalRefetchQueriesInclude;\n\n /**\n * By default, `refetchQueries` does not wait for the refetched queries to\n * be completed, before resolving the mutation `Promise`. This ensures that\n * query refetching does not hold up mutation response handling (query\n * refetching is handled asynchronously). Set `awaitRefetchQueries` to\n * `true` if you would like to wait for the refetched queries to complete,\n * before the mutation can be marked as resolved.\n */\n awaitRefetchQueries?: boolean;\n\n /**\n * A function which provides an {@link ApolloCache} instance, and the result\n * of the mutation, to allow the user to update the store based on the\n * results of the mutation.\n *\n * This function will be called twice over the lifecycle of a mutation. Once\n * at the very beginning if an `optimisticResponse` was provided. The writes\n * created from the optimistic data will be rolled back before the second time\n * this function is called which is when the mutation has successfully\n * resolved. At that point `update` will be called with the *actual* mutation\n * result and those writes will not be rolled back.\n *\n * Note that since this function is intended to be used to update the\n * store, it cannot be used with a `no-cache` fetch policy. If you're\n * interested in performing some action after a mutation has completed,\n * and you don't need to update the store, use the Promise returned from\n * `client.mutate` instead.\n */\n update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;\n\n /**\n * A function that will be called for each ObservableQuery affected by\n * this mutation, after the mutation has completed.\n */\n onQueryUpdated?: OnQueryUpdated<any>;\n\n /**\n * Specifies the {@link ErrorPolicy} to be used for this operation\n */\n errorPolicy?: ErrorPolicy;\n\n /**\n * An object that maps from the name of a variable as used in the mutation\n * GraphQL document to that variable's value.\n */\n variables?: TVariables;\n\n /**\n * The context to be passed to the link execution chain. This context will\n * only be used with this mutation. It will not be used with\n * `refetchQueries`. Refetched queries use the context they were\n * initialized with (since the initial context is stored as part of the\n * `ObservableQuery` instance). If a specific context is needed when\n * refetching queries, make sure it is configured (via the\n * [query `context` option](https://www.apollographql.com/docs/react/api/apollo-client#ApolloClient.query))\n * when the query is first initialized/run.\n */\n context?: TContext;\n}\n\nexport interface MutationOptions<\n TData = any,\n TVariables = OperationVariables,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> extends MutationBaseOptions<TData, TVariables, TContext, TCache> {\n /**\n * A GraphQL document, often created with `gql` from the `graphql-tag`\n * package, that contains a single mutation inside of it.\n */\n mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;\n\n /**\n * Specifies the {@link MutationFetchPolicy} to be used for this query.\n * Mutations support only 'network-only' and 'no-cache' fetchPolicy strings.\n * If fetchPolicy is not provided, it defaults to 'network-only'.\n */\n fetchPolicy?: MutationFetchPolicy;\n\n /**\n * To avoid retaining sensitive information from mutation root field\n * arguments, Apollo Client v3.4+ automatically clears any `ROOT_MUTATION`\n * fields from the cache after each mutation finishes. If you need this\n * information to remain in the cache, you can prevent the removal by passing\n * `keepRootFields: true` to the mutation. `ROOT_MUTATION` result data are\n * also passed to the mutation `update` function, so we recommend obtaining\n * the results that way, rather than using this option, if possible.\n */\n keepRootFields?: boolean;\n}\n"]}