@apollo/client 4.0.0-rc.6 → 4.0.0-rc.8

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 (351) hide show
  1. package/CHANGELOG.md +159 -0
  2. package/__cjs/cache/core/cache.cjs +12 -7
  3. package/__cjs/cache/core/cache.cjs.map +1 -1
  4. package/__cjs/cache/core/cache.d.cts +12 -7
  5. package/__cjs/core/ApolloClient.cjs +2 -2
  6. package/__cjs/core/ApolloClient.cjs.map +1 -1
  7. package/__cjs/core/ApolloClient.d.cts +80 -98
  8. package/__cjs/core/ObservableQuery.d.cts +41 -74
  9. package/__cjs/core/QueryInfo.cjs.map +1 -1
  10. package/__cjs/core/QueryInfo.d.cts +3 -3
  11. package/__cjs/core/QueryManager.cjs +0 -2
  12. package/__cjs/core/QueryManager.cjs.map +1 -1
  13. package/__cjs/core/QueryManager.d.cts +3 -3
  14. package/__cjs/core/index.cjs +1 -2
  15. package/__cjs/core/index.cjs.map +1 -1
  16. package/__cjs/core/index.d.cts +2 -3
  17. package/__cjs/core/types.d.cts +40 -28
  18. package/__cjs/errors/CombinedGraphQLErrors.cjs +22 -17
  19. package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
  20. package/__cjs/errors/CombinedGraphQLErrors.d.cts +39 -20
  21. package/__cjs/errors/CombinedProtocolErrors.cjs +12 -6
  22. package/__cjs/errors/CombinedProtocolErrors.cjs.map +1 -1
  23. package/__cjs/errors/CombinedProtocolErrors.d.cts +12 -6
  24. package/__cjs/errors/ServerError.cjs +2 -1
  25. package/__cjs/errors/ServerError.cjs.map +1 -1
  26. package/__cjs/errors/ServerError.d.cts +2 -1
  27. package/__cjs/errors/ServerParseError.cjs +2 -1
  28. package/__cjs/errors/ServerParseError.cjs.map +1 -1
  29. package/__cjs/errors/ServerParseError.d.cts +2 -1
  30. package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
  31. package/__cjs/incremental/handlers/defer20220824.d.cts +4 -4
  32. package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
  33. package/__cjs/incremental/handlers/notImplemented.d.cts +2 -2
  34. package/__cjs/incremental/types.d.cts +4 -4
  35. package/__cjs/invariantErrorCodes.cjs +15 -11
  36. package/__cjs/link/batch/batchLink.cjs +4 -12
  37. package/__cjs/link/batch/batchLink.cjs.map +1 -1
  38. package/__cjs/link/batch/batchLink.d.cts +36 -28
  39. package/__cjs/link/batch/batching.cjs +1 -1
  40. package/__cjs/link/batch/batching.cjs.map +1 -1
  41. package/__cjs/link/batch/batching.d.cts +8 -8
  42. package/__cjs/link/batch/index.cjs +1 -2
  43. package/__cjs/link/batch/index.cjs.map +1 -1
  44. package/__cjs/link/batch/index.d.cts +1 -2
  45. package/__cjs/link/batch-http/batchHttpLink.cjs +29 -6
  46. package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
  47. package/__cjs/link/batch-http/batchHttpLink.d.cts +45 -6
  48. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +33 -0
  49. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
  50. package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +35 -2
  51. package/__cjs/link/context/index.cjs.map +1 -1
  52. package/__cjs/link/context/index.d.cts +3 -4
  53. package/__cjs/link/core/ApolloLink.cjs +226 -54
  54. package/__cjs/link/core/ApolloLink.cjs.map +1 -1
  55. package/__cjs/link/core/ApolloLink.d.cts +355 -9
  56. package/__cjs/link/core/concat.cjs +4 -0
  57. package/__cjs/link/core/concat.cjs.map +1 -1
  58. package/__cjs/link/core/concat.d.cts +4 -0
  59. package/__cjs/link/core/deprecated.cjs +3 -0
  60. package/__cjs/link/core/deprecated.cjs.map +1 -0
  61. package/__cjs/link/core/deprecated.d.cts +10 -0
  62. package/__cjs/link/core/empty.cjs +4 -0
  63. package/__cjs/link/core/empty.cjs.map +1 -1
  64. package/__cjs/link/core/empty.d.cts +4 -0
  65. package/__cjs/link/core/from.cjs +4 -0
  66. package/__cjs/link/core/from.cjs.map +1 -1
  67. package/__cjs/link/core/from.d.cts +4 -0
  68. package/__cjs/link/core/split.cjs +4 -0
  69. package/__cjs/link/core/split.cjs.map +1 -1
  70. package/__cjs/link/core/split.d.cts +4 -0
  71. package/__cjs/link/core/types.d.cts +2 -33
  72. package/__cjs/link/error/index.cjs +44 -0
  73. package/__cjs/link/error/index.cjs.map +1 -1
  74. package/__cjs/link/error/index.d.cts +68 -9
  75. package/__cjs/link/http/BaseHttpLink.cjs +3 -4
  76. package/__cjs/link/http/BaseHttpLink.cjs.map +1 -1
  77. package/__cjs/link/http/HttpLink.cjs +26 -1
  78. package/__cjs/link/http/HttpLink.cjs.map +1 -1
  79. package/__cjs/link/http/HttpLink.d.cts +191 -89
  80. package/__cjs/link/http/index.cjs +1 -3
  81. package/__cjs/link/http/index.cjs.map +1 -1
  82. package/__cjs/link/http/index.d.cts +0 -2
  83. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +40 -25
  84. package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
  85. package/__cjs/link/http/parseAndCheckHttpResponse.d.cts +2 -2
  86. package/__cjs/link/http/rewriteURIForGET.cjs +2 -3
  87. package/__cjs/link/http/rewriteURIForGET.cjs.map +1 -1
  88. package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
  89. package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +3 -3
  90. package/__cjs/link/http/selectURI.cjs.map +1 -1
  91. package/__cjs/link/http/selectURI.d.cts +2 -2
  92. package/__cjs/link/index.cjs.map +1 -1
  93. package/__cjs/link/index.d.cts +2 -1
  94. package/__cjs/link/persisted-queries/index.cjs.map +1 -1
  95. package/__cjs/link/persisted-queries/index.d.cts +23 -25
  96. package/__cjs/link/remove-typename/index.cjs.map +1 -1
  97. package/__cjs/link/remove-typename/index.d.cts +0 -1
  98. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
  99. package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +9 -8
  100. package/__cjs/link/retry/delayFunction.cjs.map +1 -1
  101. package/__cjs/link/retry/delayFunction.d.cts +2 -39
  102. package/__cjs/link/retry/retryFunction.cjs.map +1 -1
  103. package/__cjs/link/retry/retryFunction.d.cts +2 -29
  104. package/__cjs/link/retry/retryLink.cjs +12 -9
  105. package/__cjs/link/retry/retryLink.cjs.map +1 -1
  106. package/__cjs/link/retry/retryLink.d.cts +57 -6
  107. package/__cjs/link/schema/index.cjs.map +1 -1
  108. package/__cjs/link/schema/index.d.cts +3 -4
  109. package/__cjs/link/subscriptions/index.cjs +23 -0
  110. package/__cjs/link/subscriptions/index.cjs.map +1 -1
  111. package/__cjs/link/subscriptions/index.d.cts +24 -2
  112. package/__cjs/link/utils/createOperation.cjs +12 -4
  113. package/__cjs/link/utils/createOperation.cjs.map +1 -1
  114. package/__cjs/link/utils/createOperation.d.cts +2 -2
  115. package/__cjs/link/utils/index.cjs +1 -5
  116. package/__cjs/link/utils/index.cjs.map +1 -1
  117. package/__cjs/link/utils/index.d.cts +0 -2
  118. package/__cjs/link/ws/index.cjs +17 -1
  119. package/__cjs/link/ws/index.cjs.map +1 -1
  120. package/__cjs/link/ws/index.d.cts +8 -2
  121. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  122. package/__cjs/react/hooks/useBackgroundQuery.d.cts +125 -93
  123. package/__cjs/react/hooks/useFragment.cjs.map +1 -1
  124. package/__cjs/react/hooks/useFragment.d.cts +2 -2
  125. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  126. package/__cjs/react/hooks/useLazyQuery.d.cts +70 -108
  127. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  128. package/__cjs/react/hooks/useLoadableQuery.d.cts +52 -61
  129. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  130. package/__cjs/react/hooks/useMutation.d.cts +36 -54
  131. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  132. package/__cjs/react/hooks/useQuery.d.cts +64 -105
  133. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  134. package/__cjs/react/hooks/useQueryRefHandlers.d.cts +17 -8
  135. package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
  136. package/__cjs/react/hooks/useReadQuery.d.cts +6 -9
  137. package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
  138. package/__cjs/react/hooks/useSubscription.d.cts +32 -24
  139. package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
  140. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  141. package/__cjs/react/hooks/useSuspenseQuery.d.cts +75 -94
  142. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  143. package/__cjs/react/internal/cache/QueryReference.d.cts +3 -1
  144. package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
  145. package/__cjs/react/query-preloader/createQueryPreloader.d.cts +29 -20
  146. package/__cjs/react/types/types.documentation.d.cts +5 -5
  147. package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
  148. package/__cjs/testing/core/mocking/mockLink.d.cts +5 -6
  149. package/__cjs/testing/core/mocking/mockSubscriptionLink.cjs.map +1 -1
  150. package/__cjs/testing/core/mocking/mockSubscriptionLink.d.cts +3 -4
  151. package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +20 -28
  152. package/__cjs/utilities/internal/types/VariablesOption.d.cts +2 -6
  153. package/__cjs/utilities/subscriptions/relay/index.cjs +1 -2
  154. package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
  155. package/__cjs/version.cjs +1 -1
  156. package/cache/core/cache.d.ts +12 -7
  157. package/cache/core/cache.js +12 -7
  158. package/cache/core/cache.js.map +1 -1
  159. package/core/ApolloClient.d.ts +80 -98
  160. package/core/ApolloClient.js +2 -2
  161. package/core/ApolloClient.js.map +1 -1
  162. package/core/ObservableQuery.d.ts +41 -74
  163. package/core/QueryInfo.d.ts +3 -3
  164. package/core/QueryInfo.js.map +1 -1
  165. package/core/QueryManager.d.ts +3 -3
  166. package/core/QueryManager.js +0 -2
  167. package/core/QueryManager.js.map +1 -1
  168. package/core/index.d.ts +2 -3
  169. package/core/index.js +1 -1
  170. package/core/index.js.map +1 -1
  171. package/core/types.d.ts +40 -28
  172. package/errors/CombinedGraphQLErrors.d.ts +39 -20
  173. package/errors/CombinedGraphQLErrors.js +22 -17
  174. package/errors/CombinedGraphQLErrors.js.map +1 -1
  175. package/errors/CombinedProtocolErrors.d.ts +12 -6
  176. package/errors/CombinedProtocolErrors.js +12 -6
  177. package/errors/CombinedProtocolErrors.js.map +1 -1
  178. package/errors/ServerError.d.ts +2 -1
  179. package/errors/ServerError.js +2 -1
  180. package/errors/ServerError.js.map +1 -1
  181. package/errors/ServerParseError.d.ts +2 -1
  182. package/errors/ServerParseError.js +2 -1
  183. package/errors/ServerParseError.js.map +1 -1
  184. package/incremental/handlers/defer20220824.d.ts +4 -4
  185. package/incremental/handlers/defer20220824.js.map +1 -1
  186. package/incremental/handlers/notImplemented.d.ts +2 -2
  187. package/incremental/handlers/notImplemented.js.map +1 -1
  188. package/incremental/types.d.ts +4 -4
  189. package/incremental/types.js.map +1 -1
  190. package/invariantErrorCodes.js +15 -11
  191. package/link/batch/batchLink.d.ts +37 -29
  192. package/link/batch/batchLink.js +3 -10
  193. package/link/batch/batchLink.js.map +1 -1
  194. package/link/batch/batching.d.ts +8 -8
  195. package/link/batch/batching.js +2 -2
  196. package/link/batch/batching.js.map +1 -1
  197. package/link/batch/index.d.ts +1 -2
  198. package/link/batch/index.js +1 -1
  199. package/link/batch/index.js.map +1 -1
  200. package/link/batch-http/batchHttpLink.d.ts +46 -7
  201. package/link/batch-http/batchHttpLink.js +30 -7
  202. package/link/batch-http/batchHttpLink.js.map +1 -1
  203. package/link/client-awareness/ClientAwarenessLink.d.ts +35 -2
  204. package/link/client-awareness/ClientAwarenessLink.js +33 -0
  205. package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
  206. package/link/context/index.d.ts +3 -4
  207. package/link/context/index.js.map +1 -1
  208. package/link/core/ApolloLink.d.ts +355 -9
  209. package/link/core/ApolloLink.js +227 -56
  210. package/link/core/ApolloLink.js.map +1 -1
  211. package/link/core/concat.d.ts +4 -0
  212. package/link/core/concat.js +4 -0
  213. package/link/core/concat.js.map +1 -1
  214. package/link/core/deprecated.d.ts +10 -0
  215. package/link/core/deprecated.js +2 -0
  216. package/link/core/deprecated.js.map +1 -0
  217. package/link/core/empty.d.ts +4 -0
  218. package/link/core/empty.js +4 -0
  219. package/link/core/empty.js.map +1 -1
  220. package/link/core/from.d.ts +4 -0
  221. package/link/core/from.js +4 -0
  222. package/link/core/from.js.map +1 -1
  223. package/link/core/split.d.ts +4 -0
  224. package/link/core/split.js +4 -0
  225. package/link/core/split.js.map +1 -1
  226. package/link/core/types.d.ts +2 -33
  227. package/link/core/types.js.map +1 -1
  228. package/link/error/index.d.ts +69 -10
  229. package/link/error/index.js +44 -0
  230. package/link/error/index.js.map +1 -1
  231. package/link/http/BaseHttpLink.js +3 -4
  232. package/link/http/BaseHttpLink.js.map +1 -1
  233. package/link/http/HttpLink.d.ts +192 -90
  234. package/link/http/HttpLink.js +26 -1
  235. package/link/http/HttpLink.js.map +1 -1
  236. package/link/http/index.d.ts +0 -2
  237. package/link/http/index.js +0 -1
  238. package/link/http/index.js.map +1 -1
  239. package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
  240. package/link/http/parseAndCheckHttpResponse.js +40 -25
  241. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  242. package/link/http/rewriteURIForGET.js +2 -3
  243. package/link/http/rewriteURIForGET.js.map +1 -1
  244. package/link/http/selectHttpOptionsAndBody.d.ts +3 -3
  245. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  246. package/link/http/selectURI.d.ts +2 -2
  247. package/link/http/selectURI.js.map +1 -1
  248. package/link/index.d.ts +2 -1
  249. package/link/index.js.map +1 -1
  250. package/link/persisted-queries/index.d.ts +23 -25
  251. package/link/persisted-queries/index.js.map +1 -1
  252. package/link/remove-typename/index.d.ts +0 -1
  253. package/link/remove-typename/index.js.map +1 -1
  254. package/link/remove-typename/removeTypenameFromVariables.d.ts +9 -8
  255. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  256. package/link/retry/delayFunction.d.ts +2 -39
  257. package/link/retry/delayFunction.js.map +1 -1
  258. package/link/retry/retryFunction.d.ts +2 -29
  259. package/link/retry/retryFunction.js.map +1 -1
  260. package/link/retry/retryLink.d.ts +57 -6
  261. package/link/retry/retryLink.js +13 -10
  262. package/link/retry/retryLink.js.map +1 -1
  263. package/link/schema/index.d.ts +3 -4
  264. package/link/schema/index.js.map +1 -1
  265. package/link/subscriptions/index.d.ts +24 -2
  266. package/link/subscriptions/index.js +23 -0
  267. package/link/subscriptions/index.js.map +1 -1
  268. package/link/utils/createOperation.d.ts +2 -2
  269. package/link/utils/createOperation.js +12 -4
  270. package/link/utils/createOperation.js.map +1 -1
  271. package/link/utils/index.d.ts +0 -2
  272. package/link/utils/index.js +0 -2
  273. package/link/utils/index.js.map +1 -1
  274. package/link/ws/index.d.ts +8 -2
  275. package/link/ws/index.js +13 -1
  276. package/link/ws/index.js.map +1 -1
  277. package/package.json +1 -1
  278. package/react/hooks/useBackgroundQuery.d.ts +125 -93
  279. package/react/hooks/useBackgroundQuery.js.map +1 -1
  280. package/react/hooks/useFragment.d.ts +2 -2
  281. package/react/hooks/useFragment.js.map +1 -1
  282. package/react/hooks/useLazyQuery.d.ts +70 -108
  283. package/react/hooks/useLazyQuery.js.map +1 -1
  284. package/react/hooks/useLoadableQuery.d.ts +52 -61
  285. package/react/hooks/useLoadableQuery.js.map +1 -1
  286. package/react/hooks/useMutation.d.ts +36 -54
  287. package/react/hooks/useMutation.js.map +1 -1
  288. package/react/hooks/useQuery.d.ts +64 -105
  289. package/react/hooks/useQuery.js.map +1 -1
  290. package/react/hooks/useQueryRefHandlers.d.ts +17 -8
  291. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  292. package/react/hooks/useReadQuery.d.ts +6 -9
  293. package/react/hooks/useReadQuery.js.map +1 -1
  294. package/react/hooks/useSubscription.d.ts +32 -24
  295. package/react/hooks/useSubscription.js.map +1 -1
  296. package/react/hooks/useSuspenseFragment.js.map +1 -1
  297. package/react/hooks/useSuspenseQuery.d.ts +75 -94
  298. package/react/hooks/useSuspenseQuery.js.map +1 -1
  299. package/react/hooks-compiled/useBackgroundQuery.d.ts +125 -93
  300. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  301. package/react/hooks-compiled/useFragment.d.ts +2 -2
  302. package/react/hooks-compiled/useFragment.js.map +1 -1
  303. package/react/hooks-compiled/useLazyQuery.d.ts +70 -108
  304. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  305. package/react/hooks-compiled/useLoadableQuery.d.ts +52 -61
  306. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  307. package/react/hooks-compiled/useMutation.d.ts +36 -54
  308. package/react/hooks-compiled/useMutation.js.map +1 -1
  309. package/react/hooks-compiled/useQuery.d.ts +64 -105
  310. package/react/hooks-compiled/useQuery.js.map +1 -1
  311. package/react/hooks-compiled/useQueryRefHandlers.d.ts +17 -8
  312. package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
  313. package/react/hooks-compiled/useReadQuery.d.ts +6 -9
  314. package/react/hooks-compiled/useReadQuery.js.map +1 -1
  315. package/react/hooks-compiled/useSubscription.d.ts +32 -24
  316. package/react/hooks-compiled/useSubscription.js.map +1 -1
  317. package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
  318. package/react/hooks-compiled/useSuspenseQuery.d.ts +75 -94
  319. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  320. package/react/internal/cache/QueryReference.d.ts +3 -1
  321. package/react/internal/cache/QueryReference.js.map +1 -1
  322. package/react/query-preloader/createQueryPreloader.d.ts +29 -20
  323. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  324. package/react/types/types.documentation.d.ts +5 -5
  325. package/testing/core/mocking/mockLink.d.ts +5 -6
  326. package/testing/core/mocking/mockLink.js.map +1 -1
  327. package/testing/core/mocking/mockSubscriptionLink.d.ts +3 -4
  328. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  329. package/utilities/internal/types/DocumentationTypes.d.ts +20 -28
  330. package/utilities/internal/types/VariablesOption.d.ts +2 -6
  331. package/utilities/subscriptions/relay/index.js +1 -2
  332. package/utilities/subscriptions/relay/index.js.map +1 -1
  333. package/version.js +1 -1
  334. package/__cjs/link/http/serializeFetchParameter.cjs +0 -18
  335. package/__cjs/link/http/serializeFetchParameter.cjs.map +0 -1
  336. package/__cjs/link/http/serializeFetchParameter.d.cts +0 -6
  337. package/__cjs/link/utils/transformOperation.cjs +0 -22
  338. package/__cjs/link/utils/transformOperation.cjs.map +0 -1
  339. package/__cjs/link/utils/transformOperation.d.cts +0 -3
  340. package/__cjs/link/utils/validateOperation.cjs +0 -21
  341. package/__cjs/link/utils/validateOperation.cjs.map +0 -1
  342. package/__cjs/link/utils/validateOperation.d.cts +0 -3
  343. package/link/http/serializeFetchParameter.d.ts +0 -6
  344. package/link/http/serializeFetchParameter.js +0 -14
  345. package/link/http/serializeFetchParameter.js.map +0 -1
  346. package/link/utils/transformOperation.d.ts +0 -3
  347. package/link/utils/transformOperation.js +0 -19
  348. package/link/utils/transformOperation.js.map +0 -1
  349. package/link/utils/validateOperation.d.ts +0 -3
  350. package/link/utils/validateOperation.js +0 -18
  351. package/link/utils/validateOperation.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"batchHttpLink.js","sourceRoot":"","sources":["../../../src/link/batch-http/batchHttpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAs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3B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ;YACR,YAAY;SACb,CAAC,CAAC;IACL,CAAC;IAEM,OAAO,CAAC,SAAoB;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["import { Observable, throwError } from \"rxjs\";\n\nimport type { FetchResult, Operation } from \"@apollo/client/link\";\nimport { ApolloLink } from \"@apollo/client/link\";\nimport type { BatchHandler } from \"@apollo/client/link/batch\";\nimport { BatchLink } from \"@apollo/client/link/batch\";\nimport { ClientAwarenessLink } from \"@apollo/client/link/client-awareness\";\nimport type { HttpLink } from \"@apollo/client/link/http\";\nimport {\n checkFetcher,\n defaultPrinter,\n fallbackHttpConfig,\n parseAndCheckHttpResponse,\n selectHttpOptionsAndBodyInternal,\n selectURI,\n serializeFetchParameter,\n} from \"@apollo/client/link/http\";\nimport { filterOperationVariables } from \"@apollo/client/link/utils\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport { compact } from \"@apollo/client/utilities/internal\";\nimport { maybe } from \"@apollo/client/utilities/internal/globals\";\n\nexport declare namespace BatchHttpLink {\n export type Options = Pick<\n BatchLink.Options,\n \"batchMax\" | \"batchDebounce\" | \"batchInterval\" | \"batchKey\"\n > &\n Omit<HttpLink.Options, \"useGETForQueries\">;\n\n export type ContextOptions = HttpLink.ContextOptions;\n}\n\nconst backupFetch = maybe(() => fetch);\n\n/**\n * Transforms Operation for into HTTP results.\n * context can include the headers property, which will be passed to the fetch function\n */\nexport class BatchHttpLink extends ApolloLink {\n constructor(\n options: BatchHttpLink.Options & ClientAwarenessLink.Options = {}\n ) {\n const { left, right, request } = ApolloLink.concat(\n new ClientAwarenessLink(options),\n new BaseBatchHttpLink(options)\n );\n super(request);\n Object.assign(this, { left, right });\n }\n}\nexport class BaseBatchHttpLink extends ApolloLink {\n private batchDebounce?: boolean;\n private batchInterval: number;\n private batchMax: number;\n private batcher: ApolloLink;\n\n constructor(fetchParams?: BatchHttpLink.Options) {\n super();\n\n let {\n uri = \"/graphql\",\n // use default global fetch if nothing is passed in\n fetch: preferredFetch,\n print = defaultPrinter,\n includeExtensions,\n preserveHeaderCase,\n batchInterval,\n batchDebounce,\n batchMax,\n batchKey,\n includeUnusedVariables = false,\n ...requestOptions\n } = fetchParams || ({} as BatchHttpLink.Options);\n\n if (__DEV__) {\n // Make sure at least one of preferredFetch, window.fetch, or backupFetch\n // is defined, so requests won't fail at runtime.\n checkFetcher(preferredFetch || backupFetch);\n }\n\n const linkConfig = {\n http: compact({ includeExtensions, preserveHeaderCase }),\n options: requestOptions.fetchOptions,\n credentials: requestOptions.credentials,\n headers: requestOptions.headers,\n };\n\n this.batchDebounce = batchDebounce;\n this.batchInterval = batchInterval || 10;\n this.batchMax = batchMax || 10;\n\n const batchHandler: BatchHandler = (operations) => {\n const chosenURI = selectURI(operations[0], uri);\n\n const context = operations[0].getContext();\n\n const contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n\n //uses fallback, link, and then context to build options\n const optsAndBody = operations.map((operation) => {\n const result = selectHttpOptionsAndBodyInternal(\n operation,\n print,\n fallbackHttpConfig,\n linkConfig,\n contextConfig\n );\n\n if (result.body.variables && !includeUnusedVariables) {\n result.body.variables = filterOperationVariables(\n result.body.variables,\n operation.query\n );\n }\n\n return result;\n });\n\n const loadedBody = optsAndBody.map(({ body }) => body);\n const options = optsAndBody[0].options;\n\n // There's no spec for using GET with batches.\n if (options.method === \"GET\") {\n return throwError(\n () =>\n new Error(\"apollo-link-batch-http does not support GET requests\")\n );\n }\n\n try {\n (options as any).body = serializeFetchParameter(loadedBody, \"Payload\");\n } catch (parseError) {\n return throwError(() => parseError);\n }\n\n let controller: AbortController | undefined;\n if (!options.signal && typeof AbortController !== \"undefined\") {\n controller = new AbortController();\n options.signal = controller.signal;\n }\n\n return new Observable((observer) => {\n // Prefer BatchHttpLink.Options.fetch (preferredFetch) if provided, and\n // otherwise fall back to the *current* global window.fetch function\n // (see issue #7832), or (if all else fails) the backupFetch function we\n // saved when this module was first evaluated. This last option protects\n // against the removal of window.fetch, which is unlikely but not\n // impossible.\n const currentFetch =\n preferredFetch || maybe(() => fetch) || backupFetch;\n\n currentFetch!(chosenURI, options)\n .then((response) => {\n // Make the raw response available in the context.\n operations.forEach((operation) =>\n operation.setContext({ response })\n );\n return response;\n })\n .then(parseAndCheckHttpResponse(operations))\n .then((result) => {\n controller = undefined;\n // we have data and can send it to back up the link chain\n observer.next(result);\n observer.complete();\n return result;\n })\n .catch((err) => {\n controller = undefined;\n observer.error(err);\n });\n\n return () => {\n // XXX support canceling this request\n // https://developers.google.com/web/updates/2017/09/abortable-fetch\n if (controller) controller.abort();\n };\n });\n };\n\n batchKey =\n batchKey ||\n ((operation: Operation) => {\n const context = operation.getContext();\n\n const contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n\n //may throw error if config not serializable\n return selectURI(operation, uri) + JSON.stringify(contextConfig);\n });\n\n this.batcher = new BatchLink({\n batchDebounce: this.batchDebounce,\n batchInterval: this.batchInterval,\n batchMax: this.batchMax,\n batchKey,\n batchHandler,\n });\n }\n\n public request(operation: Operation): Observable<FetchResult> | null {\n return this.batcher.request(operation);\n }\n}\n"]}
