@apollo/client 3.8.7 → 3.8.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 (609) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +14 -0
  3. package/CHANGELOG.md +3357 -0
  4. package/apollo-client.cjs +314 -316
  5. package/apollo-client.cjs.map +1 -1
  6. package/apollo-client.min.cjs +1 -1
  7. package/cache/cache.cjs +133 -152
  8. package/cache/cache.cjs.map +1 -1
  9. package/cache/cache.cjs.native.js +133 -152
  10. package/cache/core/cache.d.ts +10 -0
  11. package/cache/core/cache.js +17 -5
  12. package/cache/core/cache.js.map +1 -1
  13. package/cache/core/types/Cache.d.ts +1 -1
  14. package/cache/core/types/Cache.js.map +1 -1
  15. package/cache/core/types/DataProxy.d.ts +92 -0
  16. package/cache/core/types/common.js +4 -1
  17. package/cache/core/types/common.js.map +1 -1
  18. package/cache/inmemory/entityStore.d.ts +1 -1
  19. package/cache/inmemory/entityStore.js +190 -29
  20. package/cache/inmemory/entityStore.js.map +1 -1
  21. package/cache/inmemory/fixPolyfills.js +9 -0
  22. package/cache/inmemory/fixPolyfills.js.map +1 -1
  23. package/cache/inmemory/fixPolyfills.native.js +12 -0
  24. package/cache/inmemory/fixPolyfills.native.js.map +1 -1
  25. package/cache/inmemory/fragmentRegistry.js +23 -12
  26. package/cache/inmemory/fragmentRegistry.js.map +1 -1
  27. package/cache/inmemory/helpers.js +20 -11
  28. package/cache/inmemory/helpers.js.map +1 -1
  29. package/cache/inmemory/inMemoryCache.js +161 -8
  30. package/cache/inmemory/inMemoryCache.js.map +1 -1
  31. package/cache/inmemory/key-extractor.js +72 -4
  32. package/cache/inmemory/key-extractor.js.map +1 -1
  33. package/cache/inmemory/object-canon.js +91 -3
  34. package/cache/inmemory/object-canon.js.map +1 -1
  35. package/cache/inmemory/policies.js +193 -43
  36. package/cache/inmemory/policies.js.map +1 -1
  37. package/cache/inmemory/reactiveVars.js +20 -2
  38. package/cache/inmemory/reactiveVars.js.map +1 -1
  39. package/cache/inmemory/readFromStore.d.ts +4 -0
  40. package/cache/inmemory/readFromStore.js +54 -9
  41. package/cache/inmemory/readFromStore.js.map +1 -1
  42. package/cache/inmemory/types.d.ts +28 -0
  43. package/cache/inmemory/types.js.map +1 -1
  44. package/cache/inmemory/writeToStore.js +152 -25
  45. package/cache/inmemory/writeToStore.js.map +1 -1
  46. package/config/jest/setup.js +2 -0
  47. package/config/jest/setup.js.map +1 -1
  48. package/core/ApolloClient.d.ts +264 -3
  49. package/core/ApolloClient.js +235 -7
  50. package/core/ApolloClient.js.map +1 -1
  51. package/core/LocalState.d.ts +4 -6
  52. package/core/LocalState.js +56 -18
  53. package/core/LocalState.js.map +1 -1
  54. package/core/ObservableQuery.d.ts +25 -0
  55. package/core/ObservableQuery.js +239 -30
  56. package/core/ObservableQuery.js.map +1 -1
  57. package/core/QueryInfo.d.ts +3 -3
  58. package/core/QueryInfo.js +116 -13
  59. package/core/QueryInfo.js.map +1 -1
  60. package/core/QueryManager.d.ts +4 -0
  61. package/core/QueryManager.js +229 -33
  62. package/core/QueryManager.js.map +1 -1
  63. package/core/core.cjs +112 -103
  64. package/core/core.cjs.map +1 -1
  65. package/core/core.cjs.native.js +112 -103
  66. package/core/equalByQuery.js +20 -1
  67. package/core/equalByQuery.js.map +1 -1
  68. package/core/index.d.ts +1 -1
  69. package/core/index.js +19 -0
  70. package/core/index.js.map +1 -1
  71. package/core/networkStatus.d.ts +39 -0
  72. package/core/networkStatus.js +39 -0
  73. package/core/networkStatus.js.map +1 -1
  74. package/core/types.d.ts +9 -0
  75. package/core/types.js.map +1 -1
  76. package/core/watchQueryOptions.d.ts +225 -1
  77. package/core/watchQueryOptions.js.map +1 -1
  78. package/dev/dev.cjs +5 -111
  79. package/dev/dev.cjs.map +1 -1
  80. package/dev/dev.cjs.native.js +5 -111
  81. package/dev/loadErrorMessageHandler.js.map +1 -1
  82. package/errors/errors.cjs +1 -1
  83. package/errors/errors.cjs.map +1 -1
  84. package/errors/errors.cjs.native.js +1 -1
  85. package/errors/index.js +14 -1
  86. package/errors/index.js.map +1 -1
  87. package/invariantErrorCodes.js +1 -0
  88. package/link/batch/batch.cjs +2 -2
  89. package/link/batch/batch.cjs.map +1 -1
  90. package/link/batch/batch.cjs.native.js +2 -2
  91. package/link/batch/batchLink.d.ts +21 -0
  92. package/link/batch/batchLink.js +2 -1
  93. package/link/batch/batchLink.js.map +1 -1
  94. package/link/batch/batching.js +24 -1
  95. package/link/batch/batching.js.map +1 -1
  96. package/link/batch-http/batch-http.cjs +3 -2
  97. package/link/batch-http/batch-http.cjs.map +1 -1
  98. package/link/batch-http/batch-http.cjs.native.js +3 -2
  99. package/link/batch-http/batchHttpLink.d.ts +4 -0
  100. package/link/batch-http/batchHttpLink.js +53 -2
  101. package/link/batch-http/batchHttpLink.js.map +1 -1
  102. package/link/context/context.cjs.map +1 -1
  103. package/link/context/index.js +1 -0
  104. package/link/context/index.js.map +1 -1
  105. package/link/core/ApolloLink.js +12 -5
  106. package/link/core/ApolloLink.js.map +1 -1
  107. package/link/core/core.cjs +5 -5
  108. package/link/core/core.cjs.map +1 -1
  109. package/link/core/core.cjs.native.js +5 -5
  110. package/link/error/error.cjs +1 -1
  111. package/link/error/error.cjs.map +1 -1
  112. package/link/error/error.cjs.native.js +1 -1
  113. package/link/error/index.d.ts +3 -0
  114. package/link/error/index.js +4 -1
  115. package/link/error/index.js.map +1 -1
  116. package/link/http/HttpLink.d.ts +0 -2
  117. package/link/http/HttpLink.js +1 -1
  118. package/link/http/HttpLink.js.map +1 -1
  119. package/link/http/checkFetcher.js.map +1 -1
  120. package/link/http/createHttpLink.js +23 -1
  121. package/link/http/createHttpLink.js.map +1 -1
  122. package/link/http/createSignalIfSupported.d.ts +5 -0
  123. package/link/http/createSignalIfSupported.js +5 -0
  124. package/link/http/createSignalIfSupported.js.map +1 -1
  125. package/link/http/http.cjs +14 -12
  126. package/link/http/http.cjs.map +1 -1
  127. package/link/http/http.cjs.native.js +14 -12
  128. package/link/http/index.js +2 -1
  129. package/link/http/index.js.map +1 -1
  130. package/link/http/iterators/async.d.ts +4 -0
  131. package/link/http/iterators/async.js +4 -0
  132. package/link/http/iterators/async.js.map +1 -1
  133. package/link/http/iterators/nodeStream.d.ts +4 -0
  134. package/link/http/iterators/nodeStream.js +4 -0
  135. package/link/http/iterators/nodeStream.js.map +1 -1
  136. package/link/http/iterators/promise.d.ts +4 -0
  137. package/link/http/iterators/promise.js +4 -0
  138. package/link/http/iterators/promise.js.map +1 -1
  139. package/link/http/iterators/reader.d.ts +4 -0
  140. package/link/http/iterators/reader.js +4 -0
  141. package/link/http/iterators/reader.js.map +1 -1
  142. package/link/http/parseAndCheckHttpResponse.js +51 -10
  143. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  144. package/link/http/responseIterator.d.ts +4 -0
  145. package/link/http/responseIterator.js +6 -0
  146. package/link/http/responseIterator.js.map +1 -1
  147. package/link/http/rewriteURIForGET.d.ts +1 -1
  148. package/link/http/rewriteURIForGET.js +10 -0
  149. package/link/http/rewriteURIForGET.js.map +1 -1
  150. package/link/http/selectHttpOptionsAndBody.d.ts +45 -0
  151. package/link/http/selectHttpOptionsAndBody.js +23 -0
  152. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  153. package/link/http/selectURI.js.map +1 -1
  154. package/link/http/serializeFetchParameter.js.map +1 -1
  155. package/link/persisted-queries/index.js +34 -4
  156. package/link/persisted-queries/index.js.map +1 -1
  157. package/link/persisted-queries/persisted-queries.cjs +4 -4
  158. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  159. package/link/persisted-queries/persisted-queries.cjs.native.js +4 -4
  160. package/link/remove-typename/remove-typename.cjs +12 -9
  161. package/link/remove-typename/remove-typename.cjs.map +1 -1
  162. package/link/remove-typename/remove-typename.cjs.native.js +12 -9
  163. package/link/remove-typename/removeTypenameFromVariables.js +12 -9
  164. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  165. package/link/retry/delayFunction.d.ts +29 -0
  166. package/link/retry/delayFunction.js +6 -0
  167. package/link/retry/delayFunction.js.map +1 -1
  168. package/link/retry/retry.cjs +5 -5
  169. package/link/retry/retry.cjs.map +1 -1
  170. package/link/retry/retry.cjs.native.js +5 -5
  171. package/link/retry/retryFunction.d.ts +20 -0
  172. package/link/retry/retryLink.d.ts +6 -0
  173. package/link/retry/retryLink.js +31 -6
  174. package/link/retry/retryLink.js.map +1 -1
  175. package/link/schema/index.d.ts +13 -0
  176. package/link/schema/index.js +3 -3
  177. package/link/schema/index.js.map +1 -1
  178. package/link/schema/schema.cjs +3 -3
  179. package/link/schema/schema.cjs.map +1 -1
  180. package/link/schema/schema.cjs.native.js +3 -3
  181. package/link/subscriptions/index.js +35 -2
  182. package/link/subscriptions/index.js.map +1 -1
  183. package/link/subscriptions/subscriptions.cjs +3 -2
  184. package/link/subscriptions/subscriptions.cjs.map +1 -1
  185. package/link/subscriptions/subscriptions.cjs.native.js +3 -2
  186. package/link/utils/createOperation.js.map +1 -1
  187. package/link/utils/filterOperationVariables.js +4 -0
  188. package/link/utils/filterOperationVariables.js.map +1 -1
  189. package/link/utils/toPromise.js.map +1 -1
  190. package/link/utils/transformOperation.js +3 -2
  191. package/link/utils/transformOperation.js.map +1 -1
  192. package/link/utils/utils.cjs +2 -2
  193. package/link/utils/utils.cjs.map +1 -1
  194. package/link/utils/utils.cjs.native.js +2 -2
  195. package/link/utils/validateOperation.js.map +1 -1
  196. package/link/ws/index.d.ts +12 -0
  197. package/link/ws/index.js +1 -1
  198. package/link/ws/index.js.map +1 -1
  199. package/link/ws/ws.cjs +1 -1
  200. package/link/ws/ws.cjs.map +1 -1
  201. package/link/ws/ws.cjs.native.js +1 -1
  202. package/package.json +49 -38
  203. package/react/cache/QueryReference.d.ts +6 -1
  204. package/react/cache/QueryReference.js +26 -1
  205. package/react/cache/QueryReference.js.map +1 -1
  206. package/react/cache/SuspenseCache.d.ts +10 -0
  207. package/react/cache/SuspenseCache.js +1 -1
  208. package/react/cache/SuspenseCache.js.map +1 -1
  209. package/react/cache/getSuspenseCache.js.map +1 -1
  210. package/react/context/ApolloContext.d.ts +5 -0
  211. package/react/context/ApolloContext.js +10 -3
  212. package/react/context/ApolloContext.js.map +1 -1
  213. package/react/context/context.cjs +1 -3
  214. package/react/context/context.cjs.map +1 -1
  215. package/react/context/context.cjs.native.js +1 -3
  216. package/react/hoc/graphql.js.map +1 -1
  217. package/react/hoc/hoc-utils.js +3 -1
  218. package/react/hoc/hoc-utils.js.map +1 -1
  219. package/react/hoc/hoc.cjs +9 -17
  220. package/react/hoc/hoc.cjs.map +1 -1
  221. package/react/hoc/hoc.cjs.native.js +9 -17
  222. package/react/hoc/mutation-hoc.js +9 -4
  223. package/react/hoc/mutation-hoc.js.map +1 -1
  224. package/react/hoc/query-hoc.js +10 -4
  225. package/react/hoc/query-hoc.js.map +1 -1
  226. package/react/hoc/subscription-hoc.js +10 -4
  227. package/react/hoc/subscription-hoc.js.map +1 -1
  228. package/react/hoc/withApollo.js +3 -4
  229. package/react/hoc/withApollo.js.map +1 -1
  230. package/react/hooks/hooks.cjs +30 -22
  231. package/react/hooks/hooks.cjs.map +1 -1
  232. package/react/hooks/hooks.cjs.native.js +30 -22
  233. package/react/hooks/internal/__use.js +5 -0
  234. package/react/hooks/internal/__use.js.map +1 -1
  235. package/react/hooks/internal/index.js +1 -0
  236. package/react/hooks/internal/index.js.map +1 -1
  237. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  238. package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -3
  239. package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
  240. package/react/hooks/useBackgroundQuery.js +6 -0
  241. package/react/hooks/useBackgroundQuery.js.map +1 -1
  242. package/react/hooks/useFragment.js +4 -3
  243. package/react/hooks/useFragment.js.map +1 -1
  244. package/react/hooks/useLazyQuery.js +13 -4
  245. package/react/hooks/useLazyQuery.js.map +1 -1
  246. package/react/hooks/useMutation.js +8 -3
  247. package/react/hooks/useMutation.js.map +1 -1
  248. package/react/hooks/useQuery.d.ts +11 -0
  249. package/react/hooks/useQuery.js +137 -5
  250. package/react/hooks/useQuery.js.map +1 -1
  251. package/react/hooks/useReactiveVar.js +5 -0
  252. package/react/hooks/useReactiveVar.js.map +1 -1
  253. package/react/hooks/useReadQuery.d.ts +19 -0
  254. package/react/hooks/useReadQuery.js.map +1 -1
  255. package/react/hooks/useSubscription.js +5 -0
  256. package/react/hooks/useSubscription.js.map +1 -1
  257. package/react/hooks/useSuspenseQuery.js +11 -5
  258. package/react/hooks/useSuspenseQuery.js.map +1 -1
  259. package/react/hooks/useSyncExternalStore.js +53 -1
  260. package/react/hooks/useSyncExternalStore.js.map +1 -1
  261. package/react/parser/index.js +4 -5
  262. package/react/parser/index.js.map +1 -1
  263. package/react/parser/parser.cjs +2 -4
  264. package/react/parser/parser.cjs.map +1 -1
  265. package/react/parser/parser.cjs.native.js +2 -4
  266. package/react/ssr/RenderPromises.js +21 -1
  267. package/react/ssr/RenderPromises.js.map +1 -1
  268. package/react/ssr/getDataFromTree.js +18 -3
  269. package/react/ssr/getDataFromTree.js.map +1 -1
  270. package/react/ssr/ssr.cjs +6 -4
  271. package/react/ssr/ssr.cjs.map +1 -1
  272. package/react/ssr/ssr.cjs.native.js +6 -4
  273. package/react/types/types.d.ts +66 -0
  274. package/testing/core/core.cjs +14 -11
  275. package/testing/core/core.cjs.map +1 -1
  276. package/testing/core/core.cjs.native.js +14 -11
  277. package/testing/core/itAsync.d.ts +1 -1
  278. package/testing/core/itAsync.js.map +1 -1
  279. package/testing/core/mocking/mockFetch.d.ts +2 -2
  280. package/testing/core/mocking/mockFetch.js +8 -4
  281. package/testing/core/mocking/mockFetch.js.map +1 -1
  282. package/testing/core/mocking/mockLink.js +17 -7
  283. package/testing/core/mocking/mockLink.js.map +1 -1
  284. package/testing/core/mocking/mockQueryManager.js +2 -0
  285. package/testing/core/mocking/mockQueryManager.js.map +1 -1
  286. package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
  287. package/testing/core/mocking/mockSubscriptionLink.js +1 -1
  288. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  289. package/testing/core/mocking/mockWatchQuery.js +1 -1
  290. package/testing/core/mocking/mockWatchQuery.js.map +1 -1
  291. package/testing/core/observableToPromise.d.ts +17 -3
  292. package/testing/core/observableToPromise.js +5 -0
  293. package/testing/core/observableToPromise.js.map +1 -1
  294. package/testing/core/subscribeAndCount.js +3 -0
  295. package/testing/core/subscribeAndCount.js.map +1 -1
  296. package/testing/core/wait.js +2 -2
  297. package/testing/core/wait.js.map +1 -1
  298. package/testing/core/withConsoleSpy.d.ts +3 -0
  299. package/testing/core/withConsoleSpy.js +7 -1
  300. package/testing/core/withConsoleSpy.js.map +1 -1
  301. package/testing/core/wrap.js +2 -0
  302. package/testing/core/wrap.js.map +1 -1
  303. package/testing/internal/ObservableStream.js +14 -14
  304. package/testing/internal/ObservableStream.js.map +1 -1
  305. package/testing/internal/disposables/spyOnConsole.d.ts +1 -0
  306. package/testing/internal/disposables/spyOnConsole.js +2 -0
  307. package/testing/internal/disposables/spyOnConsole.js.map +1 -1
  308. package/testing/internal/disposables/withCleanup.d.ts +1 -0
  309. package/testing/internal/disposables/withCleanup.js +3 -0
  310. package/testing/internal/disposables/withCleanup.js.map +1 -1
  311. package/testing/internal/profile/Render.d.ts +28 -0
  312. package/testing/internal/profile/Render.js +12 -1
  313. package/testing/internal/profile/Render.js.map +1 -1
  314. package/testing/internal/profile/profile.d.ts +44 -7
  315. package/testing/internal/profile/profile.js +63 -51
  316. package/testing/internal/profile/profile.js.map +1 -1
  317. package/testing/internal/profile/traces.d.ts +4 -0
  318. package/testing/internal/profile/traces.js +9 -5
  319. package/testing/internal/profile/traces.js.map +1 -1
  320. package/testing/matchers/ProfiledComponent.js +27 -22
  321. package/testing/matchers/ProfiledComponent.js.map +1 -1
  322. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
  323. package/testing/matchers/toMatchDocument.js.map +1 -1
  324. package/testing/react/MockedProvider.d.ts +4 -0
  325. package/testing/react/MockedProvider.js +6 -2
  326. package/testing/react/MockedProvider.js.map +1 -1
  327. package/testing/testing.cjs +4 -2
  328. package/testing/testing.cjs.map +1 -1
  329. package/testing/testing.cjs.native.js +4 -2
  330. package/utilities/common/arrays.js +1 -0
  331. package/utilities/common/arrays.js.map +1 -1
  332. package/utilities/common/canUse.js +16 -1
  333. package/utilities/common/canUse.js.map +1 -1
  334. package/utilities/common/cloneDeep.d.ts +3 -0
  335. package/utilities/common/cloneDeep.js +5 -0
  336. package/utilities/common/cloneDeep.js.map +1 -1
  337. package/utilities/common/compact.d.ts +4 -0
  338. package/utilities/common/compact.js +4 -0
  339. package/utilities/common/compact.js.map +1 -1
  340. package/utilities/common/errorHandling.js +1 -3
  341. package/utilities/common/errorHandling.js.map +1 -1
  342. package/utilities/common/incrementalResult.js +3 -0
  343. package/utilities/common/incrementalResult.js.map +1 -1
  344. package/utilities/common/makeUniqueId.js +2 -0
  345. package/utilities/common/makeUniqueId.js.map +1 -1
  346. package/utilities/common/maybeDeepFreeze.js +3 -0
  347. package/utilities/common/maybeDeepFreeze.js.map +1 -1
  348. package/utilities/common/mergeDeep.js +12 -1
  349. package/utilities/common/mergeDeep.js.map +1 -1
  350. package/utilities/common/mergeOptions.d.ts +1 -1
  351. package/utilities/common/mergeOptions.js.map +1 -1
  352. package/utilities/common/omitDeep.js.map +1 -1
  353. package/utilities/globals/global.js +7 -1
  354. package/utilities/globals/global.js.map +1 -1
  355. package/utilities/globals/globals.cjs +4 -5
  356. package/utilities/globals/globals.cjs.map +1 -1
  357. package/utilities/globals/globals.cjs.native.js +4 -5
  358. package/utilities/globals/index.d.ts +4 -0
  359. package/utilities/globals/index.js +7 -0
  360. package/utilities/globals/index.js.map +1 -1
  361. package/utilities/globals/invariantWrappers.d.ts +40 -0
  362. package/utilities/globals/invariantWrappers.js +11 -3
  363. package/utilities/globals/invariantWrappers.js.map +1 -1
  364. package/utilities/globals/maybe.js.map +1 -1
  365. package/utilities/graphql/DocumentTransform.js +19 -6
  366. package/utilities/graphql/DocumentTransform.js.map +1 -1
  367. package/utilities/graphql/directives.js +3 -0
  368. package/utilities/graphql/directives.js.map +1 -1
  369. package/utilities/graphql/fragments.d.ts +25 -0
  370. package/utilities/graphql/fragments.js +36 -0
  371. package/utilities/graphql/fragments.js.map +1 -1
  372. package/utilities/graphql/getFromAST.d.ts +5 -0
  373. package/utilities/graphql/getFromAST.js +9 -0
  374. package/utilities/graphql/getFromAST.js.map +1 -1
  375. package/utilities/graphql/print.js.map +1 -1
  376. package/utilities/graphql/storeUtils.d.ts +14 -0
  377. package/utilities/graphql/storeUtils.js +7 -2
  378. package/utilities/graphql/storeUtils.js.map +1 -1
  379. package/utilities/graphql/transform.js +106 -7
  380. package/utilities/graphql/transform.js.map +1 -1
  381. package/utilities/observables/Concast.d.ts +1 -1
  382. package/utilities/observables/Concast.js +84 -1
  383. package/utilities/observables/Concast.js.map +1 -1
  384. package/utilities/observables/Observable.js +6 -0
  385. package/utilities/observables/Observable.js.map +1 -1
  386. package/utilities/observables/asyncMap.js +12 -3
  387. package/utilities/observables/asyncMap.js.map +1 -1
  388. package/utilities/observables/iteration.js +3 -0
  389. package/utilities/observables/iteration.js.map +1 -1
  390. package/utilities/observables/subclassing.js +14 -0
  391. package/utilities/observables/subclassing.js.map +1 -1
  392. package/utilities/policies/pagination.js +47 -3
  393. package/utilities/policies/pagination.js.map +1 -1
  394. package/utilities/promises/decoration.js +1 -0
  395. package/utilities/promises/decoration.js.map +1 -1
  396. package/utilities/types/DeepOmit.js.map +1 -1
  397. package/utilities/types/DeepPartial.d.ts +1 -1
  398. package/utilities/types/DeepPartial.js +4 -0
  399. package/utilities/types/DeepPartial.js.map +1 -1
  400. package/utilities/types/IsStrictlyAny.js.map +1 -1
  401. package/utilities/types/TODO.d.ts +3 -0
  402. package/utilities/types/TODO.js +2 -0
  403. package/utilities/types/TODO.js.map +1 -0
  404. package/utilities/utilities.cjs +31 -27
  405. package/utilities/utilities.cjs.map +1 -1
  406. package/utilities/utilities.cjs.native.js +31 -27
  407. package/version.js +1 -1
  408. package/cache/core/cache.d.ts.map +0 -1
  409. package/cache/core/types/Cache.d.ts.map +0 -1
  410. package/cache/core/types/DataProxy.d.ts.map +0 -1
  411. package/cache/core/types/common.d.ts.map +0 -1
  412. package/cache/index.d.ts.map +0 -1
  413. package/cache/inmemory/entityStore.d.ts.map +0 -1
  414. package/cache/inmemory/fixPolyfills.d.ts.map +0 -1
  415. package/cache/inmemory/fixPolyfills.native.d.ts.map +0 -1
  416. package/cache/inmemory/fragmentRegistry.d.ts.map +0 -1
  417. package/cache/inmemory/helpers.d.ts.map +0 -1
  418. package/cache/inmemory/inMemoryCache.d.ts.map +0 -1
  419. package/cache/inmemory/key-extractor.d.ts.map +0 -1
  420. package/cache/inmemory/object-canon.d.ts.map +0 -1
  421. package/cache/inmemory/policies.d.ts.map +0 -1
  422. package/cache/inmemory/reactiveVars.d.ts.map +0 -1
  423. package/cache/inmemory/readFromStore.d.ts.map +0 -1
  424. package/cache/inmemory/types.d.ts.map +0 -1
  425. package/cache/inmemory/writeToStore.d.ts.map +0 -1
  426. package/config/jest/setup.d.ts.map +0 -1
  427. package/core/ApolloClient.d.ts.map +0 -1
  428. package/core/LocalState.d.ts.map +0 -1
  429. package/core/ObservableQuery.d.ts.map +0 -1
  430. package/core/QueryInfo.d.ts.map +0 -1
  431. package/core/QueryManager.d.ts.map +0 -1
  432. package/core/equalByQuery.d.ts.map +0 -1
  433. package/core/index.d.ts.map +0 -1
  434. package/core/networkStatus.d.ts.map +0 -1
  435. package/core/types.d.ts.map +0 -1
  436. package/core/watchQueryOptions.d.ts.map +0 -1
  437. package/dev/index.d.ts.map +0 -1
  438. package/dev/loadDevMessages.d.ts.map +0 -1
  439. package/dev/loadErrorMessageHandler.d.ts.map +0 -1
  440. package/dev/loadErrorMessages.d.ts.map +0 -1
  441. package/errors/index.d.ts.map +0 -1
  442. package/index.d.ts.map +0 -1
  443. package/invariantErrorCodes.d.ts.map +0 -1
  444. package/link/batch/batchLink.d.ts.map +0 -1
  445. package/link/batch/batching.d.ts.map +0 -1
  446. package/link/batch/index.d.ts.map +0 -1
  447. package/link/batch-http/batchHttpLink.d.ts.map +0 -1
  448. package/link/batch-http/index.d.ts.map +0 -1
  449. package/link/context/index.d.ts.map +0 -1
  450. package/link/core/ApolloLink.d.ts.map +0 -1
  451. package/link/core/concat.d.ts.map +0 -1
  452. package/link/core/empty.d.ts.map +0 -1
  453. package/link/core/execute.d.ts.map +0 -1
  454. package/link/core/from.d.ts.map +0 -1
  455. package/link/core/index.d.ts.map +0 -1
  456. package/link/core/split.d.ts.map +0 -1
  457. package/link/core/types.d.ts.map +0 -1
  458. package/link/error/index.d.ts.map +0 -1
  459. package/link/http/HttpLink.d.ts.map +0 -1
  460. package/link/http/checkFetcher.d.ts.map +0 -1
  461. package/link/http/createHttpLink.d.ts.map +0 -1
  462. package/link/http/createSignalIfSupported.d.ts.map +0 -1
  463. package/link/http/index.d.ts.map +0 -1
  464. package/link/http/iterators/async.d.ts.map +0 -1
  465. package/link/http/iterators/nodeStream.d.ts.map +0 -1
  466. package/link/http/iterators/promise.d.ts.map +0 -1
  467. package/link/http/iterators/reader.d.ts.map +0 -1
  468. package/link/http/parseAndCheckHttpResponse.d.ts.map +0 -1
  469. package/link/http/responseIterator.d.ts.map +0 -1
  470. package/link/http/rewriteURIForGET.d.ts.map +0 -1
  471. package/link/http/selectHttpOptionsAndBody.d.ts.map +0 -1
  472. package/link/http/selectURI.d.ts.map +0 -1
  473. package/link/http/serializeFetchParameter.d.ts.map +0 -1
  474. package/link/persisted-queries/index.d.ts.map +0 -1
  475. package/link/remove-typename/index.d.ts.map +0 -1
  476. package/link/remove-typename/removeTypenameFromVariables.d.ts.map +0 -1
  477. package/link/retry/delayFunction.d.ts.map +0 -1
  478. package/link/retry/index.d.ts.map +0 -1
  479. package/link/retry/retryFunction.d.ts.map +0 -1
  480. package/link/retry/retryLink.d.ts.map +0 -1
  481. package/link/schema/index.d.ts.map +0 -1
  482. package/link/subscriptions/index.d.ts.map +0 -1
  483. package/link/utils/createOperation.d.ts.map +0 -1
  484. package/link/utils/filterOperationVariables.d.ts.map +0 -1
  485. package/link/utils/fromError.d.ts.map +0 -1
  486. package/link/utils/fromPromise.d.ts.map +0 -1
  487. package/link/utils/index.d.ts.map +0 -1
  488. package/link/utils/throwServerError.d.ts.map +0 -1
  489. package/link/utils/toPromise.d.ts.map +0 -1
  490. package/link/utils/transformOperation.d.ts.map +0 -1
  491. package/link/utils/validateOperation.d.ts.map +0 -1
  492. package/link/ws/index.d.ts.map +0 -1
  493. package/react/cache/QueryReference.d.ts.map +0 -1
  494. package/react/cache/SuspenseCache.d.ts.map +0 -1
  495. package/react/cache/getSuspenseCache.d.ts.map +0 -1
  496. package/react/cache/index.d.ts.map +0 -1
  497. package/react/cache/types.d.ts.map +0 -1
  498. package/react/components/Mutation.d.ts.map +0 -1
  499. package/react/components/Query.d.ts.map +0 -1
  500. package/react/components/Subscription.d.ts.map +0 -1
  501. package/react/components/index.d.ts.map +0 -1
  502. package/react/components/types.d.ts.map +0 -1
  503. package/react/context/ApolloConsumer.d.ts.map +0 -1
  504. package/react/context/ApolloContext.d.ts.map +0 -1
  505. package/react/context/ApolloProvider.d.ts.map +0 -1
  506. package/react/context/index.d.ts.map +0 -1
  507. package/react/hoc/graphql.d.ts.map +0 -1
  508. package/react/hoc/hoc-utils.d.ts.map +0 -1
  509. package/react/hoc/index.d.ts.map +0 -1
  510. package/react/hoc/mutation-hoc.d.ts.map +0 -1
  511. package/react/hoc/query-hoc.d.ts.map +0 -1
  512. package/react/hoc/subscription-hoc.d.ts.map +0 -1
  513. package/react/hoc/types.d.ts.map +0 -1
  514. package/react/hoc/withApollo.d.ts.map +0 -1
  515. package/react/hooks/constants.d.ts.map +0 -1
  516. package/react/hooks/index.d.ts.map +0 -1
  517. package/react/hooks/internal/__use.d.ts.map +0 -1
  518. package/react/hooks/internal/index.d.ts.map +0 -1
  519. package/react/hooks/internal/useDeepMemo.d.ts.map +0 -1
  520. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +0 -1
  521. package/react/hooks/useApolloClient.d.ts.map +0 -1
  522. package/react/hooks/useBackgroundQuery.d.ts.map +0 -1
  523. package/react/hooks/useFragment.d.ts.map +0 -1
  524. package/react/hooks/useLazyQuery.d.ts.map +0 -1
  525. package/react/hooks/useMutation.d.ts.map +0 -1
  526. package/react/hooks/useQuery.d.ts.map +0 -1
  527. package/react/hooks/useReactiveVar.d.ts.map +0 -1
  528. package/react/hooks/useReadQuery.d.ts.map +0 -1
  529. package/react/hooks/useSubscription.d.ts.map +0 -1
  530. package/react/hooks/useSuspenseQuery.d.ts.map +0 -1
  531. package/react/hooks/useSyncExternalStore.d.ts.map +0 -1
  532. package/react/index.d.ts.map +0 -1
  533. package/react/parser/index.d.ts.map +0 -1
  534. package/react/ssr/RenderPromises.d.ts.map +0 -1
  535. package/react/ssr/getDataFromTree.d.ts.map +0 -1
  536. package/react/ssr/index.d.ts.map +0 -1
  537. package/react/ssr/renderToStringWithData.d.ts.map +0 -1
  538. package/react/types/types.d.ts.map +0 -1
  539. package/testing/core/index.d.ts.map +0 -1
  540. package/testing/core/itAsync.d.ts.map +0 -1
  541. package/testing/core/mocking/mockClient.d.ts.map +0 -1
  542. package/testing/core/mocking/mockFetch.d.ts.map +0 -1
  543. package/testing/core/mocking/mockLink.d.ts.map +0 -1
  544. package/testing/core/mocking/mockQueryManager.d.ts.map +0 -1
  545. package/testing/core/mocking/mockSubscriptionLink.d.ts.map +0 -1
  546. package/testing/core/mocking/mockWatchQuery.d.ts.map +0 -1
  547. package/testing/core/observableToPromise.d.ts.map +0 -1
  548. package/testing/core/subscribeAndCount.d.ts.map +0 -1
  549. package/testing/core/wait.d.ts.map +0 -1
  550. package/testing/core/withConsoleSpy.d.ts.map +0 -1
  551. package/testing/core/wrap.d.ts.map +0 -1
  552. package/testing/index.d.ts.map +0 -1
  553. package/testing/internal/ObservableStream.d.ts.map +0 -1
  554. package/testing/internal/disposables/index.d.ts.map +0 -1
  555. package/testing/internal/disposables/spyOnConsole.d.ts.map +0 -1
  556. package/testing/internal/disposables/withCleanup.d.ts.map +0 -1
  557. package/testing/internal/index.d.ts.map +0 -1
  558. package/testing/internal/profile/Render.d.ts.map +0 -1
  559. package/testing/internal/profile/index.d.ts.map +0 -1
  560. package/testing/internal/profile/profile.d.ts.map +0 -1
  561. package/testing/internal/profile/traces.d.ts.map +0 -1
  562. package/testing/matchers/ProfiledComponent.d.ts.map +0 -1
  563. package/testing/matchers/index.d.ts.map +0 -1
  564. package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts.map +0 -1
  565. package/testing/matchers/toMatchDocument.d.ts.map +0 -1
  566. package/testing/react/MockedProvider.d.ts.map +0 -1
  567. package/utilities/common/arrays.d.ts.map +0 -1
  568. package/utilities/common/canUse.d.ts.map +0 -1
  569. package/utilities/common/cloneDeep.d.ts.map +0 -1
  570. package/utilities/common/compact.d.ts.map +0 -1
  571. package/utilities/common/errorHandling.d.ts.map +0 -1
  572. package/utilities/common/filterInPlace.d.ts +0 -2
  573. package/utilities/common/filterInPlace.d.ts.map +0 -1
  574. package/utilities/common/filterInPlace.js +0 -11
  575. package/utilities/common/filterInPlace.js.map +0 -1
  576. package/utilities/common/incrementalResult.d.ts.map +0 -1
  577. package/utilities/common/makeUniqueId.d.ts.map +0 -1
  578. package/utilities/common/maybeDeepFreeze.d.ts.map +0 -1
  579. package/utilities/common/mergeDeep.d.ts.map +0 -1
  580. package/utilities/common/mergeOptions.d.ts.map +0 -1
  581. package/utilities/common/objects.d.ts.map +0 -1
  582. package/utilities/common/omitDeep.d.ts.map +0 -1
  583. package/utilities/common/stringifyForDisplay.d.ts.map +0 -1
  584. package/utilities/common/stripTypename.d.ts.map +0 -1
  585. package/utilities/globals/global.d.ts.map +0 -1
  586. package/utilities/globals/index.d.ts.map +0 -1
  587. package/utilities/globals/invariantWrappers.d.ts.map +0 -1
  588. package/utilities/globals/maybe.d.ts.map +0 -1
  589. package/utilities/graphql/DocumentTransform.d.ts.map +0 -1
  590. package/utilities/graphql/directives.d.ts.map +0 -1
  591. package/utilities/graphql/fragments.d.ts.map +0 -1
  592. package/utilities/graphql/getFromAST.d.ts.map +0 -1
  593. package/utilities/graphql/operations.d.ts.map +0 -1
  594. package/utilities/graphql/print.d.ts.map +0 -1
  595. package/utilities/graphql/storeUtils.d.ts.map +0 -1
  596. package/utilities/graphql/transform.d.ts.map +0 -1
  597. package/utilities/index.d.ts.map +0 -1
  598. package/utilities/observables/Concast.d.ts.map +0 -1
  599. package/utilities/observables/Observable.d.ts.map +0 -1
  600. package/utilities/observables/asyncMap.d.ts.map +0 -1
  601. package/utilities/observables/iteration.d.ts.map +0 -1
  602. package/utilities/observables/subclassing.d.ts.map +0 -1
  603. package/utilities/policies/pagination.d.ts.map +0 -1
  604. package/utilities/promises/decoration.d.ts.map +0 -1
  605. package/utilities/types/DeepOmit.d.ts.map +0 -1
  606. package/utilities/types/DeepPartial.d.ts.map +0 -1
  607. package/utilities/types/IsStrictlyAny.d.ts.map +0 -1
  608. package/utilities/types/Primitive.d.ts.map +0 -1
  609. package/version.d.ts.map +0 -1