1
+ {"version":3,"file":"batchHttpLink.js","sourceRoot":"","sources":["../../../src/link/batch-http/batchHttpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EACL,YAAY,EACZ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AE,IAAI,CAAC,aAAa;YACjC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ;YACR,YAAY;SACb,CAAC,CAAC;IACL,CAAC;IAEM,OAAO,CACZ,SAA+B,EAC/B,OAAmC;QAEnC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;CACF","sourcesContent":["import { Observable, throwError } from \"rxjs\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\nimport { BatchLink } from \"@apollo/client/link/batch\";\nimport { ClientAwarenessLink } from \"@apollo/client/link/client-awareness\";\nimport type { HttpLink } from \"@apollo/client/link/http\";\nimport {\n checkFetcher,\n defaultPrinter,\n fallbackHttpConfig,\n parseAndCheckHttpResponse,\n selectHttpOptionsAndBodyInternal,\n selectURI,\n} from \"@apollo/client/link/http\";\nimport { filterOperationVariables } from \"@apollo/client/link/utils\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport { compact } from \"@apollo/client/utilities/internal\";\nimport { maybe } from \"@apollo/client/utilities/internal/globals\";\n\nexport declare namespace BatchHttpLink {\n /**\n * Options provided to the `BatchHttpLink` constructor.\n */\n export interface Options\n extends BatchLink.Shared.Options,\n HttpLink.Shared.Options {\n /** {@inheritDoc @apollo/client/link/batch!BatchLink.Shared.Options#batchMax:member {\"defaultValue\": 10}} */\n batchMax?: number;\n }\n\n /**\n * Options passed to `BatchHttpLink` through [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context). Previous\n * non-terminating links in the link chain also can set these values to\n * customize the behavior of `BatchHttpLink` for each operation.\n *\n * > [!NOTE]\n * > Some of these values can also be provided to the `BatchHttpLink` constructor.\n * > If a value is provided to both, the value in `context` takes precedence.\n */\n export interface ContextOptions extends HttpLink.ContextOptions {}\n}\n\nconst backupFetch = maybe(() => fetch);\n\n/**\n * `BatchHttpLink` is a terminating link that batches array of individual\n * GraphQL operations into a single HTTP request that's sent to a single GraphQL\n * endpoint. It combines the functionality of `BaseBatchHttpLink` and\n * `ClientAwarenessLink` into a single link.\n *\n * @remarks\n *\n * If you use `BatchHttpLink` instead of `HttpLink` as your terminating link,\n * Apollo Client automatically batches executed GraphQL operations and transmits\n * them to your server according to the batching options you provide.\n *\n * @example\n *\n * ```ts\n * import { BatchHttpLink } from \"@apollo/client/link/batch-http\";\n *\n * const link = new BatchHttpLink({\n * uri: \"http://localhost:4000/graphql\",\n * batchMax: 5, // No more than 5 operations per batch\n * batchInterval: 20, // Wait no more than 20ms after first batched operation\n * });\n * ```\n */\nexport class BatchHttpLink extends ApolloLink {\n constructor(\n options: BatchHttpLink.Options & ClientAwarenessLink.Options = {}\n ) {\n const { left, right, request } = ApolloLink.from([\n new ClientAwarenessLink(options),\n new BaseBatchHttpLink(options),\n ]);\n super(request);\n Object.assign(this, { left, right });\n }\n}\nexport class BaseBatchHttpLink extends ApolloLink {\n private batchDebounce?: boolean;\n private batchInterval: number;\n private batchMax: number;\n private batcher: ApolloLink;\n\n constructor(fetchParams?: BatchHttpLink.Options) {\n super();\n\n let {\n uri = \"/graphql\",\n // use default global fetch if nothing is passed in\n fetch: preferredFetch,\n print = defaultPrinter,\n includeExtensions,\n preserveHeaderCase,\n batchInterval,\n batchDebounce,\n batchMax,\n batchKey,\n includeUnusedVariables = false,\n ...requestOptions\n } = fetchParams || ({} as BatchHttpLink.Options);\n\n if (__DEV__) {\n // Make sure at least one of preferredFetch, window.fetch, or backupFetch\n // is defined, so requests won't fail at runtime.\n checkFetcher(preferredFetch || backupFetch);\n }\n\n const linkConfig = {\n http: compact({ includeExtensions, preserveHeaderCase }),\n options: requestOptions.fetchOptions,\n credentials: requestOptions.credentials,\n headers: requestOptions.headers,\n };\n\n this.batchDebounce = batchDebounce;\n this.batchInterval = batchInterval || 10;\n this.batchMax = batchMax || 10;\n\n const batchHandler: BatchLink.BatchHandler = (operations) => {\n const chosenURI = selectURI(operations[0], uri);\n\n const context = operations[0].getContext();\n\n const contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n\n //uses fallback, link, and then context to build options\n const optsAndBody = operations.map((operation) => {\n const result = selectHttpOptionsAndBodyInternal(\n operation,\n print,\n fallbackHttpConfig,\n linkConfig,\n contextConfig\n );\n\n if (result.body.variables && !includeUnusedVariables) {\n result.body.variables = filterOperationVariables(\n result.body.variables,\n operation.query\n );\n }\n\n return result;\n });\n\n const loadedBody = optsAndBody.map(({ body }) => body);\n const options = optsAndBody[0].options;\n\n // There's no spec for using GET with batches.\n if (options.method === \"GET\") {\n return throwError(\n () =>\n new Error(\"apollo-link-batch-http does not support GET requests\")\n );\n }\n\n try {\n (options as any).body = JSON.stringify(loadedBody);\n } catch (parseError) {\n return throwError(() => parseError);\n }\n\n let controller: AbortController | undefined;\n if (!options.signal && typeof AbortController !== \"undefined\") {\n controller = new AbortController();\n options.signal = controller.signal;\n }\n\n return new Observable((observer) => {\n // Prefer BatchHttpLink.Options.fetch (preferredFetch) if provided, and\n // otherwise fall back to the *current* global window.fetch function\n // (see issue #7832), or (if all else fails) the backupFetch function we\n // saved when this module was first evaluated. This last option protects\n // against the removal of window.fetch, which is unlikely but not\n // impossible.\n const currentFetch =\n preferredFetch || maybe(() => fetch) || backupFetch;\n\n currentFetch!(chosenURI, options)\n .then((response) => {\n // Make the raw response available in the context.\n operations.forEach((operation) =>\n operation.setContext({ response })\n );\n return response;\n })\n .then(parseAndCheckHttpResponse(operations))\n .then((result) => {\n controller = undefined;\n // we have data and can send it to back up the link chain\n observer.next(result);\n observer.complete();\n return result;\n })\n .catch((err) => {\n controller = undefined;\n observer.error(err);\n });\n\n return () => {\n // XXX support canceling this request\n // https://developers.google.com/web/updates/2017/09/abortable-fetch\n if (controller) controller.abort();\n };\n });\n };\n\n batchKey =\n batchKey ||\n ((operation: ApolloLink.Operation) => {\n const context = operation.getContext();\n\n const contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n\n //may throw error if config not serializable\n return selectURI(operation, uri) + JSON.stringify(contextConfig);\n });\n\n this.batcher = new BatchLink({\n batchDebounce: this.batchDebounce,\n batchInterval: this.batchInterval,\n batchMax: this.batchMax,\n batchKey,\n batchHandler,\n });\n }\n\n public request(\n operation: ApolloLink.Operation,\n forward: ApolloLink.ForwardFunction\n ): Observable<ApolloLink.Result> {\n return this.batcher.request(operation, forward);\n }\n}\n"]}
@@ -46,16 +46,49 @@ export declare namespace ClientAwarenessLink {
46
46
  * and Apollo Server logs (and other monitoring or analytics tools) by adding
47
47
  * information about the your application to outgoing requests.
48
48
  */
49
- clientAwareness?: ClientAwarenessOptions;
49
+ clientAwareness?: ClientAwarenessLink.ClientAwarenessOptions;
50
50
  /**
51
51
  * Configures the "enhanced client awareness" feature.
52
52
  * This feature allows you to identify the version of the Apollo Client library
53
53
  * used in your application in Apollo Studio (and other monitoring or analytics tools)
54
54
  * by adding information about the Apollo Client library to outgoing requests.
55
55
  */
56
- enhancedClientAwareness?: EnhancedClientAwarenessOptions;
56
+ enhancedClientAwareness?: ClientAwarenessLink.EnhancedClientAwarenessOptions;
57
57
  }
58
58
  }
59
+ /**
60
+ * `ClientAwarenessLink` provides support for providing client awareness
61
+ * features.
62
+ *
63
+ * @remarks
64
+ *
65
+ * Client awareness adds identifying information about the client to HTTP
66
+ * requests for use with metrics reporting tools, such as [Apollo GraphOS](https://apollographql.com/docs/graphos/platform).
67
+ * It is included in the functionality of [`HttpLink`](https://apollographql.com/docs/react/api/link/apollo-link-http) by default.
68
+ *
69
+ * Client awareness distinguishes between user-provided client awareness
70
+ * (provided by the `clientAwareness` option) and enhanced client awareness
71
+ * (provided by the `enhancedClientAwareness` option). User-provided client
72
+ * awareness enables you to set a customized client name and version for
73
+ * identification in metrics reporting tools. Enhanced client awareness enables
74
+ * the identification of the Apollo Client package name and version.
75
+ *
76
+ * @example
77
+ *
78
+ * ```ts
79
+ * import { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
80
+ *
81
+ * const link = new ClientAwarenessLink({
82
+ * clientAwareness: {
83
+ * name: "My Client",
84
+ * version: "1",
85
+ * },
86
+ * enhancedClientAwareness: {
87
+ * transport: "extensions",
88
+ * },
89
+ * });
90
+ * ```
91
+ */
59
92
  export declare class ClientAwarenessLink extends ApolloLink {
60
93
  constructor(constructorOptions?: ClientAwarenessLink.Options);
61
94
  }