@@ -1,7 +1,8 @@
1
1
  import "../../utilities/globals/index.js";
2
2
  export { parseAndCheckHttpResponse } from "./parseAndCheckHttpResponse.js";
3
3
  export { serializeFetchParameter } from "./serializeFetchParameter.js";
4
- export { fallbackHttpConfig, defaultPrinter, selectHttpOptionsAndBody, selectHttpOptionsAndBodyInternal, } from "./selectHttpOptionsAndBody.js";
4
+ export { fallbackHttpConfig, defaultPrinter, selectHttpOptionsAndBody, selectHttpOptionsAndBodyInternal, // needed by ../batch-http but not public
5
+ } from "./selectHttpOptionsAndBody.js";
5
6
  export { checkFetcher } from "./checkFetcher.js";
6
7
  export { createSignalIfSupported } from "./createSignalIfSupported.js";
7
8
  export { selectURI } from "./selectURI.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAG1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,wBAAwB,EACxB,gCAAgC,GACjC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["import \"../../utilities/globals/index.js\";\n\nexport type { ServerParseError } from \"./parseAndCheckHttpResponse.js\";\nexport { parseAndCheckHttpResponse } from \"./parseAndCheckHttpResponse.js\";\nexport type { ClientParseError } from \"./serializeFetchParameter.js\";\nexport { serializeFetchParameter } from \"./serializeFetchParameter.js\";\nexport type { HttpOptions, UriFunction } from \"./selectHttpOptionsAndBody.js\";\nexport {\n fallbackHttpConfig,\n defaultPrinter,\n selectHttpOptionsAndBody,\n selectHttpOptionsAndBodyInternal, // needed by ../batch-http but not public\n} from \"./selectHttpOptionsAndBody.js\";\nexport { checkFetcher } from \"./checkFetcher.js\";\nexport { createSignalIfSupported } from \"./createSignalIfSupported.js\";\nexport { selectURI } from \"./selectURI.js\";\nexport { createHttpLink } from \"./createHttpLink.js\";\nexport { HttpLink } from \"./HttpLink.js\";\nexport { rewriteURIForGET } from \"./rewriteURIForGET.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAG1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,wBAAwB,EACxB,gCAAgC,EAAE,yCAAyC;EAC5E,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["import \"../../utilities/globals/index.js\";\n\nexport type { ServerParseError } from \"./parseAndCheckHttpResponse.js\";\nexport { parseAndCheckHttpResponse } from \"./parseAndCheckHttpResponse.js\";\nexport type { ClientParseError } from \"./serializeFetchParameter.js\";\nexport { serializeFetchParameter } from \"./serializeFetchParameter.js\";\nexport type { HttpOptions, UriFunction } from \"./selectHttpOptionsAndBody.js\";\nexport {\n fallbackHttpConfig,\n defaultPrinter,\n selectHttpOptionsAndBody,\n selectHttpOptionsAndBodyInternal, // needed by ../batch-http but not public\n} from \"./selectHttpOptionsAndBody.js\";\nexport { checkFetcher } from \"./checkFetcher.js\";\nexport { createSignalIfSupported } from \"./createSignalIfSupported.js\";\nexport { selectURI } from \"./selectURI.js\";\nexport { createHttpLink } from \"./createHttpLink.js\";\nexport { HttpLink } from \"./HttpLink.js\";\nexport { rewriteURIForGET } from \"./rewriteURIForGET.js\";\n"]}
@@ -1,2 +1,6 @@
1
+ /**
2
+ * Original source:
3
+ * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/async.ts
4
+ */
1
5
  export default function asyncIterator<T>(source: AsyncIterableIterator<T>): AsyncIterableIterator<T>;
2
6
  //# sourceMappingURL=async.d.ts.map
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Original source:
3
+ * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/async.ts
4
+ */
1
5
  export default function asyncIterator(source) {
2
6
  var _a;
3
7
  var iterator = source[Symbol.asyncIterator]();
@@ -1 +1 @@
1
- {"version":3,"file":"async.js","sourceRoot":"","sources":["../../../../src/link/http/iterators/async.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,MAAgC;;IAEhC,IAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;IAChD;YACE,IAAI;gBACF,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,CAAC;;QACD,GAAC,MAAM,CAAC,aAAa,IAArB;YACE,OAAO,IAAI,CAAC;QACd,CAAC;WACD;AACJ,CAAC","sourcesContent":["/**\n * Original source:\n * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/async.ts\n */\n\nexport default function asyncIterator<T>(\n source: AsyncIterableIterator<T>\n): AsyncIterableIterator<T> {\n const iterator = source[Symbol.asyncIterator]();\n return {\n next(): Promise<IteratorResult<T, boolean>> {\n return iterator.next();\n },\n [Symbol.asyncIterator](): AsyncIterableIterator<T> {\n return this;\n },\n };\n}\n"]}
1
+ {"version":3,"file":"async.js","sourceRoot":"","sources":["../../../../src/link/http/iterators/async.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,MAAgC;;IAEhC,IAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;IAChD;YACE,IAAI;gBACF,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;YACzB,CAAC;;QACD,GAAC,MAAM,CAAC,aAAa,IAArB;YACE,OAAO,IAAI,CAAC;QACd,CAAC;WACD;AACJ,CAAC","sourcesContent":["/**\n * Original source:\n * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/async.ts\n */\n\nexport default function asyncIterator<T>(\n source: AsyncIterableIterator<T>\n): AsyncIterableIterator<T> {\n const iterator = source[Symbol.asyncIterator]();\n return {\n next(): Promise<IteratorResult<T, boolean>> {\n return iterator.next();\n },\n [Symbol.asyncIterator](): AsyncIterableIterator<T> {\n return this;\n },\n };\n}\n"]}
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Original source:
3
+ * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/nodeStream.ts
4
+ */
1
5
  /// <reference types="node" />
2
6
  import type { Readable as NodeReadableStream } from "stream";
3
7
  export default function nodeStreamIterator<T>(stream: NodeReadableStream): AsyncIterableIterator<T>;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Original source:
3
+ * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/nodeStream.ts
4
+ */
1
5
  import { canUseAsyncIteratorSymbol } from "../../../utilities/index.js";
2
6
  export default function nodeStreamIterator(stream) {
3
7
  var cleanup = null;
@@ -1 +1 @@
1
- {"version":3,"file":"nodeStream.js","sourceRoot":"","sources":["../../../../src/link/http/iterators/nodeStream.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAOxE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,MAA0B;IAE1B,IAAI,OAAO,GAAwB,IAAI,CAAC;IACxC,IAAI,KAAK,GAAiB,IAAI,CAAC;IAC/B,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAM,IAAI,GAAc,EAAE,CAAC;IAE3B,IAAM,OAAO,GAOP,EAAE,CAAC;IAET,SAAS,MAAM,CAAC,KAAU;QACxB,IAAI,KAAK;YAAE,OAAO;QAClB,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,IAAM,UAAU,GAAG,OAAO,CAAC,KAAK,EA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IACxC,CAAC,CAAC;IACF,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC3B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAE1B,SAAS,OAAO;QACd,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM;YAC1C,IAAI,KAAK;gBAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;YAChC,IAAI,IAAI,CAAC,MAAM;gBACb,OAAO,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YAC5D,IAAI,IAAI;gBAAE,OAAO,OAAO,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAM,QAAQ,GAA0B;QACtC,IAAI;YACF,OAAO,OAAO,EAAE,CAAC;QACnB,CAAC;KACF,CAAC;IAEF,IAAI,yBAAyB,EAAE;QAC7B,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;KACH;IAED,OAAO,QAAoC,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * Original source:\n * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/nodeStream.ts\n */\n\nimport type { Readable as NodeReadableStream } from \"stream\";\nimport { canUseAsyncIteratorSymbol } from \"../../../utilities/index.js\";\n\ninterface NodeStreamIterator<T> {\n next(): Promise<IteratorResult<T, boolean | undefined>>;\n [Symbol.asyncIterator]?(): AsyncIterator<T>;\n}\n\nexport default function nodeStreamIterator<T>(\n stream: NodeReadableStream\n): AsyncIterableIterator<T> {\n let cleanup: (() => void) | null = null;\n let error: Error | null = null;\n let done = false;\n const data: unknown[] = [];\n\n const waiting: [\n (\n value:\n | IteratorResult<T, boolean | undefined>\n | PromiseLike<IteratorResult<T, boolean | undefined>>\n ) => void,\n (reason?: any) => void,\n ][] = [];\n\n function onData(chunk: any) {\n if (error) return;\n if (waiting.length) {\n const shiftedArr = waiting.shift();\n if (Array.isArray(shiftedArr) && shiftedArr[0]) {\n return shiftedArr[0]({ value: chunk, done: false });\n }\n }\n data.push(chunk);\n }\n function onError(err: Error) {\n error = err;\n const all = waiting.slice();\n all.forEach(function (pair) {\n pair[1](err);\n });\n !cleanup || cleanup();\n }\n function onEnd() {\n done = true;\n const all = waiting.slice();\n all.forEach(function (pair) {\n pair[0]({ value: undefined, done: true });\n });\n !cleanup || cleanup();\n }\n\n cleanup = function () {\n cleanup = null;\n stream.removeListener(\"data\", onData);\n stream.removeListener(\"error\", onError);\n stream.removeListener(\"end\", onEnd);\n stream.removeListener(\"finish\", onEnd);\n stream.removeListener(\"close\", onEnd);\n };\n stream.on(\"data\", onData);\n stream.on(\"error\", onError);\n stream.on(\"end\", onEnd);\n stream.on(\"finish\", onEnd);\n stream.on(\"close\", onEnd);\n\n function getNext(): Promise<IteratorResult<T, boolean | undefined>> {\n return new Promise(function (resolve, reject) {\n if (error) return reject(error);\n if (data.length)\n return resolve({ value: data.shift() as T, done: false });\n if (done) return resolve({ value: undefined, done: true });\n waiting.push([resolve, reject]);\n });\n }\n\n const iterator: NodeStreamIterator<T> = {\n next(): Promise<IteratorResult<T, boolean | undefined>> {\n return getNext();\n },\n };\n\n if (canUseAsyncIteratorSymbol) {\n iterator[Symbol.asyncIterator] = function (): AsyncIterator<T> {\n return this;\n };\n }\n\n return iterator as AsyncIterableIterator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S,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAM,QAAQ,GAA0B;QACtC,IAAI;YACF,OAAO,OAAO,EAAE,CAAC;QACnB,CAAC;KACF,CAAC;IAEF,IAAI,yBAAyB,EAAE,CAAC;QAC9B,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,QAAoC,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * Original source:\n * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/nodeStream.ts\n */\n\nimport type { Readable as NodeReadableStream } from \"stream\";\nimport { canUseAsyncIteratorSymbol } from \"../../../utilities/index.js\";\n\ninterface NodeStreamIterator<T> {\n next(): Promise<IteratorResult<T, boolean | undefined>>;\n [Symbol.asyncIterator]?(): AsyncIterator<T>;\n}\n\nexport default function nodeStreamIterator<T>(\n stream: NodeReadableStream\n): AsyncIterableIterator<T> {\n let cleanup: (() => void) | null = null;\n let error: Error | null = null;\n let done = false;\n const data: unknown[] = [];\n\n const waiting: [\n (\n value:\n | IteratorResult<T, boolean | undefined>\n | PromiseLike<IteratorResult<T, boolean | undefined>>\n ) => void,\n (reason?: any) => void,\n ][] = [];\n\n function onData(chunk: any) {\n if (error) return;\n if (waiting.length) {\n const shiftedArr = waiting.shift();\n if (Array.isArray(shiftedArr) && shiftedArr[0]) {\n return shiftedArr[0]({ value: chunk, done: false });\n }\n }\n data.push(chunk);\n }\n function onError(err: Error) {\n error = err;\n const all = waiting.slice();\n all.forEach(function (pair) {\n pair[1](err);\n });\n !cleanup || cleanup();\n }\n function onEnd() {\n done = true;\n const all = waiting.slice();\n all.forEach(function (pair) {\n pair[0]({ value: undefined, done: true });\n });\n !cleanup || cleanup();\n }\n\n cleanup = function () {\n cleanup = null;\n stream.removeListener(\"data\", onData);\n stream.removeListener(\"error\", onError);\n stream.removeListener(\"end\", onEnd);\n stream.removeListener(\"finish\", onEnd);\n stream.removeListener(\"close\", onEnd);\n };\n stream.on(\"data\", onData);\n stream.on(\"error\", onError);\n stream.on(\"end\", onEnd);\n stream.on(\"finish\", onEnd);\n stream.on(\"close\", onEnd);\n\n function getNext(): Promise<IteratorResult<T, boolean | undefined>> {\n return new Promise(function (resolve, reject) {\n if (error) return reject(error);\n if (data.length)\n return resolve({ value: data.shift() as T, done: false });\n if (done) return resolve({ value: undefined, done: true });\n waiting.push([resolve, reject]);\n });\n }\n\n const iterator: NodeStreamIterator<T> = {\n next(): Promise<IteratorResult<T, boolean | undefined>> {\n return getNext();\n },\n };\n\n if (canUseAsyncIteratorSymbol) {\n iterator[Symbol.asyncIterator] = function (): AsyncIterator<T> {\n return this;\n };\n }\n\n return iterator as AsyncIterableIterator<T>;\n}\n"]}
@@ -1,2 +1,6 @@
1
+ /**
2
+ * Original source:
3
+ * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/promise.ts
4
+ */
1
5
  export default function promiseIterator<T = ArrayBuffer>(promise: Promise<ArrayBuffer>): AsyncIterableIterator<T>;
2
6
  //# sourceMappingURL=promise.d.ts.map
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Original source:
3
+ * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/promise.ts
4
+ */
1
5
  import { canUseAsyncIteratorSymbol } from "../../../utilities/index.js";
2
6
  export default function promiseIterator(promise) {
3
7
  var resolved = false;
@@ -1 +1 @@
1
- {"version":3,"file":"promise.js","sourceRoot":"","sources":["../../../../src/link/http/iterators/promise.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAOxE,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,OAA6B;IAE7B,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,IAAM,QAAQ,GAAuB;QACnC,IAAI;YACF,IAAI,QAAQ;gBACV,OAAO,OAAO,CAAC,OAAO,CAAC;oBACrB,KAAK,EAAE,SAAS;oBAChB,IAAI,EAAE,IAAI;iBACX,CAAC,CAAC;YACL,QAAQ,GAAG,IAAI,CAAC;YAChB,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM;gBAC1C,OAAO;qBACJ,IAAI,CAAC,UAAU,KAAK;oBACnB,OAAO,CAAC,EAAE,KAAK,EAAE,KAAqB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;gBACzD,CAAC,CAAC;qBACD,KAAK,CAAC,MAAM,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;IAEF,IAAI,yBAAyB,EAAE;QAC7B,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;KACH;IAED,OAAO,QAAoC,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * Original source:\n * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/promise.ts\n */\n\nimport { canUseAsyncIteratorSymbol } from \"../../../utilities/index.js\";\n\ninterface PromiseIterator<T> {\n next(): Promise<IteratorResult<T, ArrayBuffer | undefined>>;\n [Symbol.asyncIterator]?(): AsyncIterator<T>;\n}\n\nexport default function promiseIterator<T = ArrayBuffer>(\n promise: Promise<ArrayBuffer>\n): AsyncIterableIterator<T> {\n let resolved = false;\n\n const iterator: PromiseIterator<T> = {\n next(): Promise<IteratorResult<T, ArrayBuffer | undefined>> {\n if (resolved)\n return Promise.resolve({\n value: undefined,\n done: true,\n });\n resolved = true;\n return new Promise(function (resolve, reject) {\n promise\n .then(function (value) {\n resolve({ value: value as unknown as T, done: false });\n })\n .catch(reject);\n });\n },\n };\n\n if (canUseAsyncIteratorSymbol) {\n iterator[Symbol.asyncIterator] = function (): AsyncIterator<T> {\n return this;\n };\n }\n\n return iterator as AsyncIterableIterator<T>;\n}\n"]}
1
+ {"version":3,"file":"promise.js","sourceRoot":"","sources":["../../../../src/link/http/iterators/promise.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAOxE,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,OAA6B;IAE7B,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,IAAM,QAAQ,GAAuB;QACnC,IAAI;YACF,IAAI,QAAQ;gBACV,OAAO,OAAO,CAAC,OAAO,CAAC;oBACrB,KAAK,EAAE,SAAS;oBAChB,IAAI,EAAE,IAAI;iBACX,CAAC,CAAC;YACL,QAAQ,GAAG,IAAI,CAAC;YAChB,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM;gBAC1C,OAAO;qBACJ,IAAI,CAAC,UAAU,KAAK;oBACnB,OAAO,CAAC,EAAE,KAAK,EAAE,KAAqB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;gBACzD,CAAC,CAAC;qBACD,KAAK,CAAC,MAAM,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;IAEF,IAAI,yBAAyB,EAAE,CAAC;QAC9B,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,QAAoC,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * Original source:\n * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/promise.ts\n */\n\nimport { canUseAsyncIteratorSymbol } from \"../../../utilities/index.js\";\n\ninterface PromiseIterator<T> {\n next(): Promise<IteratorResult<T, ArrayBuffer | undefined>>;\n [Symbol.asyncIterator]?(): AsyncIterator<T>;\n}\n\nexport default function promiseIterator<T = ArrayBuffer>(\n promise: Promise<ArrayBuffer>\n): AsyncIterableIterator<T> {\n let resolved = false;\n\n const iterator: PromiseIterator<T> = {\n next(): Promise<IteratorResult<T, ArrayBuffer | undefined>> {\n if (resolved)\n return Promise.resolve({\n value: undefined,\n done: true,\n });\n resolved = true;\n return new Promise(function (resolve, reject) {\n promise\n .then(function (value) {\n resolve({ value: value as unknown as T, done: false });\n })\n .catch(reject);\n });\n },\n };\n\n if (canUseAsyncIteratorSymbol) {\n iterator[Symbol.asyncIterator] = function (): AsyncIterator<T> {\n return this;\n };\n }\n\n return iterator as AsyncIterableIterator<T>;\n}\n"]}
@@ -1,2 +1,6 @@
1
+ /**
2
+ * Original source:
3
+ * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/reader.ts
4
+ */
1
5
  export default function readerIterator<T>(reader: ReadableStreamDefaultReader<T>): AsyncIterableIterator<T>;
2
6
  //# sourceMappingURL=reader.d.ts.map
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Original source:
3
+ * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/reader.ts
4
+ */
1
5
  import { canUseAsyncIteratorSymbol } from "../../../utilities/index.js";
2
6
  export default function readerIterator(reader) {
3
7
  var iterator = {
@@ -1 +1 @@
1
- {"version":3,"file":"reader.js","sourceRoot":"","sources":["../../../../src/link/http/iterators/reader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAOxE,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,MAAsC;IAEtC,IAAM,QAAQ,GAAsB;QAClC,IAAI;YACF,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;IAEF,IAAI,yBAAyB,EAAE;QAC7B,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;KACH;IAED,OAAO,QAAoC,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * Original source:\n * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/reader.ts\n */\n\nimport { canUseAsyncIteratorSymbol } from \"../../../utilities/index.js\";\n\ninterface ReaderIterator<T> {\n next(): Promise<ReadableStreamReadResult<T>>;\n [Symbol.asyncIterator]?(): AsyncIterator<T>;\n}\n\nexport default function readerIterator<T>(\n reader: ReadableStreamDefaultReader<T>\n): AsyncIterableIterator<T> {\n const iterator: ReaderIterator<T> = {\n next() {\n return reader.read();\n },\n };\n\n if (canUseAsyncIteratorSymbol) {\n iterator[Symbol.asyncIterator] = function (): AsyncIterator<T> {\n return this;\n };\n }\n\n return iterator as AsyncIterableIterator<T>;\n}\n"]}
1
+ {"version":3,"file":"reader.js","sourceRoot":"","sources":["../../../../src/link/http/iterators/reader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAOxE,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,MAAsC;IAEtC,IAAM,QAAQ,GAAsB;QAClC,IAAI;YACF,OAAO,MAAM,CAAC,IAAI,EAKjB,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,IAAI,yBAAyB,EAAE,CAAC;QAC9B,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG;YAI/B,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,QAAoC,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * Original source:\n * https://github.com/kmalakoff/response-iterator/blob/master/src/iterators/reader.ts\n */\n\nimport { canUseAsyncIteratorSymbol } from \"../../../utilities/index.js\";\n\ninterface ReaderIterator<T> {\n next(): Promise<IteratorResult<T, T | undefined>>;\n [Symbol.asyncIterator]?(): AsyncIterator<T>;\n}\n\nexport default function readerIterator<T>(\n reader: ReadableStreamDefaultReader<T>\n): AsyncIterableIterator<T> {\n const iterator: ReaderIterator<T> = {\n next() {\n return reader.read() as Promise<\n | ReadableStreamReadValueResult<T>\n // DoneResult has `value` optional, which doesn't comply with an\n // `IteratorResult`, so we assert it to `T | undefined` instead\n | Required<ReadableStreamReadDoneResult<T | undefined>>\n >;\n },\n };\n\n if (canUseAsyncIteratorSymbol) {\n iterator[Symbol.asyncIterator] = function (): AsyncIterator<\n T,\n T | undefined\n > {\n return this;\n };\n }\n\n return iterator as AsyncIterableIterator<T>;\n}\n"]}
@@ -18,8 +18,8 @@ export function readMultipartBody(response, nextValue) {
18
18
  decoder = new TextDecoder("utf-8");
19
19
  contentType = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get("content-type");
20
20
  delimiter = "boundary=";
21
- boundaryVal = (contentType === null || contentType === void 0 ? void 0 : contentType.includes(delimiter))
22
- ? contentType === null || contentType === void 0 ? void 0 : contentType.substring((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf(delimiter)) + delimiter.length).replace(/['"]/g, "").replace(/\;(.*)/gm, "").trim()
21
+ boundaryVal = (contentType === null || contentType === void 0 ? void 0 : contentType.includes(delimiter)) ?
22
+ contentType === null || contentType === void 0 ? void 0 : contentType.substring((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf(delimiter)) + delimiter.length).replace(/['"]/g, "").replace(/\;(.*)/gm, "").trim()
23
23
  : "-";
24
24
  boundary = "\r\n--".concat(boundaryVal);
25
25
  buffer = "";
@@ -27,8 +27,8 @@ export function readMultipartBody(response, nextValue) {
27
27
  running = true;
28
28
  _e.label = 1;
29
29
  case 1:
30
- if (!running) return [3, 3];
31
- return [4, iterator.next()];
30
+ if (!running) return [3 /*break*/, 3];
31
+ return [4 /*yield*/, iterator.next()];
32
32
  case 2:
33
33
  _b = _e.sent(), value = _b.value, done = _b.done;
34
34
  chunk = typeof value === "string" ? value : decoder.decode(value);
@@ -68,19 +68,24 @@ export function readMultipartBody(response, nextValue) {
68
68
  nextValue(next);
69
69
  }
70
70
  else {
71
+ // for the last chunk with only `hasNext: false`
72
+ // we don't need to call observer.next as there is no data/errors
71
73
  nextValue(result);
72
74
  }
73
75
  }
74
- else if (Object.keys(result).length === 1 &&
76
+ else if (
77
+ // If the chunk contains only a "hasNext: false", we can call
78
+ // observer.complete() immediately.
79
+ Object.keys(result).length === 1 &&
75
80
  "hasNext" in result &&
76
81
  !result.hasNext) {
77
- return [2];
82
+ return [2 /*return*/];
78
83
  }
79
84
  }
80
85
  bi = buffer.indexOf(boundary);
81
86
  }
82
- return [3, 1];
83
- case 3: return [2];
87
+ return [3 /*break*/, 1];
88
+ case 3: return [2 /*return*/];
84
89
  }
85
90
  });
86
91
  });
@@ -90,6 +95,7 @@ export function parseHeaders(headerText) {
90
95
  headerText.split("\n").forEach(function (line) {
91
96
  var i = line.indexOf(":");
92
97
  if (i > -1) {
98
+ // normalize headers to lowercase
93
99
  var name_1 = line.slice(0, i).trim().toLowerCase();
94
100
  var value = line.slice(i + 1).trim();
95
101
  headersInit[name_1] = value;
@@ -99,6 +105,7 @@ export function parseHeaders(headerText) {
99
105
  }
100
106
  export function parseJsonBody(response, bodyText) {
101
107
  if (response.status >= 300) {
108
+ // Network error
102
109
  var getResult = function () {
103
110
  try {
104
111
  return JSON.parse(bodyText);
@@ -122,7 +129,39 @@ export function parseJsonBody(response, bodyText) {
122
129
  }
123
130
  }
124
131
  export function handleError(err, observer) {
132
+ // if it is a network error, BUT there is graphql result info fire
133
+ // the next observer before calling error this gives apollo-client
134
+ // (and react-apollo) the `graphqlErrors` and `networkErrors` to
135
+ // pass to UI this should only happen if we *also* have data as
136
+ // part of the response key per the spec
125
137
  if (err.result && err.result.errors && err.result.data) {
138
+ // if we don't call next, the UI can only show networkError
139
+ // because AC didn't get any graphqlErrors this is graphql
140
+ // execution result info (i.e errors and possibly data) this is
141
+ // because there is no formal spec how errors should translate to
142
+ // http status codes. So an auth error (401) could have both data
143
+ // from a public field, errors from a private field, and a status
144
+ // of 401
145
+ // {
146
+ // user { // this will have errors
147
+ // firstName
148
+ // }
149
+ // products { // this is public so will have data
150
+ // cost
151
+ // }
152
+ // }
153
+ //
154
+ // the result of above *could* look like this:
155
+ // {
156
+ // data: { products: [{ cost: "$10" }] },
157
+ // errors: [{
158
+ // message: 'your session has timed out',
159
+ // path: []
160
+ // }]
161
+ // }
162
+ // status code of above would be a 401
163
+ // in the UI you want to show data where you can, errors as data where you can
164
+ // and use correct http status codes
126
165
  observer.next(err.result);
127
166
  }
128
167
  observer.error(err);
@@ -134,13 +173,15 @@ export function parseAndCheckHttpResponse(operations) {
134
173
  .then(function (bodyText) { return parseJsonBody(response, bodyText); })
135
174
  .then(function (result) {
136
175
  if (response.status >= 300) {
176
+ // Network error
137
177
  throwServerError(response, result, "Response not successful: Received status code ".concat(response.status));
138
178
  }
139
179
  if (!Array.isArray(result) &&
140
180
  !hasOwnProperty.call(result, "data") &&
141
181
  !hasOwnProperty.call(result, "errors")) {
142
- throwServerError(response, result, "Server response was missing for query '".concat(Array.isArray(operations)
143
- ? operations.map(function (op) { return op.operationName; })
182
+ // Data error
183
+ throwServerError(response, result, "Server response was missing for query '".concat(Array.isArray(operations) ?
184
+ operations.map(function (op) { return op.operationName; })
144
185
  : operations.operationName, "'."));
145
186
  }
146
187
  return result;
@@ -1 +1 @@
1
- {"version":3,"file":"parseAndCheckHttpResponse.js","sourceRoot":"","sources":["../../../src/link/http/parseAndCheckHttpResponse.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAG5E,IAAA,cAAc,GAAK,MAAM,CAAC,SAAS,eAArB,CAAsB;AAQ5C,MAAM,UAAgB,iBAAiB,CAErC,QAAkB,EAAE,SAA6B;;;;;;;;oBACjD,IAAI,WAAW,KAAK,SAAS,EAAE;wBAC7B,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;qBACH;oBACK,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;oBACnC,WAAW,GAAG,MAAA,QA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AAQ,CAAC,EACtC;gBAEA,gBAAgB,CACd,QAAQ,EACR,MAAM,EACN,iDACE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;oBACvB,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,UAAC,EAAE,IAAK,OAAA,EAAE,CAAC,aAAa,EAAhB,CAAgB,CAAC;oBAC1C,CAAC,CAAC,UAAU,CAAC,aAAa,OAC1B,CACL,CAAC;aACH;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IA7BJ,CA6BI,CAAC;AACT,CAAC","sourcesContent":["import { responseIterator } from \"./responseIterator.js\";\nimport type { Operation } from \"../core/index.js\";\nimport { throwServerError } from \"../utils/index.js\";\nimport { PROTOCOL_ERRORS_SYMBOL } from \"../../errors/index.js\";\nimport { isApolloPayloadResult } from \"../../utilities/common/incrementalResult.js\";\nimport type { SubscriptionObserver } from \"zen-observable-ts\";\n\nconst { hasOwnProperty } = Object.prototype;\n\nexport type ServerParseError = Error & {\n response: Response;\n statusCode: number;\n bodyText: string;\n};\n\nexport async function readMultipartBody<\n T extends object = Record<string, unknown>,\n>(response: Response, nextValue: (value: T) => void) {\n if (TextDecoder === undefined) {\n throw new Error(\n \"TextDecoder must be defined in the environment: please import a polyfill.\"\n );\n }\n const decoder = new TextDecoder(\"utf-8\");\n const contentType = response.headers?.get(\"content-type\");\n const delimiter = \"boundary=\";\n\n // parse boundary value and ignore any subsequent name/value pairs after ;\n // https://www.rfc-editor.org/rfc/rfc9110.html#name-parameters\n // e.g. multipart/mixed;boundary=\"graphql\";deferSpec=20220824\n // if no boundary is specified, default to -\n const boundaryVal = contentType?.includes(delimiter)\n ? contentType\n ?.substring(contentType?.indexOf(delimiter) + delimiter.length)\n .replace(/['\"]/g, \"\")\n .replace(/\\;(.*)/gm, \"\")\n .trim()\n : \"-\";\n\n const boundary = `\\r\\n--${boundaryVal}`;\n let buffer = \"\";\n const iterator = responseIterator(response);\n let running = true;\n\n while (running) {\n const { value, done } = await iterator.next();\n const chunk = typeof value === \"string\" ? value : decoder.decode(value);\n const searchFrom = buffer.length - boundary.length + 1;\n running = !done;\n buffer += chunk;\n let bi = buffer.indexOf(boundary, searchFrom);\n\n while (bi > -1) {\n let message: string;\n [message, buffer] = [\n buffer.slice(0, bi),\n buffer.slice(bi + boundary.length),\n ];\n const i = message.indexOf(\"\\r\\n\\r\\n\");\n const headers = parseHeaders(message.slice(0, i));\n const contentType = headers[\"content-type\"];\n if (\n contentType &&\n contentType.toLowerCase().indexOf(\"application/json\") === -1\n ) {\n throw new Error(\n \"Unsupported patch content type: application/json is required.\"\n );\n }\n // nb: Technically you'd want to slice off the beginning \"\\r\\n\" but since\n // this is going to be `JSON.parse`d there is no need.\n const body = message.slice(i);\n\n if (body) {\n const result = parseJsonBody<T>(response, body);\n if (\n Object.keys(result).length > 1 ||\n \"data\" in result ||\n \"incremental\" in result ||\n \"errors\" in result ||\n \"payload\" in result\n ) {\n if (isApolloPayloadResult(result)) {\n let next = {};\n if (\"payload\" in result) {\n next = { ...result.payload };\n }\n if (\"errors\" in result) {\n next = {\n ...next,\n extensions: {\n ...(\"extensions\" in next ? next.extensions : (null as any)),\n [PROTOCOL_ERRORS_SYMBOL]: result.errors,\n },\n };\n }\n nextValue(next as T);\n } else {\n // for the last chunk with only `hasNext: false`\n // we don't need to call observer.next as there is no data/errors\n nextValue(result);\n }\n } else if (\n // If the chunk contains only a \"hasNext: false\", we can call\n // observer.complete() immediately.\n Object.keys(result).length === 1 &&\n \"hasNext\" in result &&\n !result.hasNext\n ) {\n return;\n }\n }\n bi = buffer.indexOf(boundary);\n }\n }\n}\n\nexport function parseHeaders(headerText: string): Record<string, string> {\n const headersInit: Record<string, string> = {};\n headerText.split(\"\\n\").forEach((line) => {\n const i = line.indexOf(\":\");\n if (i > -1) {\n // normalize headers to lowercase\n const name = line.slice(0, i).trim().toLowerCase();\n const value = line.slice(i + 1).trim();\n headersInit[name] = value;\n }\n });\n return headersInit;\n}\n\nexport function parseJsonBody<T>(response: Response, bodyText: string): T {\n if (response.status >= 300) {\n // Network error\n const getResult = (): Record<string, unknown> | string => {\n try {\n return JSON.parse(bodyText);\n } catch (err) {\n return bodyText;\n }\n };\n throwServerError(\n response,\n getResult(),\n `Response not successful: Received status code ${response.status}`\n );\n }\n\n try {\n return JSON.parse(bodyText) as T;\n } catch (err) {\n const parseError = err as ServerParseError;\n parseError.name = \"ServerParseError\";\n parseError.response = response;\n parseError.statusCode = response.status;\n parseError.bodyText = bodyText;\n throw parseError;\n }\n}\n\nexport function handleError(err: any, observer: SubscriptionObserver<any>) {\n // if it is a network error, BUT there is graphql result info fire\n // the next observer before calling error this gives apollo-client\n // (and react-apollo) the `graphqlErrors` and `networkErrors` to\n // pass to UI this should only happen if we *also* have data as\n // part of the response key per the spec\n if (err.result && err.result.errors && err.result.data) {\n // if we don't call next, the UI can only show networkError\n // because AC didn't get any graphqlErrors this is graphql\n // execution result info (i.e errors and possibly data) this is\n // because there is no formal spec how errors should translate to\n // http status codes. So an auth error (401) could have both data\n // from a public field, errors from a private field, and a status\n // of 401\n // {\n // user { // this will have errors\n // firstName\n // }\n // products { // this is public so will have data\n // cost\n // }\n // }\n //\n // the result of above *could* look like this:\n // {\n // data: { products: [{ cost: \"$10\" }] },\n // errors: [{\n // message: 'your session has timed out',\n // path: []\n // }]\n // }\n // status code of above would be a 401\n // in the UI you want to show data where you can, errors as data where you can\n // and use correct http status codes\n observer.next(err.result);\n }\n\n observer.error(err);\n}\n\nexport function parseAndCheckHttpResponse(operations: Operation | Operation[]) {\n return (response: Response) =>\n response\n .text()\n .then((bodyText) => parseJsonBody(response, bodyText))\n .then((result: any) => {\n if (response.status >= 300) {\n // Network error\n throwServerError(\n response,\n result,\n `Response not successful: Received status code ${response.status}`\n );\n }\n if (\n !Array.isArray(result) &&\n !hasOwnProperty.call(result, \"data\") &&\n !hasOwnProperty.call(result, \"errors\")\n ) {\n // Data error\n throwServerError(\n response,\n result,\n `Server response was missing for query '${\n Array.isArray(operations)\n ? operations.map((op) => op.operationName)\n : operations.operationName\n }'.`\n );\n }\n return result;\n });\n}\n"]}
1
+ {"version":3,"file":"parseAndCheckHttpResponse.js","sourceRoot":"","sources":["../../../src/link/http/parseAndCheckHttpResponse.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAG5E,IAAA,cAAc,GAAK,MAAM,CAAC,SAAS,eAArB,CAAsB;AAQ5C,MAAM,UAAgB,iBAAiB,CAErC,QAAkB,EAAE,SAA6B;;;;;;;;oBACjD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;wBAC9B,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;oBACJ,CAAC;oBACK,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;oBACnC,WAAW,GAAG,MAAA,QAAQ,CAAC,OAAO,0CAAE,GAAG,CAAC,cAAc,CAAC,CAAC;oBACpD,SAAS,GAAG,WAAW,CAAC;oBAMxB,WAAW,GACf,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,CAAC,SAAS,CAAC,EAAC,CAAC;wBAChC,WAAW,aAAX,WAAW,uBAAX,WAAW,CACP,SAAS,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,SAAS,CAAC,IAAG,SAAS,CAAC,MAAM,EAC7D,OAAO,CAAC,OAAO,EAAE,EAAE,EACnB,OAAO,CAAC,UAAU,EAAE,EAAE,EACtB,IAAI,EAAE;wBACX,CAAC,CAAC,GAAG,CAAC;oBAEF,QAAQ,GAAG,gBAAS,WAAW,CAAE,CAAC;oBACpC,MAAM,GAAG,EAAE,CAAC;oBACV,QAAQ,GAA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,CAAE,CACnE,CAAC;YACJ,CAAC;YACD,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;gBACtB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;gBACpC,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EACtC,CAAC;gBACD,aAAa;gBACb,gBAAgB,CACd,QAAQ,EACR,MAAM,EACN,iDACE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;oBACzB,UAAU,CAAC,GAAG,CAAC,UAAC,EAAE,IAAK,OAAA,EAAE,CAAC,aAAa,EAAhB,CAAgB,CAAC;oBAC1C,CAAC,CAAC,UAAU,CAAC,aAAa,OACxB,CACL,CAAC;YACJ,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IA7BJ,CA6BI,CAAC;AACT,CAAC","sourcesContent":["import { responseIterator } from \"./responseIterator.js\";\nimport type { Operation } from \"../core/index.js\";\nimport { throwServerError } from \"../utils/index.js\";\nimport { PROTOCOL_ERRORS_SYMBOL } from \"../../errors/index.js\";\nimport { isApolloPayloadResult } from \"../../utilities/common/incrementalResult.js\";\nimport type { SubscriptionObserver } from \"zen-observable-ts\";\n\nconst { hasOwnProperty } = Object.prototype;\n\nexport type ServerParseError = Error & {\n response: Response;\n statusCode: number;\n bodyText: string;\n};\n\nexport async function readMultipartBody<\n T extends object = Record<string, unknown>,\n>(response: Response, nextValue: (value: T) => void) {\n if (TextDecoder === undefined) {\n throw new Error(\n \"TextDecoder must be defined in the environment: please import a polyfill.\"\n );\n }\n const decoder = new TextDecoder(\"utf-8\");\n const contentType = response.headers?.get(\"content-type\");\n const delimiter = \"boundary=\";\n\n // parse boundary value and ignore any subsequent name/value pairs after ;\n // https://www.rfc-editor.org/rfc/rfc9110.html#name-parameters\n // e.g. multipart/mixed;boundary=\"graphql\";deferSpec=20220824\n // if no boundary is specified, default to -\n const boundaryVal =\n contentType?.includes(delimiter) ?\n contentType\n ?.substring(contentType?.indexOf(delimiter) + delimiter.length)\n .replace(/['\"]/g, \"\")\n .replace(/\\;(.*)/gm, \"\")\n .trim()\n : \"-\";\n\n const boundary = `\\r\\n--${boundaryVal}`;\n let buffer = \"\";\n const iterator = responseIterator(response);\n let running = true;\n\n while (running) {\n const { value, done } = await iterator.next();\n const chunk = typeof value === \"string\" ? value : decoder.decode(value);\n const searchFrom = buffer.length - boundary.length + 1;\n running = !done;\n buffer += chunk;\n let bi = buffer.indexOf(boundary, searchFrom);\n\n while (bi > -1) {\n let message: string;\n [message, buffer] = [\n buffer.slice(0, bi),\n buffer.slice(bi + boundary.length),\n ];\n const i = message.indexOf(\"\\r\\n\\r\\n\");\n const headers = parseHeaders(message.slice(0, i));\n const contentType = headers[\"content-type\"];\n if (\n contentType &&\n contentType.toLowerCase().indexOf(\"application/json\") === -1\n ) {\n throw new Error(\n \"Unsupported patch content type: application/json is required.\"\n );\n }\n // nb: Technically you'd want to slice off the beginning \"\\r\\n\" but since\n // this is going to be `JSON.parse`d there is no need.\n const body = message.slice(i);\n\n if (body) {\n const result = parseJsonBody<T>(response, body);\n if (\n Object.keys(result).length > 1 ||\n \"data\" in result ||\n \"incremental\" in result ||\n \"errors\" in result ||\n \"payload\" in result\n ) {\n if (isApolloPayloadResult(result)) {\n let next = {};\n if (\"payload\" in result) {\n next = { ...result.payload };\n }\n if (\"errors\" in result) {\n next = {\n ...next,\n extensions: {\n ...(\"extensions\" in next ? next.extensions : (null as any)),\n [PROTOCOL_ERRORS_SYMBOL]: result.errors,\n },\n };\n }\n nextValue(next as T);\n } else {\n // for the last chunk with only `hasNext: false`\n // we don't need to call observer.next as there is no data/errors\n nextValue(result);\n }\n } else if (\n // If the chunk contains only a \"hasNext: false\", we can call\n // observer.complete() immediately.\n Object.keys(result).length === 1 &&\n \"hasNext\" in result &&\n !result.hasNext\n ) {\n return;\n }\n }\n bi = buffer.indexOf(boundary);\n }\n }\n}\n\nexport function parseHeaders(headerText: string): Record<string, string> {\n const headersInit: Record<string, string> = {};\n headerText.split(\"\\n\").forEach((line) => {\n const i = line.indexOf(\":\");\n if (i > -1) {\n // normalize headers to lowercase\n const name = line.slice(0, i).trim().toLowerCase();\n const value = line.slice(i + 1).trim();\n headersInit[name] = value;\n }\n });\n return headersInit;\n}\n\nexport function parseJsonBody<T>(response: Response, bodyText: string): T {\n if (response.status >= 300) {\n // Network error\n const getResult = (): Record<string, unknown> | string => {\n try {\n return JSON.parse(bodyText);\n } catch (err) {\n return bodyText;\n }\n };\n throwServerError(\n response,\n getResult(),\n `Response not successful: Received status code ${response.status}`\n );\n }\n\n try {\n return JSON.parse(bodyText) as T;\n } catch (err) {\n const parseError = err as ServerParseError;\n parseError.name = \"ServerParseError\";\n parseError.response = response;\n parseError.statusCode = response.status;\n parseError.bodyText = bodyText;\n throw parseError;\n }\n}\n\nexport function handleError(err: any, observer: SubscriptionObserver<any>) {\n // if it is a network error, BUT there is graphql result info fire\n // the next observer before calling error this gives apollo-client\n // (and react-apollo) the `graphqlErrors` and `networkErrors` to\n // pass to UI this should only happen if we *also* have data as\n // part of the response key per the spec\n if (err.result && err.result.errors && err.result.data) {\n // if we don't call next, the UI can only show networkError\n // because AC didn't get any graphqlErrors this is graphql\n // execution result info (i.e errors and possibly data) this is\n // because there is no formal spec how errors should translate to\n // http status codes. So an auth error (401) could have both data\n // from a public field, errors from a private field, and a status\n // of 401\n // {\n // user { // this will have errors\n // firstName\n // }\n // products { // this is public so will have data\n // cost\n // }\n // }\n //\n // the result of above *could* look like this:\n // {\n // data: { products: [{ cost: \"$10\" }] },\n // errors: [{\n // message: 'your session has timed out',\n // path: []\n // }]\n // }\n // status code of above would be a 401\n // in the UI you want to show data where you can, errors as data where you can\n // and use correct http status codes\n observer.next(err.result);\n }\n\n observer.error(err);\n}\n\nexport function parseAndCheckHttpResponse(operations: Operation | Operation[]) {\n return (response: Response) =>\n response\n .text()\n .then((bodyText) => parseJsonBody(response, bodyText))\n .then((result: any) => {\n if (response.status >= 300) {\n // Network error\n throwServerError(\n response,\n result,\n `Response not successful: Received status code ${response.status}`\n );\n }\n if (\n !Array.isArray(result) &&\n !hasOwnProperty.call(result, \"data\") &&\n !hasOwnProperty.call(result, \"errors\")\n ) {\n // Data error\n throwServerError(\n response,\n result,\n `Server response was missing for query '${\n Array.isArray(operations) ?\n operations.map((op) => op.operationName)\n : operations.operationName\n }'.`\n );\n }\n return result;\n });\n}\n"]}
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Original source:
3
+ * https://github.com/kmalakoff/response-iterator/blob/master/src/index.ts
4
+ */
1
5
  import type { Response as NodeResponse } from "node-fetch";
2
6
  export declare function responseIterator<T>(response: Response | NodeResponse): AsyncIterableIterator<T>;
3
7
  //# sourceMappingURL=responseIterator.d.ts.map
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Original source:
3
+ * https://github.com/kmalakoff/response-iterator/blob/master/src/index.ts
4
+ */
1
5
  import { canUseAsyncIteratorSymbol } from "../../utilities/index.js";
2
6
  import asyncIterator from "./iterators/async.js";
3
7
  import nodeStreamIterator from "./iterators/nodeStream.js";
@@ -30,6 +34,8 @@ export function responseIterator(response) {
30
34
  return asyncIterator(body);
31
35
  if (isReadableStream(body))
32
36
  return readerIterator(body.getReader());
37
+ // this errors without casting to ReadableStream<T>
38
+ // because Blob.stream() returns a NodeJS ReadableStream
33
39
  if (isStreamableBlob(body)) {
34
40
  return readerIterator(body.stream().getReader());
35
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"responseIterator.js","sourceRoot":"","sources":["../../../src/link/http/responseIterator.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,kBAAkB,MAAM,2BAA2B,CAAC;AAC3D,OAAO,eAAe,MAAM,wBAAwB,CAAC;AACrD,OAAO,cAAc,MAAM,uBAAuB,CAAC;AAEnD,SAAS,cAAc,CA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EnE,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Original source:\n * https://github.com/kmalakoff/response-iterator/blob/master/src/index.ts\n */\n\nimport type { Response as NodeResponse } from \"node-fetch\";\nimport type { Readable as NodeReadableStream } from \"stream\";\nimport { canUseAsyncIteratorSymbol } from \"../../utilities/index.js\";\n\nimport asyncIterator from \"./iterators/async.js\";\nimport nodeStreamIterator from \"./iterators/nodeStream.js\";\nimport promiseIterator from \"./iterators/promise.js\";\nimport readerIterator from \"./iterators/reader.js\";\n\nfunction isNodeResponse(value: any): value is NodeResponse {\n return !!(value as NodeResponse).body;\n}\n\nfunction isReadableStream(value: any): value is ReadableStream<any> {\n return !!(value as ReadableStream<any>).getReader;\n}\n\nfunction isAsyncIterableIterator(\n value: any\n): value is AsyncIterableIterator<any> {\n return !!(\n canUseAsyncIteratorSymbol &&\n (value as AsyncIterableIterator<any>)[Symbol.asyncIterator]\n );\n}\n\nfunction isStreamableBlob(value: any): value is Blob {\n return !!(value as Blob).stream;\n}\n\nfunction isBlob(value: any): value is Blob {\n return !!(value as Blob).arrayBuffer;\n}\n\nfunction isNodeReadableStream(value: any): value is NodeReadableStream {\n return !!(value as NodeReadableStream).pipe;\n}\n\nexport function responseIterator<T>(\n response: Response | NodeResponse\n): AsyncIterableIterator<T> {\n let body: unknown = response;\n\n if (isNodeResponse(response)) body = response.body;\n\n if (isAsyncIterableIterator(body)) return asyncIterator<T>(body);\n\n if (isReadableStream(body)) return readerIterator<T>(body.getReader());\n\n // this errors without casting to ReadableStream<T>\n // because Blob.stream() returns a NodeJS ReadableStream\n if (isStreamableBlob(body)) {\n return readerIterator<T>(\n (body.stream() as unknown as ReadableStream<T>).getReader()\n );\n }\n\n if (isBlob(body)) return promiseIterator<T>(body.arrayBuffer());\n\n if (isNodeReadableStream(body)) return nodeStreamIterator<T>(body);\n\n throw new Error(\n \"Unknown body type for responseIterator. Please pass a streamable response.\"\n );\n}\n"]}
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AAC,CAAC;IAEvE,mDAAmD;IACnD,wDAAwD;IACxD,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,OAAO,cAAc,CAClB,IAAI,CAAC,MAAM,EAAmC,CAAC,SAAS,EAAE,CAC5D,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC;QAAE,OAAO,eAAe,CAAI,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAEhE,IAAI,oBAAoB,CAAC,IAAI,CAAC;QAAE,OAAO,kBAAkB,CAAI,IAAI,CAAC,CAAC;IAEnE,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Original source:\n * https://github.com/kmalakoff/response-iterator/blob/master/src/index.ts\n */\n\nimport type { Response as NodeResponse } from \"node-fetch\";\nimport type { Readable as NodeReadableStream } from \"stream\";\nimport { canUseAsyncIteratorSymbol } from \"../../utilities/index.js\";\n\nimport asyncIterator from \"./iterators/async.js\";\nimport nodeStreamIterator from \"./iterators/nodeStream.js\";\nimport promiseIterator from \"./iterators/promise.js\";\nimport readerIterator from \"./iterators/reader.js\";\n\nfunction isNodeResponse(value: any): value is NodeResponse {\n return !!(value as NodeResponse).body;\n}\n\nfunction isReadableStream(value: any): value is ReadableStream<any> {\n return !!(value as ReadableStream<any>).getReader;\n}\n\nfunction isAsyncIterableIterator(\n value: any\n): value is AsyncIterableIterator<any> {\n return !!(\n canUseAsyncIteratorSymbol &&\n (value as AsyncIterableIterator<any>)[Symbol.asyncIterator]\n );\n}\n\nfunction isStreamableBlob(value: any): value is Blob {\n return !!(value as Blob).stream;\n}\n\nfunction isBlob(value: any): value is Blob {\n return !!(value as Blob).arrayBuffer;\n}\n\nfunction isNodeReadableStream(value: any): value is NodeReadableStream {\n return !!(value as NodeReadableStream).pipe;\n}\n\nexport function responseIterator<T>(\n response: Response | NodeResponse\n): AsyncIterableIterator<T> {\n let body: unknown = response;\n\n if (isNodeResponse(response)) body = response.body;\n\n if (isAsyncIterableIterator(body)) return asyncIterator<T>(body);\n\n if (isReadableStream(body)) return readerIterator<T>(body.getReader());\n\n // this errors without casting to ReadableStream<T>\n // because Blob.stream() returns a NodeJS ReadableStream\n if (isStreamableBlob(body)) {\n return readerIterator<T>(\n (body.stream() as unknown as ReadableStream<T>).getReader()\n );\n }\n\n if (isBlob(body)) return promiseIterator<T>(body.arrayBuffer());\n\n if (isNodeReadableStream(body)) return nodeStreamIterator<T>(body);\n\n throw new Error(\n \"Unknown body type for responseIterator. Please pass a streamable response.\"\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { Body } from "./selectHttpOptionsAndBody.js";
2
2
  export declare function rewriteURIForGET(chosenURI: string, body: Body): {
3
- parseError: any;
3
+ parseError: unknown;
4
4
  newURI?: undefined;
5
5
  } | {
6
6
  newURI: string;
@@ -1,5 +1,9 @@
1
1
  import { serializeFetchParameter } from "./serializeFetchParameter.js";
2
+ // For GET operations, returns the given URI rewritten with parameters, or a
3
+ // parse error.
2
4
  export function rewriteURIForGET(chosenURI, body) {
5
+ // Implement the standard HTTP GET serialization, plus 'extensions'. Note
6
+ // the extra level of JSON serialization!
3
7
  var queryParams = [];
4
8
  var addQueryParam = function (key, value) {
5
9
  queryParams.push("".concat(key, "=").concat(encodeURIComponent(value)));
@@ -30,6 +34,12 @@ export function rewriteURIForGET(chosenURI, body) {
30
34
  }
31
35
  addQueryParam("extensions", serializedExtensions);
32
36
  }
37
+ // Reconstruct the URI with added query params.
38
+ // XXX This assumes that the URI is well-formed and that it doesn't
39
+ // already contain any of these query params. We could instead use the
40
+ // URL API and take a polyfill (whatwg-url@6) for older browsers that
41
+ // don't support URLSearchParams. Note that some browsers (and
42
+ // versions of whatwg-url) support URL but not URLSearchParams!
33
43
  var fragment = "", preFragment = chosenURI;
34
44
  var fragmentStart = chosenURI.indexOf("#");
35
45
  if (fragmentStart !== -1) {
@@ -1 +1 @@
1
- {"version":3,"file":"rewriteURIForGET.js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S,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAI,aAAa,KAAK,CAAC,CAAC,EAAE;QACxB,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAC3C,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;KAClD;IACD,IAAM,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IACtE,IAAM,MAAM,GACV,WAAW,GAAG,iBAAiB,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;IACrE,OAAO,EAAE,MAAM,QAAA,EAAE,CAAC;AACpB,CAAC","sourcesContent":["import { serializeFetchParameter } from \"./serializeFetchParameter.js\";\nimport type { Body } from \"./selectHttpOptionsAndBody.js\";\n\n// For GET operations, returns the given URI rewritten with parameters, or a\n// parse error.\nexport function rewriteURIForGET(chosenURI: string, body: Body) {\n // Implement the standard HTTP GET serialization, plus 'extensions'. Note\n // the extra level of JSON serialization!\n const queryParams: string[] = [];\n const addQueryParam = (key: string, value: string) => {\n queryParams.push(`${key}=${encodeURIComponent(value)}`);\n };\n\n if (\"query\" in body) {\n addQueryParam(\"query\", body.query!);\n }\n if (body.operationName) {\n addQueryParam(\"operationName\", body.operationName);\n }\n if (body.variables) {\n let serializedVariables;\n try {\n serializedVariables = serializeFetchParameter(\n body.variables,\n \"Variables map\"\n );\n } catch (parseError) {\n return { parseError };\n }\n addQueryParam(\"variables\", serializedVariables);\n }\n if (body.extensions) {\n let serializedExtensions;\n try {\n serializedExtensions = serializeFetchParameter(\n body.extensions,\n \"Extensions map\"\n );\n } catch (parseError) {\n return { parseError };\n }\n addQueryParam(\"extensions\", serializedExtensions);\n }\n\n // Reconstruct the URI with added query params.\n // XXX This assumes that the URI is well-formed and that it doesn't\n // already contain any of these query params. We could instead use the\n // URL API and take a polyfill (whatwg-url@6) for older browsers that\n // don't support URLSearchParams. Note that some browsers (and\n // versions of whatwg-url) support URL but not URLSearchParams!\n let fragment = \"\",\n preFragment = chosenURI;\n const fragmentStart = chosenURI.indexOf(\"#\");\n if (fragmentStart !== -1) {\n fragment = chosenURI.substr(fragmentStart);\n preFragment = chosenURI.substr(0, fragmentStart);\n }\n const queryParamsPrefix = preFragment.indexOf(\"?\") === -1 ? \"?\" : \"&\";\n const newURI =\n preFragment + queryParamsPrefix + queryParams.join(\"&\") + fragment;\n return { newURI };\n}\n"]}
1
+ {"version":3,"file":"rewriteURIForGET.js","sourceRoot":"","sources":["../../../src/link/http/rewriteURIForGET.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,4EAA4E;AAC5E,eAAe;AACf,MAAM,UAAU,gBAAgB,CAAC,SAAiB,EAAE,IAAU;IAC5D,yEAAyE;IACzE,yCAAyC;IACzC,IAAM,WAAW,GAAa,EAAE,CAAC;IACjC,IAAM,aAAa,GAAG,UAAC,GAAW,EAAE,KAAa;QAC/C,WAAW,CAAC,IAAI,CAAC,UAAG,GAAG,cAAI,kBAAkB,CAAC,KAAK,CAAC,CAAE,CAAC,CAAC;IAC1D,CAAC,CAAC;IAEF,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,KAAM,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,aAAa,CAAC,eAAe,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,IAAI,mBAAmB,SAAA,CAAC;QACxB,IAAI,CAAC;YACH,mBAAmB,GAAG,uBAAuB,CAC3C,IAAI,CAAC,SAAS,EACd,eAAe,CAChB,CAAC;QACJ,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,OAAO,EAAE,UAAU,YAAA,EAAE,CAAC;QACxB,CAAC;QACD,aAAa,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,IAAI,oBAAoB,SAAA,CAAC;QACzB,IAAI,CAAC;YACH,oBAAoB,GAAG,uBAAuB,CAC5C,IAAI,CAAC,UAAU,EACf,gBAAgB,CACjB,CAAC;QACJ,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,OAAO,EAAE,UAAU,YAAA,EAAE,CAAC;QACxB,CAAC;QACD,aAAa,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;IACpD,CAAC;IAED,+CAA+C;IAC/C,mEAAmE;IACnE,0EAA0E;IAC1E,yEAAyE;IACzE,kEAAkE;IAClE,mEAAmE;IACnE,IAAI,QAAQ,GAAG,EAAE,EACf,WAAW,GAAG,SAAS,CAAC;IAC1B,IAAM,aAAa,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAI,aAAa,KAAK,CAAC,CAAC,EAAE,CAAC;QACzB,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAC3C,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;IACnD,CAAC;IACD,IAAM,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IACtE,IAAM,MAAM,GACV,WAAW,GAAG,iBAAiB,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;IACrE,OAAO,EAAE,MAAM,QAAA,EAAE,CAAC;AACpB,CAAC","sourcesContent":["import { serializeFetchParameter } from \"./serializeFetchParameter.js\";\nimport type { Body } from \"./selectHttpOptionsAndBody.js\";\n\n// For GET operations, returns the given URI rewritten with parameters, or a\n// parse error.\nexport function rewriteURIForGET(chosenURI: string, body: Body) {\n // Implement the standard HTTP GET serialization, plus 'extensions'. Note\n // the extra level of JSON serialization!\n const queryParams: string[] = [];\n const addQueryParam = (key: string, value: string) => {\n queryParams.push(`${key}=${encodeURIComponent(value)}`);\n };\n\n if (\"query\" in body) {\n addQueryParam(\"query\", body.query!);\n }\n if (body.operationName) {\n addQueryParam(\"operationName\", body.operationName);\n }\n if (body.variables) {\n let serializedVariables;\n try {\n serializedVariables = serializeFetchParameter(\n body.variables,\n \"Variables map\"\n );\n } catch (parseError) {\n return { parseError };\n }\n addQueryParam(\"variables\", serializedVariables);\n }\n if (body.extensions) {\n let serializedExtensions;\n try {\n serializedExtensions = serializeFetchParameter(\n body.extensions,\n \"Extensions map\"\n );\n } catch (parseError) {\n return { parseError };\n }\n addQueryParam(\"extensions\", serializedExtensions);\n }\n\n // Reconstruct the URI with added query params.\n // XXX This assumes that the URI is well-formed and that it doesn't\n // already contain any of these query params. We could instead use the\n // URL API and take a polyfill (whatwg-url@6) for older browsers that\n // don't support URLSearchParams. Note that some browsers (and\n // versions of whatwg-url) support URL but not URLSearchParams!\n let fragment = \"\",\n preFragment = chosenURI;\n const fragmentStart = chosenURI.indexOf(\"#\");\n if (fragmentStart !== -1) {\n fragment = chosenURI.substr(fragmentStart);\n preFragment = chosenURI.substr(0, fragmentStart);\n }\n const queryParamsPrefix = preFragment.indexOf(\"?\") === -1 ? \"?\" : \"&\";\n const newURI =\n preFragment + queryParamsPrefix + queryParams.join(\"&\") + fragment;\n return { newURI };\n}\n"]}
@@ -14,15 +14,60 @@ export interface Body {
14
14
  extensions?: Record<string, any>;
15
15
  }
16
16
  export interface HttpOptions {
17
+ /**
18
+ * The URI to use when fetching operations.
19
+ *
20
+ * Defaults to '/graphql'.
21
+ */
17
22
  uri?: string | UriFunction;
23
+ /**
24
+ * Passes the extensions field to your graphql server.
25
+ *
26
+ * Defaults to false.
27
+ */
18
28
  includeExtensions?: boolean;
29
+ /**
30
+ * A `fetch`-compatible API to use when making requests.
31
+ */
19
32
  fetch?: WindowOrWorkerGlobalScope["fetch"];
33
+ /**
34
+ * An object representing values to be sent as headers on the request.
35
+ */
20
36
  headers?: Record<string, string>;
37
+ /**
38
+ * If set to true, header names won't be automatically normalized to
39
+ * lowercase. This allows for non-http-spec-compliant servers that might
40
+ * expect capitalized header names.
41
+ */
21
42
  preserveHeaderCase?: boolean;
43
+ /**
44
+ * The credentials policy you want to use for the fetch call.
45
+ */
22
46
  credentials?: string;
47
+ /**
48
+ * Any overrides of the fetch options argument to pass to the fetch call.
49
+ */
23
50
  fetchOptions?: any;
51
+ /**
52
+ * If set to true, use the HTTP GET method for query operations. Mutations
53
+ * will still use the method specified in fetchOptions.method (which defaults
54
+ * to POST).
55
+ */
24
56
  useGETForQueries?: boolean;
57
+ /**
58
+ * If set to true, the default behavior of stripping unused variables
59
+ * from the request will be disabled.
60
+ *
61
+ * Unused variables are likely to trigger server-side validation errors,
62
+ * per https://spec.graphql.org/draft/#sec-All-Variables-Used, but this
63
+ * includeUnusedVariables option can be useful if your server deviates
64
+ * from the GraphQL specification by not strictly enforcing that rule.
65
+ */
25
66
  includeUnusedVariables?: boolean;
67
+ /**
68
+ * A function to substitute for the default query print function. Can be
69
+ * used to apply changes to the results of the print function.
70
+ */
26
71
  print?: Printer;
27
72
  }
28
73
  export interface HttpQueryOptions {
@@ -6,7 +6,20 @@ var defaultHttpOptions = {
6
6
  preserveHeaderCase: false,
7
7
  };
8
8
  var defaultHeaders = {
9
+ // headers are case insensitive (https://stackoverflow.com/a/5259004)
9
10
  accept: "*/*",
11
+ // The content-type header describes the type of the body of the request, and
12
+ // so it typically only is sent with requests that actually have bodies. One
13
+ // could imagine that Apollo Client would remove this header when constructing
14
+ // a GET request (which has no body), but we historically have not done that.
15
+ // This means that browsers will preflight all Apollo Client requests (even
16
+ // GET requests). Apollo Server's CSRF prevention feature (introduced in
17
+ // AS3.7) takes advantage of this fact and does not block requests with this
18
+ // header. If you want to drop this header from GET requests, then you should
19
+ // probably replace it with a `apollo-require-preflight` header, or servers
20
+ // with CSRF prevention enabled might block your GET request. See
21
+ // https://www.apollographql.com/docs/apollo-server/security/cors/#preventing-cross-site-request-forgery-csrf
22
+ // for more details.
10
23
  "content-type": "application/json",
11
24
  };
12
25
  var defaultOptions = {
@@ -44,10 +57,12 @@ export function selectHttpOptionsAndBodyInternal(operation, printer) {
44
57
  if (options.headers) {
45
58
  options.headers = removeDuplicateHeaders(options.headers, http.preserveHeaderCase);
46
59
  }
60
+ //The body depends on the http options
47
61
  var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;
48
62
  var body = { operationName: operationName, variables: variables };
49
63
  if (http.includeExtensions)
50
64
  body.extensions = extensions;
65
+ // not sending the query (i.e persisted queries)
51
66
  if (http.includeQuery)
52
67
  body.query = printer(query, print);
53
68
  return {
@@ -55,7 +70,11 @@ export function selectHttpOptionsAndBodyInternal(operation, printer) {
55
70
  body: body,
56
71
  };
57
72
  }
73
+ // Remove potential duplicate header names, preserving last (by insertion order).
74
+ // This is done to prevent unintentionally duplicating a header instead of
75
+ // overwriting it (See #8447 and #8449).
58
76
  function removeDuplicateHeaders(headers, preserveHeaderCase) {
77
+ // If we're not preserving the case, just remove duplicates w/ normalization.
59
78
  if (!preserveHeaderCase) {
60
79
  var normalizedHeaders_1 = Object.create(null);
61
80
  Object.keys(Object(headers)).forEach(function (name) {
@@ -63,6 +82,10 @@ function removeDuplicateHeaders(headers, preserveHeaderCase) {
63
82
  });
64
83
  return normalizedHeaders_1;
65
84
  }
85
+ // If we are preserving the case, remove duplicates w/ normalization,
86
+ // preserving the original name.
87
+ // This allows for non-http-spec-compliant servers that expect intentionally
88
+ // capitalized header names (See #6741).
66
89
  var headerData = Object.create(null);
67
90
  Object.keys(Object(headers)).forEach(function (name) {
68
91
  headerData[name.toLowerCase()] = {