@@ -1,5 +1,38 @@
1
1
  import { ApolloLink } from "@apollo/client/link";
2
2
  import { compact } from "@apollo/client/utilities/internal";
3
+ /**
4
+ * `ClientAwarenessLink` provides support for providing client awareness
5
+ * features.
6
+ *
7
+ * @remarks
8
+ *
9
+ * Client awareness adds identifying information about the client to HTTP
10
+ * requests for use with metrics reporting tools, such as [Apollo GraphOS](https://apollographql.com/docs/graphos/platform).
11
+ * It is included in the functionality of [`HttpLink`](https://apollographql.com/docs/react/api/link/apollo-link-http) by default.
12
+ *
13
+ * Client awareness distinguishes between user-provided client awareness
14
+ * (provided by the `clientAwareness` option) and enhanced client awareness
15
+ * (provided by the `enhancedClientAwareness` option). User-provided client
16
+ * awareness enables you to set a customized client name and version for
17
+ * identification in metrics reporting tools. Enhanced client awareness enables
18
+ * the identification of the Apollo Client package name and version.
19
+ *
20
+ * @example
21
+ *
22
+ * ```ts
23
+ * import { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
24
+ *
25
+ * const link = new ClientAwarenessLink({
26
+ * clientAwareness: {
27
+ * name: "My Client",
28
+ * version: "1",
29
+ * },
30
+ * enhancedClientAwareness: {
31
+ * transport: "extensions",
32
+ * },
33
+ * });
34
+ * ```
35
+ */
3
36
  export class ClientAwarenessLink extends ApolloLink {
4
37
  constructor(constructorOptions = {}) {
5
38
  super((operation, forward) => {
@@ -1 +1 @@
1
- {"version":3,"file":"ClientAwarenessLink.js","sourceRoot":"","sources":["../../../src/link/client-awareness/ClientAwarenessLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM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C,UAAU,CACrB,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ApolloLink } from \"@apollo/client/link\";\nimport { compact } from \"@apollo/client/utilities/internal\";\n\nexport declare namespace ClientAwarenessLink {\n export interface ClientAwarenessOptions {\n /**\n * A custom name (e.g., `iOS`) that identifies this particular client among your set of clients. Apollo Server and Apollo Studio use this property as part of the [client awareness](https://www.apollographql.com/docs/apollo-server/monitoring/metrics#identifying-distinct-clients) feature.\n *\n * This option can either be set as part of the Apollo Client constructor call or when manually constructing a `HttpLink`, `BatchHttpLink` or `ClientAwarenessLink`.\n */\n name?: string;\n /**\n * A custom version that identifies the current version of this particular client (e.g., `1.2`). Apollo Server and Apollo Studio use this property as part of the [client awareness](https://www.apollographql.com/docs/apollo-server/monitoring/metrics#identifying-distinct-clients) feature.\n *\n * This is **not** the version of Apollo Client that you are using, but rather any version string that helps you differentiate between versions of your client.\n *\n * This option can either be set as part of the Apollo Client constructor call or when manually constructing a `HttpLink`, `BatchHttpLink` or `ClientAwarenessLink`.\n */\n version?: string;\n /**\n * Determines how `name` and `version` are sent in outgoing requests.\n *\n * If `name` and `version` are not provided, this option will be ignored.\n * (These options can either be set as part of the Apollo Client constructor call or when manually constructing a `HttpLink`, `BatchHttpLink` or `ClientAwarenessLink`.)\n *\n * - If set to `\"headers\"`, `name` and `version` will be sent in the request headers as `apollographql-client-name` and `apollographql-client-version`, respectively.\n * - If set to `false`, `name` and `version` will not be included in outgoing requests.\n *\n * @defaultValue \"headers\"\n */\n transport?: \"headers\" | false;\n }\n export interface EnhancedClientAwarenessOptions {\n /**\n * Determines how the the version information of Apollo Client is sent in outgoing requests.\n *\n * - If set to `\"extensions\"`, library `name` and `version` will be sent in an object in the request extensions as `clientLibrary`.\n * - If set to `false`, library name and version will not be included in outgoing requests.\n *\n * @defaultValue \"extensions\"\n */\n transport?: \"extensions\" | false;\n }\n\n export interface Options {\n /**\n * Configures the \"client awareness\" feature.\n * This feature allows you to identify distinct applications in Apollo Studio\n * and Apollo Server logs (and other monitoring or analytics tools) by adding\n * information about the your application to outgoing requests.\n */\n clientAwareness?: ClientAwarenessOptions;\n /**\n * Configures the \"enhanced client awareness\" feature.\n * This feature allows you to identify the version of the Apollo Client library\n * used in your application in Apollo Studio (and other monitoring or analytics tools)\n * by adding information about the Apollo Client library to outgoing requests.\n */\n enhancedClientAwareness?: EnhancedClientAwarenessOptions;\n }\n}\n\nexport class ClientAwarenessLink extends ApolloLink {\n constructor(constructorOptions: ClientAwarenessLink.Options = {}) {\n super((operation, forward) => {\n const client = operation.client;\n\n const clientOptions = client[\"queryManager\"].clientOptions;\n const context = operation.getContext();\n {\n const {\n name,\n version,\n transport = \"headers\",\n } = compact(\n {},\n clientOptions.clientAwareness,\n constructorOptions.clientAwareness,\n context.clientAwareness\n );\n\n if (transport === \"headers\") {\n operation.setContext(({ headers, extensions }) => {\n return {\n headers: compact(\n // setting these first so that they can be overridden by user-provided headers\n {\n \"apollographql-client-name\": name,\n \"apollographql-client-version\": version,\n },\n headers\n ),\n };\n });\n }\n }\n {\n const { transport = \"extensions\" } = compact(\n {},\n clientOptions.enhancedClientAwareness,\n constructorOptions.enhancedClientAwareness\n );\n if (transport === \"extensions\") {\n operation.extensions = compact(\n // setting these first so that it can be overridden by user-provided extensions\n {\n clientLibrary: {\n name: \"@apollo/client\",\n version: client.version,\n },\n },\n operation.extensions\n );\n }\n }\n\n return forward(operation);\n });\n }\n}\n"]}
1
+ {"version":3,"file":"ClientAwarenessLink.js","sourceRoot":"","sources":["../../../src/link/client-awareness/ClientAwarenessLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AA6D5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,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AAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ApolloLink } from \"@apollo/client/link\";\nimport { compact } from \"@apollo/client/utilities/internal\";\n\nexport declare namespace ClientAwarenessLink {\n export interface ClientAwarenessOptions {\n /**\n * A custom name (e.g., `iOS`) that identifies this particular client among your set of clients. Apollo Server and Apollo Studio use this property as part of the [client awareness](https://www.apollographql.com/docs/apollo-server/monitoring/metrics#identifying-distinct-clients) feature.\n *\n * This option can either be set as part of the Apollo Client constructor call or when manually constructing a `HttpLink`, `BatchHttpLink` or `ClientAwarenessLink`.\n */\n name?: string;\n /**\n * A custom version that identifies the current version of this particular client (e.g., `1.2`). Apollo Server and Apollo Studio use this property as part of the [client awareness](https://www.apollographql.com/docs/apollo-server/monitoring/metrics#identifying-distinct-clients) feature.\n *\n * This is **not** the version of Apollo Client that you are using, but rather any version string that helps you differentiate between versions of your client.\n *\n * This option can either be set as part of the Apollo Client constructor call or when manually constructing a `HttpLink`, `BatchHttpLink` or `ClientAwarenessLink`.\n */\n version?: string;\n /**\n * Determines how `name` and `version` are sent in outgoing requests.\n *\n * If `name` and `version` are not provided, this option will be ignored.\n * (These options can either be set as part of the Apollo Client constructor call or when manually constructing a `HttpLink`, `BatchHttpLink` or `ClientAwarenessLink`.)\n *\n * - If set to `\"headers\"`, `name` and `version` will be sent in the request headers as `apollographql-client-name` and `apollographql-client-version`, respectively.\n * - If set to `false`, `name` and `version` will not be included in outgoing requests.\n *\n * @defaultValue \"headers\"\n */\n transport?: \"headers\" | false;\n }\n export interface EnhancedClientAwarenessOptions {\n /**\n * Determines how the the version information of Apollo Client is sent in outgoing requests.\n *\n * - If set to `\"extensions\"`, library `name` and `version` will be sent in an object in the request extensions as `clientLibrary`.\n * - If set to `false`, library name and version will not be included in outgoing requests.\n *\n * @defaultValue \"extensions\"\n */\n transport?: \"extensions\" | false;\n }\n\n export interface Options {\n /**\n * Configures the \"client awareness\" feature.\n * This feature allows you to identify distinct applications in Apollo Studio\n * and Apollo Server logs (and other monitoring or analytics tools) by adding\n * information about the your application to outgoing requests.\n */\n clientAwareness?: ClientAwarenessLink.ClientAwarenessOptions;\n /**\n * Configures the \"enhanced client awareness\" feature.\n * This feature allows you to identify the version of the Apollo Client library\n * used in your application in Apollo Studio (and other monitoring or analytics tools)\n * by adding information about the Apollo Client library to outgoing requests.\n */\n enhancedClientAwareness?: ClientAwarenessLink.EnhancedClientAwarenessOptions;\n }\n}\n\n/**\n * `ClientAwarenessLink` provides support for providing client awareness\n * features.\n *\n * @remarks\n *\n * Client awareness adds identifying information about the client to HTTP\n * requests for use with metrics reporting tools, such as [Apollo GraphOS](https://apollographql.com/docs/graphos/platform).\n * It is included in the functionality of [`HttpLink`](https://apollographql.com/docs/react/api/link/apollo-link-http) by default.\n *\n * Client awareness distinguishes between user-provided client awareness\n * (provided by the `clientAwareness` option) and enhanced client awareness\n * (provided by the `enhancedClientAwareness` option). User-provided client\n * awareness enables you to set a customized client name and version for\n * identification in metrics reporting tools. Enhanced client awareness enables\n * the identification of the Apollo Client package name and version.\n *\n * @example\n *\n * ```ts\n * import { ClientAwarenessLink } from \"@apollo/client/link/client-awareness\";\n *\n * const link = new ClientAwarenessLink({\n * clientAwareness: {\n * name: \"My Client\",\n * version: \"1\",\n * },\n * enhancedClientAwareness: {\n * transport: \"extensions\",\n * },\n * });\n * ```\n */\nexport class ClientAwarenessLink extends ApolloLink {\n constructor(constructorOptions: ClientAwarenessLink.Options = {}) {\n super((operation, forward) => {\n const client = operation.client;\n\n const clientOptions = client[\"queryManager\"].clientOptions;\n const context = operation.getContext();\n {\n const {\n name,\n version,\n transport = \"headers\",\n } = compact(\n {},\n clientOptions.clientAwareness,\n constructorOptions.clientAwareness,\n context.clientAwareness\n );\n\n if (transport === \"headers\") {\n operation.setContext(({ headers, extensions }) => {\n return {\n headers: compact(\n // setting these first so that they can be overridden by user-provided headers\n {\n \"apollographql-client-name\": name,\n \"apollographql-client-version\": version,\n },\n headers\n ),\n };\n });\n }\n }\n {\n const { transport = \"extensions\" } = compact(\n {},\n clientOptions.enhancedClientAwareness,\n constructorOptions.enhancedClientAwareness\n );\n if (transport === \"extensions\") {\n operation.extensions = compact(\n // setting these first so that it can be overridden by user-provided extensions\n {\n clientLibrary: {\n name: \"@apollo/client\",\n version: client.version,\n },\n },\n operation.extensions\n );\n }\n }\n\n return forward(operation);\n });\n }\n}\n"]}
@@ -1,9 +1,8 @@
1
- import type { Operation, OperationContext } from "@apollo/client/link";
2
1
  import { ApolloLink } from "@apollo/client/link";
3
2
  export declare namespace SetContextLink {
4
- type ContextSetter = (prevContext: OperationContext, operation: SetContextOperation) => Promise<Partial<OperationContext>> | Partial<OperationContext>;
5
- type LegacyContextSetter = (operation: SetContextOperation, prevContext: OperationContext) => Promise<Partial<OperationContext>> | Partial<OperationContext>;
6
- type SetContextOperation = Omit<Operation, "getContext" | "setContext">;
3
+ type ContextSetter = (prevContext: ApolloLink.OperationContext, operation: SetContextOperation) => Promise<Partial<ApolloLink.OperationContext>> | Partial<ApolloLink.OperationContext>;
4
+ type LegacyContextSetter = (operation: SetContextOperation, prevContext: ApolloLink.OperationContext) => Promise<Partial<ApolloLink.OperationContext>> | Partial<ApolloLink.OperationContext>;
5
+ type SetContextOperation = Omit<ApolloLink.Operation, "getContext" | "setContext">;
7
6
  }
8
7
  /**
9
8
  * @deprecated
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAmBjD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,MAA0C;IACnE,OAAO,IAAI,cAAc,CAAC,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE,CACnD,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,CAC/B,CAAC;AACJ,CAAC;AACD,MAAM,OAAO,cAAe,SAAQ,UAAU;IAC5C,YAAY,MAAoC;QAC9C,KAAK,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;YAC3B,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,SAA+C,CAAC;YAEvE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE;gBACvC,UAAU,EAAE,KAAK;gBACjB,KAAK,EAAE,SAAS,CAAC,MAAM;aACxB,CAAC,CAAC;YAEH,OAAO,IAAI,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACjC,IAAI,MAAM,GAAG,KAAK,CAAC;gBACnB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;qBACrB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,CAAC;qBAClD,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;qBAC1B,IAAI,CAAC,GAAG,EAAE;oBACT,IAAI,CAAC,MAAM,EAAE,CAAC;wBACZ,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;oBACzC,CAAC;gBACH,CAAC,CAAC;qBACD,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAExC,OAAO,GAAG,EAAE;oBACV,MAAM,GAAG,IAAI,CAAC;gBAChB,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Observable } from \"rxjs\";\n\nimport type { Operation, OperationContext } from \"@apollo/client/link\";\nimport { ApolloLink } from \"@apollo/client/link\";\n\nexport declare namespace SetContextLink {\n export type ContextSetter = (\n prevContext: OperationContext,\n operation: SetContextOperation\n ) => Promise<Partial<OperationContext>> | Partial<OperationContext>;\n\n export type LegacyContextSetter = (\n operation: SetContextOperation,\n prevContext: OperationContext\n ) => Promise<Partial<OperationContext>> | Partial<OperationContext>;\n\n export type SetContextOperation = Omit<\n Operation,\n \"getContext\" | \"setContext\"\n >;\n}\n\n/**\n * @deprecated\n * Use `SetContextLink` from `@apollo/client/link/context` instead. Note you\n * will need to flip the arguments when using `SetContextLink` as `prevContext`\n * is the first argument.\n *\n * ```ts\n * new SetContextLink((prevContext, operation) => {\n * // ...\n * });\n * ```\n */\nexport function setContext(setter: SetContextLink.LegacyContextSetter) {\n return new SetContextLink((prevContext, operation) =>\n setter(operation, prevContext)\n );\n}\nexport class SetContextLink extends ApolloLink {\n constructor(setter: SetContextLink.ContextSetter) {\n super((operation, forward) => {\n const { ...request } = operation as SetContextLink.SetContextOperation;\n\n Object.defineProperty(request, \"client\", {\n enumerable: false,\n value: operation.client,\n });\n\n return new Observable((observer) => {\n let closed = false;\n Promise.resolve(request)\n .then((req) => setter(operation.getContext(), req))\n .then(operation.setContext)\n .then(() => {\n if (!closed) {\n forward(operation).subscribe(observer);\n }\n })\n .catch(observer.error.bind(observer));\n\n return () => {\n closed = true;\n };\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAuBjD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,MAA0C;IACnE,OAAO,IAAI,cAAc,CAAC,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE,CACnD,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,CAC/B,CAAC;AACJ,CAAC;AACD,MAAM,OAAO,cAAe,SAAQ,UAAU;IAC5C,YAAY,MAAoC;QAC9C,KAAK,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;YAC3B,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,SAA+C,CAAC;YAEvE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE;gBACvC,UAAU,EAAE,KAAK;gBACjB,KAAK,EAAE,SAAS,CAAC,MAAM;aACxB,CAAC,CAAC;YAEH,OAAO,IAAI,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACjC,IAAI,MAAM,GAAG,KAAK,CAAC;gBACnB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;qBACrB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,CAAC;qBAClD,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;qBAC1B,IAAI,CAAC,GAAG,EAAE;oBACT,IAAI,CAAC,MAAM,EAAE,CAAC;wBACZ,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;oBACzC,CAAC;gBACH,CAAC,CAAC;qBACD,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAExC,OAAO,GAAG,EAAE;oBACV,MAAM,GAAG,IAAI,CAAC;gBAChB,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Observable } from \"rxjs\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\n\nexport declare namespace SetContextLink {\n export type ContextSetter = (\n prevContext: ApolloLink.OperationContext,\n operation: SetContextOperation\n ) =>\n | Promise<Partial<ApolloLink.OperationContext>>\n | Partial<ApolloLink.OperationContext>;\n\n export type LegacyContextSetter = (\n operation: SetContextOperation,\n prevContext: ApolloLink.OperationContext\n ) =>\n | Promise<Partial<ApolloLink.OperationContext>>\n | Partial<ApolloLink.OperationContext>;\n\n export type SetContextOperation = Omit<\n ApolloLink.Operation,\n \"getContext\" | \"setContext\"\n >;\n}\n\n/**\n * @deprecated\n * Use `SetContextLink` from `@apollo/client/link/context` instead. Note you\n * will need to flip the arguments when using `SetContextLink` as `prevContext`\n * is the first argument.\n *\n * ```ts\n * new SetContextLink((prevContext, operation) => {\n * // ...\n * });\n * ```\n */\nexport function setContext(setter: SetContextLink.LegacyContextSetter) {\n return new SetContextLink((prevContext, operation) =>\n setter(operation, prevContext)\n );\n}\nexport class SetContextLink extends ApolloLink {\n constructor(setter: SetContextLink.ContextSetter) {\n super((operation, forward) => {\n const { ...request } = operation as SetContextLink.SetContextOperation;\n\n Object.defineProperty(request, \"client\", {\n enumerable: false,\n value: operation.client,\n });\n\n return new Observable((observer) => {\n let closed = false;\n Promise.resolve(request)\n .then((req) => setter(operation.getContext(), req))\n .then(operation.setContext)\n .then(() => {\n if (!closed) {\n forward(operation).subscribe(observer);\n }\n })\n .catch(observer.error.bind(observer));\n\n return () => {\n closed = true;\n };\n });\n });\n }\n}\n"]}
@@ -1,15 +1,361 @@
1
+ import type { DocumentNode, FormattedExecutionResult, OperationTypeNode } from "graphql";
1
2
  import type { Observable } from "rxjs";
2
- import type { ExecuteContext, FetchResult, GraphQLRequest, NextLink, Operation, RequestHandler } from "./types.js";
3
+ import type { ApolloClient, DefaultContext, OperationVariables } from "@apollo/client";
4
+ import type { AdditionalApolloLinkResultTypes } from "./types.js";
5
+ export declare namespace ApolloLink {
6
+ /**
7
+ * Context provided for link execution, such as the client executing the
8
+ * request. It is separate from the request operation context.
9
+ */
10
+ interface ExecuteContext {
11
+ /**
12
+ * The Apollo Client instance that executed the GraphQL request.
13
+ */
14
+ client: ApolloClient;
15
+ }
16
+ /**
17
+ * A function that when called will execute the next link in the link chain.
18
+ *
19
+ * @example
20
+ *
21
+ * ```ts
22
+ * const link = new ApolloLink((operation, forward) => {
23
+ * // process the request
24
+ *
25
+ * // Call `forward` to execute the next link in the chain
26
+ * return forward(operation);
27
+ * });
28
+ * ```
29
+ *
30
+ * @param operation - The current `ApolloLink.Operation` object for the
31
+ * request.
32
+ */
33
+ type ForwardFunction = (operation: ApolloLink.Operation) => Observable<ApolloLink.Result>;
34
+ /**
35
+ * The input object provided to `ApolloLink.execute` to send a GraphQL request through
36
+ * the link chain.
37
+ */
38
+ interface Request {
39
+ /**
40
+ * The parsed GraphQL document that will be sent with the GraphQL request to
41
+ * the server.
42
+ */
43
+ query: DocumentNode;
44
+ /**
45
+ * The variables provided for the query.
46
+ */
47
+ variables?: OperationVariables;
48
+ /**
49
+ * Context provided to the link chain. Context is not sent to the server and
50
+ * is used to communicate additional metadata from a request to individual
51
+ * links in the link chain.
52
+ */
53
+ context?: DefaultContext;
54
+ /**
55
+ * A map of extensions that will be sent with the GraphQL request to the
56
+ * server.
57
+ */
58
+ extensions?: Record<string, any>;
59
+ }
60
+ /**
61
+ * A request handler is responsible for performing some logic and executing the
62
+ * request, either by [forwarding](https://apollographql.com/docs/react/api/link/introduction#the-request-handler) the operation to the next link in the
63
+ * chain, or sending the operation to the destination that executes it, such as
64
+ * a GraphQL server.
65
+ *
66
+ * @param operation - The `Operation` object that provides information about the
67
+ * currently executed GraphQL request.
68
+ *
69
+ * @param forward - A function that is called to execute the next link in the
70
+ * chain.
71
+ */
72
+ type RequestHandler = (operation: ApolloLink.Operation, forward: ApolloLink.ForwardFunction) => Observable<ApolloLink.Result>;
73
+ type Result<TData = Record<string, any>, TExtensions = Record<string, any>> = FormattedExecutionResult<TData, TExtensions> | AdditionalApolloLinkResultTypes<TData, TExtensions>[keyof AdditionalApolloLinkResultTypes<TData, TExtensions>];
74
+ /**
75
+ * The currently executed operation object provided to an `ApolloLink.RequestHandler`
76
+ * for each link in the link chain.
77
+ */
78
+ interface Operation {
79
+ /**
80
+ * A `DocumentNode` that describes the operation taking place.
81
+ */
82
+ query: DocumentNode;
83
+ /**
84
+ * A map of GraphQL variables being sent with the operation.
85
+ */
86
+ variables: OperationVariables;
87
+ /**
88
+ * The string name of the GraphQL operation. If it is anonymous,
89
+ * `operationName` will be `undefined`.
90
+ */
91
+ operationName: string | undefined;
92
+ /**
93
+ * The type of the GraphQL operation, such as query or mutation.
94
+ */
95
+ operationType: OperationTypeNode;
96
+ /**
97
+ * A map that stores extensions data to be sent to the server.
98
+ */
99
+ extensions: Record<string, any>;
100
+ /**
101
+ * A function that takes either a new context object, or a function which
102
+ * takes in the previous context and returns a new one. See [managing
103
+ * context](https://apollographql.com/docs/react/api/link/introduction#managing-context).
104
+ */
105
+ setContext: {
106
+ (context: Partial<ApolloLink.OperationContext>): void;
107
+ (updateContext: (previousContext: Readonly<ApolloLink.OperationContext>) => Partial<ApolloLink.OperationContext>): void;
108
+ };
109
+ /**
110
+ * A function that gets the current context of the request. This can be used
111
+ * by links to determine which actions to perform. See [managing context](https://apollographql.com/docs/react/api/link/introduction#managing-context)
112
+ */
113
+ getContext: () => Readonly<ApolloLink.OperationContext>;
114
+ /**
115
+ * The Apollo Client instance executing the request.
116
+ */
117
+ readonly client: ApolloClient;
118
+ }
119
+ /**
120
+ * The `context` object that can be read and modified by links using the
121
+ * `operation.getContext()` and `operation.setContext()` methods.
122
+ */
123
+ interface OperationContext extends DefaultContext {
124
+ }
125
+ namespace DocumentationTypes {
126
+ /**
127
+ * A request handler is responsible for performing some logic and executing the
128
+ * request, either by [forwarding](https://apollographql.com/docs/react/api/link/introduction#the-request-handler) the operation to the next link in the
129
+ * chain, or sending the operation to the destination that executes it, such as
130
+ * a GraphQL server.
131
+ *
132
+ * @param operation - The `Operation` object that provides information about the
133
+ * currently executed GraphQL request.
134
+ *
135
+ * @param forward - A function that is called to execute the next link in the
136
+ * chain.
137
+ */
138
+ function RequestHandler(operation: ApolloLink.Operation, forward: ApolloLink.ForwardFunction): Observable<ApolloLink.Result>;
139
+ /**
140
+ * A function that when called will execute the next link in the link chain.
141
+ *
142
+ * @example
143
+ *
144
+ * ```ts
145
+ * const link = new ApolloLink((operation, forward) => {
146
+ * // process the request
147
+ *
148
+ * // Call `forward` to execute the next link in the chain
149
+ * return forward(operation);
150
+ * });
151
+ * ```
152
+ *
153
+ * @param operation - The current `ApolloLink.Operation` object for the
154
+ * request.
155
+ */
156
+ function ForwardFunction(operation: ApolloLink.Operation): Observable<ApolloLink.Result>;
157
+ }
158
+ }
159
+ /**
160
+ * The base class for all links in Apollo Client. A link represents either a
161
+ * self-contained modification to a GraphQL operation or a side effect (such as
162
+ * logging).
163
+ *
164
+ * @remarks
165
+ *
166
+ * Links enable you to customize Apollo Client's request flow by composing
167
+ * together different pieces of functionality into a chain of links. Each
168
+ * link represents a specific capability, such as adding authentication headers,
169
+ * retrying failed requests, batching operations, or sending requests to a
170
+ * GraphQL server.
171
+ *
172
+ * Every link must define a request handler via its constructor or by extending
173
+ * this class and implementing the `request` method.
174
+ *
175
+ * @example
176
+ *
177
+ * ```ts
178
+ * import { ApolloLink } from "@apollo/client";
179
+ *
180
+ * const link = new ApolloLink((operation, forward) => {
181
+ * console.log("Operation:", operation.operationName);
182
+ * return forward(operation);
183
+ * });
184
+ * ```
185
+ */
3
186
  export declare class ApolloLink {
187
+ /**
188
+ * Creates a link that completes immediately and does not emit a result.
189
+ *
190
+ * @example
191
+ *
192
+ * ```ts
193
+ * const link = ApolloLink.empty();
194
+ * ```
195
+ */
4
196
  static empty(): ApolloLink;
5
- static from(links: (ApolloLink | RequestHandler)[]): ApolloLink;
6
- static split(test: (op: Operation) => boolean, left: ApolloLink | RequestHandler, right?: ApolloLink | RequestHandler): ApolloLink;
7
- static execute(link: ApolloLink, operation: GraphQLRequest, context: ExecuteContext): Observable<FetchResult>;
8
- static concat(first: ApolloLink | RequestHandler, second: ApolloLink | RequestHandler): ApolloLink;
9
- constructor(request?: RequestHandler);
10
- split(test: (op: Operation) => boolean, left: ApolloLink | RequestHandler, right?: ApolloLink | RequestHandler): ApolloLink;
11
- concat(next: ApolloLink | RequestHandler): ApolloLink;
12
- request(operation: Operation, forward?: NextLink): Observable<FetchResult> | null;
197
+ /**
198
+ * Composes multiple links into a single composed link that executes each
199
+ * provided link in serial order.
200
+ *
201
+ * @example
202
+ *
203
+ * ```ts
204
+ * import { from, HttpLink, ApolloLink } from "@apollo/client";
205
+ * import { RetryLink } from "@apollo/client/link/retry";
206
+ * import MyAuthLink from "../auth";
207
+ *
208
+ * const link = ApolloLink.from([
209
+ * new RetryLink(),
210
+ * new MyAuthLink(),
211
+ * new HttpLink({ uri: "http://localhost:4000/graphql" }),
212
+ * ]);
213
+ * ```
214
+ *
215
+ * @param links - An array of `ApolloLink` instances or request handlers that
216
+ * are executed in serial order.
217
+ */
218
+ static from(links: ApolloLink[]): ApolloLink;
219
+ /**
220
+ * Creates a link that conditionally routes a request to different links.
221
+ *
222
+ * @example
223
+ *
224
+ * ```ts
225
+ * import { ApolloLink, HttpLink } from "@apollo/client";
226
+ *
227
+ * const link = ApolloLink.split(
228
+ * (operation) => operation.getContext().version === 1,
229
+ * new HttpLink({ uri: "http://localhost:4000/v1/graphql" }),
230
+ * new HttpLink({ uri: "http://localhost:4000/v2/graphql" })
231
+ * );
232
+ * ```
233
+ *
234
+ * @param test - A predicate function that receives the current `operation`
235
+ * and returns a boolean indicating which link to execute. Returning `true`
236
+ * executes the `left` link. Returning `false` executes the `right` link.
237
+ *
238
+ * @param left - The link that executes when the `test` function returns
239
+ * `true`.
240
+ *
241
+ * @param right - The link that executes when the `test` function returns
242
+ * `false`. If the `right` link is not provided, the request is forwarded to
243
+ * the next link in the chain.
244
+ */
245
+ static split(test: (op: ApolloLink.Operation) => boolean, left: ApolloLink, right?: ApolloLink): ApolloLink;
246
+ /**
247
+ * Executes a GraphQL request against a link. The `execute` function begins
248
+ * the request by calling the request handler of the link.
249
+ *
250
+ * @example
251
+ *
252
+ * ```ts
253
+ * const observable = ApolloLink.execute(link, { query, variables }, { client });
254
+ *
255
+ * observable.subscribe({
256
+ * next(value) {
257
+ * console.log("Received", value);
258
+ * },
259
+ * error(error) {
260
+ * console.error("Oops got error", error);
261
+ * },
262
+ * complete() {
263
+ * console.log("Request complete");
264
+ * },
265
+ * });
266
+ * ```
267
+ *
268
+ * @param link - The `ApolloLink` instance to execute the request.
269
+ *
270
+ * @param request - The GraphQL request details, such as the `query` and
271
+ * `variables`.
272
+ *
273
+ * @param context - The execution context for the request, such as the
274
+ * `client` making the request.
275
+ */
276
+ static execute(link: ApolloLink, request: ApolloLink.Request, context: ApolloLink.ExecuteContext): Observable<ApolloLink.Result>;
277
+ /**
278
+ * Combines multiple links into a single composed link.
279
+ *
280
+ * @example
281
+ *
282
+ * ```ts
283
+ * const link = ApolloLink.concat(firstLink, secondLink, thirdLink);
284
+ * ```
285
+ *
286
+ * @param links - The links to concatenate into a single link. Each link will
287
+ * execute in serial order.
288
+ *
289
+ * @deprecated Use `ApolloLink.from` instead. `ApolloLink.concat` will be
290
+ * removed in a future major version.
291
+ */
292
+ static concat(...links: ApolloLink[]): ApolloLink;
293
+ constructor(request?: ApolloLink.RequestHandler);
294
+ /**
295
+ * Concatenates a link that conditionally routes a request to different links.
296
+ *
297
+ * @example
298
+ *
299
+ * ```ts
300
+ * import { ApolloLink, HttpLink } from "@apollo/client";
301
+ *
302
+ * const previousLink = new ApolloLink((operation, forward) => {
303
+ * // Handle the request
304
+ *
305
+ * return forward(operation);
306
+ * });
307
+ *
308
+ * const link = previousLink.split(
309
+ * (operation) => operation.getContext().version === 1,
310
+ * new HttpLink({ uri: "http://localhost:4000/v1/graphql" }),
311
+ * new HttpLink({ uri: "http://localhost:4000/v2/graphql" })
312
+ * );
313
+ * ```
314
+ *
315
+ * @param test - A predicate function that receives the current `operation`
316
+ * and returns a boolean indicating which link to execute. Returning `true`
317
+ * executes the `left` link. Returning `false` executes the `right` link.
318
+ *
319
+ * @param left - The link that executes when the `test` function returns
320
+ * `true`.
321
+ *
322
+ * @param right - The link that executes when the `test` function returns
323
+ * `false`. If the `right` link is not provided, the request is forwarded to
324
+ * the next link in the chain.
325
+ */
326
+ split(test: (op: ApolloLink.Operation) => boolean, left: ApolloLink, right?: ApolloLink): ApolloLink;
327
+ /**
328
+ * Combines the link with other links into a single composed link.
329
+ *
330
+ * @example
331
+ *
332
+ * ```ts
333
+ * import { ApolloLink, HttpLink } from "@apollo/client";
334
+ *
335
+ * const previousLink = new ApolloLink((operation, forward) => {
336
+ * // Handle the request
337
+ *
338
+ * return forward(operation);
339
+ * });
340
+ *
341
+ * const link = previousLink.concat(
342
+ * link1,
343
+ * link2,
344
+ * new HttpLink({ uri: "http://localhost:4000/graphql" })
345
+ * );
346
+ * ```
347
+ */
348
+ concat(...links: ApolloLink[]): ApolloLink;
349
+ private combine;
350
+ /**
351
+ * Runs the request handler for the provided operation.
352
+ *
353
+ * > [!NOTE]
354
+ * > This is called by the `ApolloLink.execute` function for you and should
355
+ * > not be called directly. Prefer using `ApolloLink.execute` to make the
356
+ * > request instead.
357
+ */
358
+ request(operation: ApolloLink.Operation, forward: ApolloLink.ForwardFunction): Observable<ApolloLink.Result>;
13
359
  /**
14
360
  * @internal
15
361
  * Used to iterate through all links that are concatenations or `split` links.