@apollo/client 3.8.1 → 3.8.3

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 (432) hide show
  1. package/apollo-client.cjs +708 -575
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +253 -191
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/cache.cjs.native.js +253 -191
  7. package/cache/core/cache.d.ts +4 -4
  8. package/cache/core/cache.d.ts.map +1 -1
  9. package/cache/core/cache.js +10 -7
  10. package/cache/core/cache.js.map +1 -1
  11. package/cache/core/types/Cache.d.ts +3 -3
  12. package/cache/core/types/Cache.d.ts.map +1 -1
  13. package/cache/core/types/Cache.js +0 -1
  14. package/cache/core/types/Cache.js.map +1 -1
  15. package/cache/core/types/DataProxy.d.ts +6 -6
  16. package/cache/core/types/DataProxy.d.ts.map +1 -1
  17. package/cache/core/types/DataProxy.js.map +1 -1
  18. package/cache/core/types/common.d.ts +3 -3
  19. package/cache/core/types/common.d.ts.map +1 -1
  20. package/cache/core/types/common.js.map +1 -1
  21. package/cache/index.d.ts +20 -20
  22. package/cache/index.d.ts.map +1 -1
  23. package/cache/index.js +13 -13
  24. package/cache/index.js.map +1 -1
  25. package/cache/inmemory/entityStore.d.ts +6 -6
  26. package/cache/inmemory/entityStore.d.ts.map +1 -1
  27. package/cache/inmemory/entityStore.js +38 -30
  28. package/cache/inmemory/entityStore.js.map +1 -1
  29. package/cache/inmemory/fixPolyfills.native.d.ts.map +1 -1
  30. package/cache/inmemory/fixPolyfills.native.js +10 -9
  31. package/cache/inmemory/fixPolyfills.native.js.map +1 -1
  32. package/cache/inmemory/fragmentRegistry.d.ts.map +1 -1
  33. package/cache/inmemory/fragmentRegistry.js +6 -4
  34. package/cache/inmemory/fragmentRegistry.js.map +1 -1
  35. package/cache/inmemory/helpers.d.ts +6 -6
  36. package/cache/inmemory/helpers.d.ts.map +1 -1
  37. package/cache/inmemory/helpers.js +16 -14
  38. package/cache/inmemory/helpers.js.map +1 -1
  39. package/cache/inmemory/inMemoryCache.d.ts +9 -9
  40. package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
  41. package/cache/inmemory/inMemoryCache.js +29 -33
  42. package/cache/inmemory/inMemoryCache.js.map +1 -1
  43. package/cache/inmemory/key-extractor.d.ts.map +1 -1
  44. package/cache/inmemory/key-extractor.js +55 -49
  45. package/cache/inmemory/key-extractor.js.map +1 -1
  46. package/cache/inmemory/object-canon.d.ts.map +1 -1
  47. package/cache/inmemory/object-canon.js +5 -5
  48. package/cache/inmemory/object-canon.js.map +1 -1
  49. package/cache/inmemory/policies.d.ts +6 -6
  50. package/cache/inmemory/policies.d.ts.map +1 -1
  51. package/cache/inmemory/policies.js +74 -45
  52. package/cache/inmemory/policies.js.map +1 -1
  53. package/cache/inmemory/reactiveVars.d.ts +1 -1
  54. package/cache/inmemory/reactiveVars.d.ts.map +1 -1
  55. package/cache/inmemory/reactiveVars.js +5 -5
  56. package/cache/inmemory/reactiveVars.js.map +1 -1
  57. package/cache/inmemory/readFromStore.d.ts +7 -7
  58. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  59. package/cache/inmemory/readFromStore.js +21 -17
  60. package/cache/inmemory/readFromStore.js.map +1 -1
  61. package/cache/inmemory/types.d.ts +7 -7
  62. package/cache/inmemory/types.d.ts.map +1 -1
  63. package/cache/inmemory/types.js +0 -2
  64. package/cache/inmemory/types.js.map +1 -1
  65. package/cache/inmemory/writeToStore.d.ts +7 -7
  66. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  67. package/cache/inmemory/writeToStore.js +40 -30
  68. package/cache/inmemory/writeToStore.js.map +1 -1
  69. package/config/jest/setup.d.ts +2 -2
  70. package/config/jest/setup.js +5 -5
  71. package/config/jest/setup.js.map +1 -1
  72. package/core/ApolloClient.d.ts +12 -11
  73. package/core/ApolloClient.d.ts.map +1 -1
  74. package/core/ApolloClient.js +75 -57
  75. package/core/ApolloClient.js.map +1 -1
  76. package/core/LocalState.d.ts +6 -6
  77. package/core/LocalState.d.ts.map +1 -1
  78. package/core/LocalState.js +17 -16
  79. package/core/LocalState.js.map +1 -1
  80. package/core/ObservableQuery.d.ts +12 -10
  81. package/core/ObservableQuery.d.ts.map +1 -1
  82. package/core/ObservableQuery.js +57 -38
  83. package/core/ObservableQuery.js.map +1 -1
  84. package/core/QueryInfo.d.ts +11 -11
  85. package/core/QueryInfo.d.ts.map +1 -1
  86. package/core/QueryInfo.js +28 -34
  87. package/core/QueryInfo.js.map +1 -1
  88. package/core/QueryManager.d.ts +10 -10
  89. package/core/QueryManager.d.ts.map +1 -1
  90. package/core/QueryManager.js +117 -93
  91. package/core/QueryManager.js.map +1 -1
  92. package/core/core.cjs +266 -206
  93. package/core/core.cjs.map +1 -1
  94. package/core/core.cjs.native.js +266 -206
  95. package/core/networkStatus.js.map +1 -1
  96. package/core/types.d.ts +13 -13
  97. package/core/types.d.ts.map +1 -1
  98. package/core/types.js +0 -1
  99. package/core/types.js.map +1 -1
  100. package/core/watchQueryOptions.d.ts +11 -11
  101. package/core/watchQueryOptions.d.ts.map +1 -1
  102. package/core/watchQueryOptions.js.map +1 -1
  103. package/dev/dev.cjs +44 -40
  104. package/dev/dev.cjs.map +1 -1
  105. package/dev/dev.cjs.native.js +44 -40
  106. package/errors/errors.cjs +7 -5
  107. package/errors/errors.cjs.map +1 -1
  108. package/errors/errors.cjs.native.js +7 -5
  109. package/errors/index.d.ts +4 -4
  110. package/errors/index.d.ts.map +1 -1
  111. package/errors/index.js +9 -7
  112. package/errors/index.js.map +1 -1
  113. package/index.d.ts +2 -2
  114. package/index.js +2 -2
  115. package/index.js.map +1 -1
  116. package/invariantErrorCodes.d.ts.map +1 -1
  117. package/invariantErrorCodes.js +36 -36
  118. package/invariantErrorCodes.js.map +1 -1
  119. package/link/batch/batch.cjs +4 -4
  120. package/link/batch/batch.cjs.map +1 -1
  121. package/link/batch/batch.cjs.native.js +4 -4
  122. package/link/batch/batchLink.d.ts +6 -6
  123. package/link/batch/batchLink.d.ts.map +1 -1
  124. package/link/batch/batchLink.js +4 -4
  125. package/link/batch/batchLink.js.map +1 -1
  126. package/link/batch/batching.d.ts +2 -2
  127. package/link/batch/batching.d.ts.map +1 -1
  128. package/link/batch/batching.js +4 -4
  129. package/link/batch/batching.js.map +1 -1
  130. package/link/batch/index.d.ts +1 -1
  131. package/link/batch/index.js +1 -1
  132. package/link/batch/index.js.map +1 -1
  133. package/link/batch-http/batch-http.cjs +13 -11
  134. package/link/batch-http/batch-http.cjs.map +1 -1
  135. package/link/batch-http/batch-http.cjs.native.js +13 -11
  136. package/link/batch-http/batchHttpLink.d.ts +6 -6
  137. package/link/batch-http/batchHttpLink.d.ts.map +1 -1
  138. package/link/batch-http/batchHttpLink.js +17 -15
  139. package/link/batch-http/batchHttpLink.js.map +1 -1
  140. package/link/batch-http/index.d.ts +1 -1
  141. package/link/batch-http/index.js +1 -1
  142. package/link/batch-http/index.js.map +1 -1
  143. package/link/context/context.cjs.map +1 -1
  144. package/link/context/index.d.ts +3 -3
  145. package/link/context/index.js +2 -2
  146. package/link/context/index.js.map +1 -1
  147. package/link/core/ApolloLink.d.ts +3 -3
  148. package/link/core/ApolloLink.js +4 -4
  149. package/link/core/ApolloLink.js.map +1 -1
  150. package/link/core/concat.d.ts +1 -1
  151. package/link/core/concat.js +1 -1
  152. package/link/core/concat.js.map +1 -1
  153. package/link/core/core.cjs +1 -1
  154. package/link/core/core.cjs.map +1 -1
  155. package/link/core/core.cjs.native.js +1 -1
  156. package/link/core/empty.d.ts +1 -1
  157. package/link/core/empty.js +1 -1
  158. package/link/core/empty.js.map +1 -1
  159. package/link/core/execute.d.ts +1 -1
  160. package/link/core/execute.js +1 -1
  161. package/link/core/execute.js.map +1 -1
  162. package/link/core/from.d.ts +1 -1
  163. package/link/core/from.js +1 -1
  164. package/link/core/from.js.map +1 -1
  165. package/link/core/index.d.ts +8 -8
  166. package/link/core/index.js +8 -8
  167. package/link/core/index.js.map +1 -1
  168. package/link/core/split.d.ts +1 -1
  169. package/link/core/split.js +1 -1
  170. package/link/core/split.js.map +1 -1
  171. package/link/core/types.js.map +1 -1
  172. package/link/error/error.cjs.map +1 -1
  173. package/link/error/index.d.ts +5 -5
  174. package/link/error/index.js +2 -2
  175. package/link/error/index.js.map +1 -1
  176. package/link/http/HttpLink.d.ts +3 -3
  177. package/link/http/HttpLink.js +2 -2
  178. package/link/http/HttpLink.js.map +1 -1
  179. package/link/http/checkFetcher.d.ts +1 -1
  180. package/link/http/checkFetcher.d.ts.map +1 -1
  181. package/link/http/checkFetcher.js +2 -2
  182. package/link/http/checkFetcher.js.map +1 -1
  183. package/link/http/createHttpLink.d.ts +2 -2
  184. package/link/http/createHttpLink.d.ts.map +1 -1
  185. package/link/http/createHttpLink.js +27 -26
  186. package/link/http/createHttpLink.js.map +1 -1
  187. package/link/http/createSignalIfSupported.js +1 -1
  188. package/link/http/createSignalIfSupported.js.map +1 -1
  189. package/link/http/http.cjs +39 -35
  190. package/link/http/http.cjs.map +1 -1
  191. package/link/http/http.cjs.native.js +39 -35
  192. package/link/http/index.d.ts +13 -13
  193. package/link/http/index.js +10 -10
  194. package/link/http/index.js.map +1 -1
  195. package/link/http/iterators/nodeStream.d.ts.map +1 -1
  196. package/link/http/iterators/nodeStream.js.map +1 -1
  197. package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
  198. package/link/http/parseAndCheckHttpResponse.js +2 -2
  199. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  200. package/link/http/rewriteURIForGET.d.ts +1 -1
  201. package/link/http/rewriteURIForGET.js +12 -12
  202. package/link/http/rewriteURIForGET.js.map +1 -1
  203. package/link/http/selectHttpOptionsAndBody.d.ts +5 -5
  204. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  205. package/link/http/selectHttpOptionsAndBody.js +8 -7
  206. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  207. package/link/http/selectURI.d.ts +1 -1
  208. package/link/http/selectURI.js +2 -2
  209. package/link/http/selectURI.js.map +1 -1
  210. package/link/http/serializeFetchParameter.d.ts +1 -1
  211. package/link/http/serializeFetchParameter.js +1 -1
  212. package/link/http/serializeFetchParameter.js.map +1 -1
  213. package/link/persisted-queries/index.d.ts +4 -4
  214. package/link/persisted-queries/index.d.ts.map +1 -1
  215. package/link/persisted-queries/index.js +26 -25
  216. package/link/persisted-queries/index.js.map +1 -1
  217. package/link/persisted-queries/persisted-queries.cjs +22 -17
  218. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  219. package/link/persisted-queries/persisted-queries.cjs.native.js +22 -17
  220. package/link/retry/delayFunction.d.ts +1 -1
  221. package/link/retry/delayFunction.js.map +1 -1
  222. package/link/retry/index.d.ts +1 -1
  223. package/link/retry/index.js +1 -1
  224. package/link/retry/index.js.map +1 -1
  225. package/link/retry/retry.cjs +2 -2
  226. package/link/retry/retry.cjs.map +1 -1
  227. package/link/retry/retry.cjs.native.js +2 -2
  228. package/link/retry/retryFunction.d.ts +1 -1
  229. package/link/retry/retryFunction.js.map +1 -1
  230. package/link/retry/retryLink.d.ts +5 -5
  231. package/link/retry/retryLink.d.ts.map +1 -1
  232. package/link/retry/retryLink.js +6 -6
  233. package/link/retry/retryLink.js.map +1 -1
  234. package/link/schema/index.d.ts +4 -4
  235. package/link/schema/index.d.ts.map +1 -1
  236. package/link/schema/index.js +13 -8
  237. package/link/schema/index.js.map +1 -1
  238. package/link/schema/schema.cjs +10 -5
  239. package/link/schema/schema.cjs.map +1 -1
  240. package/link/schema/schema.cjs.native.js +10 -5
  241. package/link/subscriptions/index.js +1 -1
  242. package/link/subscriptions/index.js.map +1 -1
  243. package/link/subscriptions/subscriptions.cjs.map +1 -1
  244. package/link/utils/createOperation.d.ts +1 -1
  245. package/link/utils/createOperation.js +3 -3
  246. package/link/utils/createOperation.js.map +1 -1
  247. package/link/utils/filterOperationVariables.d.ts +1 -1
  248. package/link/utils/filterOperationVariables.js +2 -2
  249. package/link/utils/filterOperationVariables.js.map +1 -1
  250. package/link/utils/fromError.d.ts +1 -1
  251. package/link/utils/fromError.js +1 -1
  252. package/link/utils/fromError.js.map +1 -1
  253. package/link/utils/fromPromise.d.ts +1 -1
  254. package/link/utils/fromPromise.js +1 -1
  255. package/link/utils/fromPromise.js.map +1 -1
  256. package/link/utils/index.d.ts +10 -10
  257. package/link/utils/index.js +9 -9
  258. package/link/utils/index.js.map +1 -1
  259. package/link/utils/throwServerError.js +1 -1
  260. package/link/utils/throwServerError.js.map +1 -1
  261. package/link/utils/toPromise.d.ts +1 -1
  262. package/link/utils/toPromise.js +1 -1
  263. package/link/utils/toPromise.js.map +1 -1
  264. package/link/utils/transformOperation.d.ts +1 -1
  265. package/link/utils/transformOperation.js +3 -3
  266. package/link/utils/transformOperation.js.map +1 -1
  267. package/link/utils/utils.cjs +12 -12
  268. package/link/utils/utils.cjs.map +1 -1
  269. package/link/utils/utils.cjs.native.js +12 -12
  270. package/link/utils/validateOperation.d.ts +1 -1
  271. package/link/utils/validateOperation.js +6 -6
  272. package/link/utils/validateOperation.js.map +1 -1
  273. package/link/ws/index.d.ts +5 -5
  274. package/link/ws/index.js +2 -2
  275. package/link/ws/index.js.map +1 -1
  276. package/link/ws/ws.cjs.map +1 -1
  277. package/package.json +22 -22
  278. package/react/cache/QueryReference.d.ts +1 -1
  279. package/react/cache/QueryReference.d.ts.map +1 -1
  280. package/react/cache/QueryReference.js +2 -0
  281. package/react/cache/QueryReference.js.map +1 -1
  282. package/react/hooks/constants.js +1 -1
  283. package/react/hooks/constants.js.map +1 -1
  284. package/react/hooks/hooks.cjs +10 -21
  285. package/react/hooks/hooks.cjs.map +1 -1
  286. package/react/hooks/hooks.cjs.native.js +10 -21
  287. package/react/hooks/useBackgroundQuery.d.ts +1 -1
  288. package/react/hooks/useBackgroundQuery.d.ts.map +1 -1
  289. package/react/hooks/useBackgroundQuery.js.map +1 -1
  290. package/react/hooks/useQuery.d.ts.map +1 -1
  291. package/react/hooks/useQuery.js +1 -8
  292. package/react/hooks/useQuery.js.map +1 -1
  293. package/react/hooks/useReactiveVar.d.ts.map +1 -1
  294. package/react/hooks/useReactiveVar.js +7 -12
  295. package/react/hooks/useReactiveVar.js.map +1 -1
  296. package/react/hooks/useReadQuery.d.ts +1 -1
  297. package/react/hooks/useReadQuery.d.ts.map +1 -1
  298. package/react/hooks/useReadQuery.js +1 -1
  299. package/react/hooks/useReadQuery.js.map +1 -1
  300. package/react/hooks/useSuspenseQuery.d.ts +1 -1
  301. package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
  302. package/react/hooks/useSuspenseQuery.js.map +1 -1
  303. package/react/react.cjs +2 -0
  304. package/react/react.cjs.map +1 -1
  305. package/react/react.cjs.native.js +2 -0
  306. package/react/types/types.js.map +1 -1
  307. package/testing/core/core.cjs +37 -28
  308. package/testing/core/core.cjs.map +1 -1
  309. package/testing/core/core.cjs.native.js +37 -28
  310. package/testing/core/itAsync.d.ts.map +1 -1
  311. package/testing/core/itAsync.js +8 -4
  312. package/testing/core/itAsync.js.map +1 -1
  313. package/testing/core/mocking/mockClient.d.ts +3 -3
  314. package/testing/core/mocking/mockClient.d.ts.map +1 -1
  315. package/testing/core/mocking/mockClient.js +6 -4
  316. package/testing/core/mocking/mockClient.js.map +1 -1
  317. package/testing/core/mocking/mockFetch.d.ts +1 -1
  318. package/testing/core/mocking/mockFetch.d.ts.map +1 -1
  319. package/testing/core/mocking/mockFetch.js +3 -3
  320. package/testing/core/mocking/mockFetch.js.map +1 -1
  321. package/testing/core/mocking/mockLink.d.ts +3 -3
  322. package/testing/core/mocking/mockLink.d.ts.map +1 -1
  323. package/testing/core/mocking/mockLink.js +24 -23
  324. package/testing/core/mocking/mockLink.js.map +1 -1
  325. package/testing/core/mocking/mockQueryManager.d.ts +2 -2
  326. package/testing/core/mocking/mockQueryManager.js +3 -3
  327. package/testing/core/mocking/mockQueryManager.js.map +1 -1
  328. package/testing/core/mocking/mockSubscriptionLink.d.ts +3 -3
  329. package/testing/core/mocking/mockSubscriptionLink.js +4 -4
  330. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  331. package/testing/core/mocking/mockWatchQuery.d.ts +2 -2
  332. package/testing/core/mocking/mockWatchQuery.js +2 -2
  333. package/testing/core/mocking/mockWatchQuery.js.map +1 -1
  334. package/testing/core/observableToPromise.d.ts +3 -3
  335. package/testing/core/observableToPromise.d.ts.map +1 -1
  336. package/testing/core/observableToPromise.js +8 -4
  337. package/testing/core/observableToPromise.js.map +1 -1
  338. package/testing/core/subscribeAndCount.d.ts +1 -1
  339. package/testing/core/subscribeAndCount.d.ts.map +1 -1
  340. package/testing/core/subscribeAndCount.js +5 -3
  341. package/testing/core/subscribeAndCount.js.map +1 -1
  342. package/testing/core/wait.js.map +1 -1
  343. package/testing/core/withConsoleSpy.d.ts.map +1 -1
  344. package/testing/core/withConsoleSpy.js.map +1 -1
  345. package/testing/core/wrap.d.ts.map +1 -1
  346. package/testing/core/wrap.js +14 -12
  347. package/testing/core/wrap.js.map +1 -1
  348. package/testing/index.d.ts +4 -4
  349. package/testing/index.js +3 -3
  350. package/testing/index.js.map +1 -1
  351. package/testing/react/MockedProvider.d.ts +7 -7
  352. package/testing/react/MockedProvider.d.ts.map +1 -1
  353. package/testing/react/MockedProvider.js +10 -11
  354. package/testing/react/MockedProvider.js.map +1 -1
  355. package/testing/testing.cjs +3 -5
  356. package/testing/testing.cjs.map +1 -1
  357. package/testing/testing.cjs.native.js +3 -5
  358. package/utilities/common/canUse.d.ts.map +1 -1
  359. package/utilities/common/canUse.js +4 -5
  360. package/utilities/common/canUse.js.map +1 -1
  361. package/utilities/common/cloneDeep.js +2 -2
  362. package/utilities/common/cloneDeep.js.map +1 -1
  363. package/utilities/common/compact.d.ts +1 -1
  364. package/utilities/common/compact.js.map +1 -1
  365. package/utilities/common/filterInPlace.js.map +1 -1
  366. package/utilities/common/maybeDeepFreeze.js +1 -1
  367. package/utilities/common/maybeDeepFreeze.js.map +1 -1
  368. package/utilities/common/mergeDeep.d.ts.map +1 -1
  369. package/utilities/common/mergeDeep.js +3 -1
  370. package/utilities/common/mergeDeep.js.map +1 -1
  371. package/utilities/common/mergeOptions.d.ts.map +1 -1
  372. package/utilities/common/mergeOptions.js.map +1 -1
  373. package/utilities/common/objects.js +2 -2
  374. package/utilities/common/objects.js.map +1 -1
  375. package/utilities/common/stringifyForDisplay.d.ts.map +1 -1
  376. package/utilities/common/stringifyForDisplay.js +3 -1
  377. package/utilities/common/stringifyForDisplay.js.map +1 -1
  378. package/utilities/globals/global.d.ts.map +1 -1
  379. package/utilities/globals/global.js +3 -1
  380. package/utilities/globals/global.js.map +1 -1
  381. package/utilities/globals/globals.cjs +8 -4
  382. package/utilities/globals/globals.cjs.map +1 -1
  383. package/utilities/globals/globals.cjs.native.js +8 -4
  384. package/utilities/globals/index.d.ts.map +1 -1
  385. package/utilities/globals/index.js +1 -1
  386. package/utilities/globals/index.js.map +1 -1
  387. package/utilities/globals/invariantWrappers.js +1 -1
  388. package/utilities/globals/invariantWrappers.js.map +1 -1
  389. package/utilities/globals/maybe.d.ts.map +1 -1
  390. package/utilities/globals/maybe.js.map +1 -1
  391. package/utilities/graphql/directives.d.ts +1 -1
  392. package/utilities/graphql/directives.d.ts.map +1 -1
  393. package/utilities/graphql/directives.js +17 -13
  394. package/utilities/graphql/directives.js.map +1 -1
  395. package/utilities/graphql/fragments.d.ts +1 -1
  396. package/utilities/graphql/fragments.d.ts.map +1 -1
  397. package/utilities/graphql/fragments.js +12 -12
  398. package/utilities/graphql/fragments.js.map +1 -1
  399. package/utilities/graphql/getFromAST.d.ts +1 -1
  400. package/utilities/graphql/getFromAST.js +16 -16
  401. package/utilities/graphql/getFromAST.js.map +1 -1
  402. package/utilities/graphql/storeUtils.d.ts +2 -2
  403. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  404. package/utilities/graphql/storeUtils.js +36 -34
  405. package/utilities/graphql/storeUtils.js.map +1 -1
  406. package/utilities/graphql/transform.d.ts +1 -1
  407. package/utilities/graphql/transform.d.ts.map +1 -1
  408. package/utilities/graphql/transform.js +48 -32
  409. package/utilities/graphql/transform.js.map +1 -1
  410. package/utilities/observables/Concast.d.ts.map +1 -1
  411. package/utilities/observables/Concast.js +5 -9
  412. package/utilities/observables/Concast.js.map +1 -1
  413. package/utilities/observables/Observable.d.ts +4 -4
  414. package/utilities/observables/Observable.d.ts.map +1 -1
  415. package/utilities/observables/Observable.js +6 -4
  416. package/utilities/observables/Observable.js.map +1 -1
  417. package/utilities/observables/asyncMap.d.ts.map +1 -1
  418. package/utilities/observables/asyncMap.js +5 -2
  419. package/utilities/observables/asyncMap.js.map +1 -1
  420. package/utilities/observables/iteration.js.map +1 -1
  421. package/utilities/policies/pagination.d.ts +1 -1
  422. package/utilities/policies/pagination.d.ts.map +1 -1
  423. package/utilities/policies/pagination.js +9 -7
  424. package/utilities/policies/pagination.js.map +1 -1
  425. package/utilities/types/IsStrictlyAny.d.ts +2 -2
  426. package/utilities/types/IsStrictlyAny.d.ts.map +1 -1
  427. package/utilities/types/IsStrictlyAny.js.map +1 -1
  428. package/utilities/utilities.cjs +147 -121
  429. package/utilities/utilities.cjs.map +1 -1
  430. package/utilities/utilities.cjs.native.js +147 -121
  431. package/version.js +1 -1
  432. package/version.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"selectHttpOptionsAndBody.js","sourceRoot":"","sources":["../../../src/link/http/selectHttpOptionsAndBody.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAMhD,CAAC;AA4FF,IAAM,kBAAkB,GAAqB;IAC3C,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,KAAK;IACxB,kBAAkB,EAAE,KAAK;CAC1B,CAAC;AAEF,IAAM,cAAc,GAAG;IAErB,MAAM,EAAE,KAAK;IAab,cAAc,EAAE,kBAAkB;CACnC,CAAC;AAEF,IAAM,cAAc,GAAG;IACrB,MAAM,EAAE,MAAM;CACf,CAAC;AAEF,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OAAO,CAAC,UAAA,IAAI;QAClC,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;IAC5E,CAAC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import type { ASTNode} from 'graphql';\nimport { print } from '../../utilities/index.js';\n\nimport type { Operation } from '../core/index.js';\n\nexport interface Printer {\n (node: ASTNode, originalPrint: typeof print): string\n};\n\nexport interface UriFunction {\n (operation: Operation): string;\n}\n\nexport interface Body {\n query?: string;\n operationName?: string;\n variables?: Record<string, any>;\n extensions?: Record<string, any>;\n}\n\nexport interface HttpOptions {\n /**\n * The URI to use when fetching operations.\n *\n * Defaults to '/graphql'.\n */\n uri?: string | UriFunction;\n\n /**\n * Passes the extensions field to your graphql server.\n *\n * Defaults to false.\n */\n includeExtensions?: boolean;\n\n /**\n * A `fetch`-compatible API to use when making requests.\n */\n fetch?: WindowOrWorkerGlobalScope['fetch'];\n\n /**\n * An object representing values to be sent as headers on the request.\n */\n headers?: Record<string, string>;\n\n /**\n * If set to true, header names won't be automatically normalized to\n * lowercase. This allows for non-http-spec-compliant servers that might\n * expect capitalized header names.\n */\n preserveHeaderCase?: boolean;\n\n /**\n * The credentials policy you want to use for the fetch call.\n */\n credentials?: string;\n\n /**\n * Any overrides of the fetch options argument to pass to the fetch call.\n */\n fetchOptions?: any;\n\n /**\n * If set to true, use the HTTP GET method for query operations. Mutations\n * will still use the method specified in fetchOptions.method (which defaults\n * to POST).\n */\n useGETForQueries?: boolean;\n\n /**\n * If set to true, the default behavior of stripping unused variables\n * from the request will be disabled.\n *\n * Unused variables are likely to trigger server-side validation errors,\n * per https://spec.graphql.org/draft/#sec-All-Variables-Used, but this\n * includeUnusedVariables option can be useful if your server deviates\n * from the GraphQL specification by not strictly enforcing that rule.\n */\n includeUnusedVariables?: boolean;\n /**\n * A function to substitute for the default query print function. Can be\n * used to apply changes to the results of the print function.\n */\n print?: Printer;\n}\n\nexport interface HttpQueryOptions {\n includeQuery?: boolean;\n includeExtensions?: boolean;\n preserveHeaderCase?: boolean;\n}\n\nexport interface HttpConfig {\n http?: HttpQueryOptions;\n options?: any;\n headers?: Record<string, string>;\n credentials?: any;\n}\n\nconst defaultHttpOptions: HttpQueryOptions = {\n includeQuery: true,\n includeExtensions: false,\n preserveHeaderCase: false,\n};\n\nconst defaultHeaders = {\n // headers are case insensitive (https://stackoverflow.com/a/5259004)\n accept: '*/*',\n // The content-type header describes the type of the body of the request, and\n // so it typically only is sent with requests that actually have bodies. One\n // could imagine that Apollo Client would remove this header when constructing\n // a GET request (which has no body), but we historically have not done that.\n // This means that browsers will preflight all Apollo Client requests (even\n // GET requests). Apollo Server's CSRF prevention feature (introduced in\n // AS3.7) takes advantage of this fact and does not block requests with this\n // header. If you want to drop this header from GET requests, then you should\n // probably replace it with a `apollo-require-preflight` header, or servers\n // with CSRF prevention enabled might block your GET request. See\n // https://www.apollographql.com/docs/apollo-server/security/cors/#preventing-cross-site-request-forgery-csrf\n // for more details.\n 'content-type': 'application/json',\n};\n\nconst defaultOptions = {\n method: 'POST',\n};\n\nexport const fallbackHttpConfig = {\n http: defaultHttpOptions,\n headers: defaultHeaders,\n options: defaultOptions,\n};\n\nexport const defaultPrinter: Printer = (ast, printer) => printer(ast);\n\nexport function selectHttpOptionsAndBody(\n operation: Operation,\n fallbackConfig: HttpConfig,\n ...configs: Array<HttpConfig>\n) {\n configs.unshift(fallbackConfig);\n return selectHttpOptionsAndBodyInternal(\n operation,\n defaultPrinter,\n ...configs,\n );\n}\n\nexport function selectHttpOptionsAndBodyInternal(\n operation: Operation,\n printer: Printer,\n ...configs: HttpConfig[]\n) {\n let options = {} as HttpConfig & Record<string, any>;\n let http = {} as HttpQueryOptions;\n\n configs.forEach(config => {\n options = {\n ...options,\n ...config.options,\n headers: {\n ...options.headers,\n ...config.headers,\n }\n };\n\n if (config.credentials) {\n options.credentials = config.credentials;\n }\n\n http = {\n ...http,\n ...config.http,\n };\n });\n\n if (options.headers) {\n options.headers = removeDuplicateHeaders(options.headers, http.preserveHeaderCase);\n }\n\n //The body depends on the http options\n const { operationName, extensions, variables, query } = operation;\n const body: Body = { operationName, variables };\n\n if (http.includeExtensions) (body as any).extensions = extensions;\n\n // not sending the query (i.e persisted queries)\n if (http.includeQuery) (body as any).query = printer(query, print);\n\n return {\n options,\n body,\n };\n};\n\n// Remove potential duplicate header names, preserving last (by insertion order).\n// This is done to prevent unintentionally duplicating a header instead of\n// overwriting it (See #8447 and #8449).\nfunction removeDuplicateHeaders(\n headers: Record<string, string>,\n preserveHeaderCase: boolean | undefined\n): typeof headers {\n\n // If we're not preserving the case, just remove duplicates w/ normalization.\n if (!preserveHeaderCase) {\n const normalizedHeaders = Object.create(null);\n Object.keys(Object(headers)).forEach(name => {\n normalizedHeaders[name.toLowerCase()] = headers[name];\n });\n return normalizedHeaders;\n }\n\n // If we are preserving the case, remove duplicates w/ normalization,\n // preserving the original name.\n // This allows for non-http-spec-compliant servers that expect intentionally\n // capitalized header names (See #6741).\n const headerData = Object.create(null);\n Object.keys(Object(headers)).forEach(name => {\n headerData[name.toLowerCase()] = { originalName: name, value: headers[name] }\n });\n\n const normalizedHeaders = Object.create(null);\n Object.keys(headerData).forEach(name => {\n normalizedHeaders[headerData[name].originalName] = headerData[name].value;\n });\n return normalizedHeaders;\n}\n"]}
1
+ {"version":3,"file":"selectHttpOptionsAndBody.js","sourceRoot":"","sources":["../../../src/link/http/selectHttpOptionsAndBody.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAkGjD,IAAM,kBAAkB,GAAqB;IAC3C,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,KAAK;IACxB,kBAAkB,EAAE,KAAK;CAC1B,CAAC;AAEF,IAAM,cAAc,GAAG;IAErB,MAAM,EAAE,KAAK;IAab,cAAc,EAAE,kBAAkB;CACnC,CAAC;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;IAC9C,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAC,IAAI;QACnC,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;IAC5E,CAAC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import type { ASTNode } from \"graphql\";\nimport { print } from \"../../utilities/index.js\";\n\nimport type { Operation } from \"../core/index.js\";\n\nexport interface Printer {\n (node: ASTNode, originalPrint: typeof print): string;\n}\n\nexport interface UriFunction {\n (operation: Operation): string;\n}\n\nexport interface Body {\n query?: string;\n operationName?: string;\n variables?: Record<string, any>;\n extensions?: Record<string, any>;\n}\n\nexport interface HttpOptions {\n /**\n * The URI to use when fetching operations.\n *\n * Defaults to '/graphql'.\n */\n uri?: string | UriFunction;\n\n /**\n * Passes the extensions field to your graphql server.\n *\n * Defaults to false.\n */\n includeExtensions?: boolean;\n\n /**\n * A `fetch`-compatible API to use when making requests.\n */\n fetch?: WindowOrWorkerGlobalScope[\"fetch\"];\n\n /**\n * An object representing values to be sent as headers on the request.\n */\n headers?: Record<string, string>;\n\n /**\n * If set to true, header names won't be automatically normalized to\n * lowercase. This allows for non-http-spec-compliant servers that might\n * expect capitalized header names.\n */\n preserveHeaderCase?: boolean;\n\n /**\n * The credentials policy you want to use for the fetch call.\n */\n credentials?: string;\n\n /**\n * Any overrides of the fetch options argument to pass to the fetch call.\n */\n fetchOptions?: any;\n\n /**\n * If set to true, use the HTTP GET method for query operations. Mutations\n * will still use the method specified in fetchOptions.method (which defaults\n * to POST).\n */\n useGETForQueries?: boolean;\n\n /**\n * If set to true, the default behavior of stripping unused variables\n * from the request will be disabled.\n *\n * Unused variables are likely to trigger server-side validation errors,\n * per https://spec.graphql.org/draft/#sec-All-Variables-Used, but this\n * includeUnusedVariables option can be useful if your server deviates\n * from the GraphQL specification by not strictly enforcing that rule.\n */\n includeUnusedVariables?: boolean;\n /**\n * A function to substitute for the default query print function. Can be\n * used to apply changes to the results of the print function.\n */\n print?: Printer;\n}\n\nexport interface HttpQueryOptions {\n includeQuery?: boolean;\n includeExtensions?: boolean;\n preserveHeaderCase?: boolean;\n}\n\nexport interface HttpConfig {\n http?: HttpQueryOptions;\n options?: any;\n headers?: Record<string, string>;\n credentials?: any;\n}\n\nconst defaultHttpOptions: HttpQueryOptions = {\n includeQuery: true,\n includeExtensions: false,\n preserveHeaderCase: false,\n};\n\nconst defaultHeaders = {\n // headers are case insensitive (https://stackoverflow.com/a/5259004)\n accept: \"*/*\",\n // The content-type header describes the type of the body of the request, and\n // so it typically only is sent with requests that actually have bodies. One\n // could imagine that Apollo Client would remove this header when constructing\n // a GET request (which has no body), but we historically have not done that.\n // This means that browsers will preflight all Apollo Client requests (even\n // GET requests). Apollo Server's CSRF prevention feature (introduced in\n // AS3.7) takes advantage of this fact and does not block requests with this\n // header. If you want to drop this header from GET requests, then you should\n // probably replace it with a `apollo-require-preflight` header, or servers\n // with CSRF prevention enabled might block your GET request. See\n // https://www.apollographql.com/docs/apollo-server/security/cors/#preventing-cross-site-request-forgery-csrf\n // for more details.\n \"content-type\": \"application/json\",\n};\n\nconst defaultOptions = {\n method: \"POST\",\n};\n\nexport const fallbackHttpConfig = {\n http: defaultHttpOptions,\n headers: defaultHeaders,\n options: defaultOptions,\n};\n\nexport const defaultPrinter: Printer = (ast, printer) => printer(ast);\n\nexport function selectHttpOptionsAndBody(\n operation: Operation,\n fallbackConfig: HttpConfig,\n ...configs: Array<HttpConfig>\n) {\n configs.unshift(fallbackConfig);\n return selectHttpOptionsAndBodyInternal(\n operation,\n defaultPrinter,\n ...configs\n );\n}\n\nexport function selectHttpOptionsAndBodyInternal(\n operation: Operation,\n printer: Printer,\n ...configs: HttpConfig[]\n) {\n let options = {} as HttpConfig & Record<string, any>;\n let http = {} as HttpQueryOptions;\n\n configs.forEach((config) => {\n options = {\n ...options,\n ...config.options,\n headers: {\n ...options.headers,\n ...config.headers,\n },\n };\n\n if (config.credentials) {\n options.credentials = config.credentials;\n }\n\n http = {\n ...http,\n ...config.http,\n };\n });\n\n if (options.headers) {\n options.headers = removeDuplicateHeaders(\n options.headers,\n http.preserveHeaderCase\n );\n }\n\n //The body depends on the http options\n const { operationName, extensions, variables, query } = operation;\n const body: Body = { operationName, variables };\n\n if (http.includeExtensions) (body as any).extensions = extensions;\n\n // not sending the query (i.e persisted queries)\n if (http.includeQuery) (body as any).query = printer(query, print);\n\n return {\n options,\n body,\n };\n}\n\n// Remove potential duplicate header names, preserving last (by insertion order).\n// This is done to prevent unintentionally duplicating a header instead of\n// overwriting it (See #8447 and #8449).\nfunction removeDuplicateHeaders(\n headers: Record<string, string>,\n preserveHeaderCase: boolean | undefined\n): typeof headers {\n // If we're not preserving the case, just remove duplicates w/ normalization.\n if (!preserveHeaderCase) {\n const normalizedHeaders = Object.create(null);\n Object.keys(Object(headers)).forEach((name) => {\n normalizedHeaders[name.toLowerCase()] = headers[name];\n });\n return normalizedHeaders;\n }\n\n // If we are preserving the case, remove duplicates w/ normalization,\n // preserving the original name.\n // This allows for non-http-spec-compliant servers that expect intentionally\n // capitalized header names (See #6741).\n const headerData = Object.create(null);\n Object.keys(Object(headers)).forEach((name) => {\n headerData[name.toLowerCase()] = {\n originalName: name,\n value: headers[name],\n };\n });\n\n const normalizedHeaders = Object.create(null);\n Object.keys(headerData).forEach((name) => {\n normalizedHeaders[headerData[name].originalName] = headerData[name].value;\n });\n return normalizedHeaders;\n}\n"]}
@@ -1,3 +1,3 @@
1
- import type { Operation } from '../core/index.js';
1
+ import type { Operation } from "../core/index.js";
2
2
  export declare const selectURI: (operation: Operation, fallbackURI?: string | ((operation: Operation) => string) | undefined) => any;
3
3
  //# sourceMappingURL=selectURI.d.ts.map
@@ -4,11 +4,11 @@ export var selectURI = function (operation, fallbackURI) {
4
4
  if (contextURI) {
5
5
  return contextURI;
6
6
  }
7
- else if (typeof fallbackURI === 'function') {
7
+ else if (typeof fallbackURI === "function") {
8
8
  return fallbackURI(operation);
9
9
  }
10
10
  else {
11
- return fallbackURI || '/graphql';
11
+ return fallbackURI || "/graphql";
12
12
  }
13
13
  };
14
14
  //# sourceMappingURL=selectURI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"selectURI.js","sourceRoot":"","sources":["../../../src/link/http/selectURI.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,IAAM,SAAS,GAAG,UACvB,SAAoB,EACpB,WAAyD;IAEzD,IAAM,OAAO,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;IACvC,IAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC;IAE/B,IAAI,UAAU,EAAE;QACd,OAAO,UAAU,CAAC;KACnB;SAAM,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;QAC5C,OAAO,WAAW,CAAC,SAAS,CAAC,CAAC;KAC/B;SAAM;QACL,OAAQ,WAAsB,IAAI,UAAU,CAAC;KAC9C;AACH,CAAC,CAAC","sourcesContent":["import type { Operation } from '../core/index.js';\n\nexport const selectURI = (\n operation: Operation,\n fallbackURI?: string | ((operation: Operation) => string),\n) => {\n const context = operation.getContext();\n const contextURI = context.uri;\n\n if (contextURI) {\n return contextURI;\n } else if (typeof fallbackURI === 'function') {\n return fallbackURI(operation);\n } else {\n return (fallbackURI as string) || '/graphql';\n }\n};\n"]}
1
+ {"version":3,"file":"selectURI.js","sourceRoot":"","sources":["../../../src/link/http/selectURI.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,IAAM,SAAS,GAAG,UACvB,SAAoB,EACpB,WAAyD;IAEzD,IAAM,OAAO,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;IACvC,IAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC;IAE/B,IAAI,UAAU,EAAE;QACd,OAAO,UAAU,CAAC;KACnB;SAAM,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;QAC5C,OAAO,WAAW,CAAC,SAAS,CAAC,CAAC;KAC/B;SAAM;QACL,OAAQ,WAAsB,IAAI,UAAU,CAAC;KAC9C;AACH,CAAC,CAAC","sourcesContent":["import type { Operation } from \"../core/index.js\";\n\nexport const selectURI = (\n operation: Operation,\n fallbackURI?: string | ((operation: Operation) => string)\n) => {\n const context = operation.getContext();\n const contextURI = context.uri;\n\n if (contextURI) {\n return contextURI;\n } else if (typeof fallbackURI === \"function\") {\n return fallbackURI(operation);\n } else {\n return (fallbackURI as string) || \"/graphql\";\n }\n};\n"]}
@@ -1,4 +1,4 @@
1
- import type { InvariantError } from '../../utilities/globals/index.js';
1
+ import type { InvariantError } from "../../utilities/globals/index.js";
2
2
  export type ClientParseError = InvariantError & {
3
3
  parseError: Error;
4
4
  };
@@ -1,4 +1,4 @@
1
- import { newInvariantError } from '../../utilities/globals/index.js';
1
+ import { newInvariantError } from "../../utilities/globals/index.js";
2
2
  export var serializeFetchParameter = function (p, label) {
3
3
  var serialized;
4
4
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"serializeFetchParameter.js","sourceRoot":"","sources":["../../../src/link/http/serializeFetchParameter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAOrE,MAAM,CAAC,IAAM,uBAAuB,GAAG,UAAC,CAAM,EAAE,KAAa;IAC3D,IAAI,UAAU,CAAC;IACf,IAAI;QACF,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;KAChC;IAAC,OAAO,CAAC,EAAE;QACV,IAAM,UAAU,GAAG,iBAAiB,CAClC,oDAAoD,EACpD,KAAK,EACL,CAAC,CAAC,OAAO,CACU,CAAC;QACtB,UAAU,CAAC,UAAU,GAAG,CAAC,CAAC;QAC1B,MAAM,UAAU,CAAC;KAClB;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC","sourcesContent":["import { newInvariantError } from '../../utilities/globals/index.js';\nimport type { InvariantError } from '../../utilities/globals/index.js';\n\nexport type ClientParseError = InvariantError & {\n parseError: Error;\n};\n\nexport const serializeFetchParameter = (p: any, label: string) => {\n let serialized;\n try {\n serialized = JSON.stringify(p);\n } catch (e) {\n const parseError = newInvariantError(\n `Network request failed. %s is not serializable: %s`,\n label,\n e.message\n ) as ClientParseError;\n parseError.parseError = e;\n throw parseError;\n }\n return serialized;\n};\n"]}
1
+ {"version":3,"file":"serializeFetchParameter.js","sourceRoot":"","sources":["../../../src/link/http/serializeFetchParameter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAOrE,MAAM,CAAC,IAAM,uBAAuB,GAAG,UAAC,CAAM,EAAE,KAAa;IAC3D,IAAI,UAAU,CAAC;IACf,IAAI;QACF,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;KAChC;IAAC,OAAO,CAAC,EAAE;QACV,IAAM,UAAU,GAAG,iBAAiB,CAClC,oDAAoD,EACpD,KAAK,EACL,CAAC,CAAC,OAAO,CACU,CAAC;QACtB,UAAU,CAAC,UAAU,GAAG,CAAC,CAAC;QAC1B,MAAM,UAAU,CAAC;KAClB;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC","sourcesContent":["import { newInvariantError } from \"../../utilities/globals/index.js\";\nimport type { InvariantError } from \"../../utilities/globals/index.js\";\n\nexport type ClientParseError = InvariantError & {\n parseError: Error;\n};\n\nexport const serializeFetchParameter = (p: any, label: string) => {\n let serialized;\n try {\n serialized = JSON.stringify(p);\n } catch (e) {\n const parseError = newInvariantError(\n `Network request failed. %s is not serializable: %s`,\n label,\n e.message\n ) as ClientParseError;\n parseError.parseError = e;\n throw parseError;\n }\n return serialized;\n};\n"]}
@@ -1,7 +1,7 @@
1
- import type { DocumentNode, ExecutionResult, GraphQLError } from 'graphql';
2
- import type { Operation } from '../core/index.js';
3
- import { ApolloLink } from '../core/index.js';
4
- import type { NetworkError } from '../../errors/index.js';
1
+ import type { DocumentNode, ExecutionResult, GraphQLError } from "graphql";
2
+ import type { Operation } from "../core/index.js";
3
+ import { ApolloLink } from "../core/index.js";
4
+ import type { NetworkError } from "../../errors/index.js";
5
5
  export declare const VERSION = 1;
6
6
  export interface ErrorResponse {
7
7
  graphQLErrors?: readonly GraphQLError[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/link/persisted-queries/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAS9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,eAAO,MAAM,OAAO,IAAI,CAAC;AAEzB,MAAM,WAAW,aAAa;IAC5B,aAAa,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,KAAK,SAAS,GAAG;IACf,0BAA0B,EAAE,OAAO,CAAC;IACpC,sBAAsB,EAAE,OAAO,CAAC;CACjC,CAAA;AAED,KAAK,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AACvE,KAAK,oBAAoB,GAAG,CAAC,QAAQ,EAAE,YAAY,KAAK,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAErF,UAAU,WAAW;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;IAC5C,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;IAC1C,sBAAsB,CA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KACnB,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAElC,UAAU,WAAW;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;IAC5C,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;IAC1C,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,yBAAiB,kBAAkB,CAAC;IAClC,UAAU,aAAc,SAAQ,WAAW;QACzC,MAAM,EAAE,cAAc,CAAC;QACvB,YAAY,CAAC,EAAE,KAAK,CAAC;KACtB;IAED,UAAU,mBAAoB,SAAQ,WAAW;QAC/C,MAAM,CAAC,EAAE,KAAK,CAAC;QACf,YAAY,EAAE,oBAAoB,CAAC;KACpC;IAED,MAAM,MAAM,OAAO,GAAG,aAAa,GAAG,mBAAmB,CAAC;;CAC3D;AAuCD,eAAO,MAAM,wBAAwB,YAC1B,mBAAmB,OAAO,eA8LpC,CAAC"}
@@ -1,15 +1,9 @@
1
1
  import { __assign } from "tslib";
2
- import { invariant } from '../../utilities/globals/index.js';
3
- import { print } from '../../utilities/index.js';
4
- import { ApolloLink } from '../core/index.js';
5
- import { Observable, compact, isNonEmptyArray, } from '../../utilities/index.js';
2
+ import { invariant } from "../../utilities/globals/index.js";
3
+ import { print } from "../../utilities/index.js";
4
+ import { ApolloLink } from "../core/index.js";
5
+ import { Observable, compact, isNonEmptyArray } from "../../utilities/index.js";
6
6
  export var VERSION = 1;
7
- ;
8
- export var PersistedQueryLink;
9
- (function (PersistedQueryLink) {
10
- ;
11
- ;
12
- })(PersistedQueryLink || (PersistedQueryLink = {}));
13
7
  function processErrors(graphQLErrors) {
14
8
  var byMessage = Object.create(null), byCode = Object.create(null);
15
9
  if (isNonEmptyArray(graphQLErrors)) {
@@ -21,7 +15,8 @@ function processErrors(graphQLErrors) {
21
15
  });
22
16
  }
23
17
  return {
24
- persistedQueryNotSupported: !!(byMessage.PersistedQueryNotSupported || byCode.PERSISTED_QUERY_NOT_SUPPORTED),
18
+ persistedQueryNotSupported: !!(byMessage.PersistedQueryNotSupported ||
19
+ byCode.PERSISTED_QUERY_NOT_SUPPORTED),
25
20
  persistedQueryNotFound: !!(byMessage.PersistedQueryNotFound || byCode.PERSISTED_QUERY_NOT_FOUND),
26
21
  };
27
22
  }
@@ -37,24 +32,27 @@ var defaultOptions = {
37
32
  useGETForHashedQueries: false,
38
33
  };
39
34
  function operationDefinesMutation(operation) {
40
- return operation.query.definitions.some(function (d) { return d.kind === 'OperationDefinition' && d.operation === 'mutation'; });
35
+ return operation.query.definitions.some(function (d) { return d.kind === "OperationDefinition" && d.operation === "mutation"; });
41
36
  }
42
37
  export var createPersistedQueryLink = function (options) {
43
38
  var hashesByQuery = new WeakMap();
44
- invariant(options && (typeof options.sha256 === 'function' ||
45
- typeof options.generateHash === 'function'), 38);
46
- var _a = compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) { return Promise.resolve(sha256(print(query))); } : _b, disable = _a.disable, retry = _a.retry, useGETForHashedQueries = _a.useGETForHashedQueries;
39
+ invariant(options &&
40
+ (typeof options.sha256 === "function" ||
41
+ typeof options.generateHash === "function"), 38);
42
+ var _a = compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) {
43
+ return Promise.resolve(sha256(print(query)));
44
+ } : _b, disable = _a.disable, retry = _a.retry, useGETForHashedQueries = _a.useGETForHashedQueries;
47
45
  var supportsPersistedQueries = true;
48
46
  var getHashPromise = function (query) {
49
47
  return new Promise(function (resolve) { return resolve(generateHash(query)); });
50
48
  };
51
49
  function getQueryHash(query) {
52
- if (!query || typeof query !== 'object') {
50
+ if (!query || typeof query !== "object") {
53
51
  return getHashPromise(query);
54
52
  }
55
53
  var hash = hashesByQuery.get(query);
56
54
  if (!hash)
57
- hashesByQuery.set(query, hash = getHashPromise(query));
55
+ hashesByQuery.set(query, (hash = getHashPromise(query)));
58
56
  return hash;
59
57
  }
60
58
  return new ApolloLink(function (operation, forward) {
@@ -75,7 +73,7 @@ export var createPersistedQueryLink = function (options) {
75
73
  graphQLErrors.push.apply(graphQLErrors, responseErrors);
76
74
  }
77
75
  var networkErrors = void 0;
78
- if (typeof (networkError === null || networkError === void 0 ? void 0 : networkError.result) !== 'string') {
76
+ if (typeof (networkError === null || networkError === void 0 ? void 0 : networkError.result) !== "string") {
79
77
  networkErrors =
80
78
  networkError &&
81
79
  networkError.result &&
@@ -88,8 +86,10 @@ export var createPersistedQueryLink = function (options) {
88
86
  response: response,
89
87
  networkError: networkError,
90
88
  operation: operation,
91
- graphQLErrors: isNonEmptyArray(graphQLErrors) ? graphQLErrors : void 0,
92
- meta: processErrors(graphQLErrors)
89
+ graphQLErrors: isNonEmptyArray(graphQLErrors)
90
+ ? graphQLErrors
91
+ : void 0,
92
+ meta: processErrors(graphQLErrors),
93
93
  };
94
94
  supportsPersistedQueries = !disable(disablePayload);
95
95
  if (retry(disablePayload)) {
@@ -101,7 +101,7 @@ export var createPersistedQueryLink = function (options) {
101
101
  includeExtensions: supportsPersistedQueries,
102
102
  },
103
103
  fetchOptions: {
104
- method: 'POST',
104
+ method: "POST",
105
105
  },
106
106
  });
107
107
  if (setFetchOptions) {
@@ -135,20 +135,21 @@ export var createPersistedQueryLink = function (options) {
135
135
  var _b = _a.fetchOptions, fetchOptions = _b === void 0 ? {} : _b;
136
136
  originalFetchOptions = fetchOptions;
137
137
  return {
138
- fetchOptions: __assign(__assign({}, fetchOptions), { method: 'GET' }),
138
+ fetchOptions: __assign(__assign({}, fetchOptions), { method: "GET" }),
139
139
  };
140
140
  });
141
141
  setFetchOptions = true;
142
142
  }
143
143
  if (supportsPersistedQueries) {
144
- getQueryHash(query).then(function (sha256Hash) {
144
+ getQueryHash(query)
145
+ .then(function (sha256Hash) {
145
146
  operation.extensions.persistedQuery = {
146
147
  version: VERSION,
147
148
  sha256Hash: sha256Hash,
148
149
  };
149
150
  subscription = forward(operation).subscribe(handler);
150
- }).catch(observer.error.bind(observer));
151
- ;
151
+ })
152
+ .catch(observer.error.bind(observer));
152
153
  }
153
154
  else {
154
155
  subscription = forward(operation).subscribe(handler);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/persisted-queries/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAQjD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,OAAO,EACL,UAAU,EACV,OAAO,EACP,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAIlC,MAAM,CAAC,IAAM,OAAO,GAAG,CAAC,CAAC;AAsBxB,CAAC;AAEF,MAAM,KAAW,kBAAkB,CAYlC;AAZD,WAAiB,kBAAkB;IAIhC,CAAC;IAKD,CAAC;AAGJ,CAAC,EAZgB,kBAAkB,KAAlB,kBAAkB,QAYlC;AAED,SAAS,aAAa,CACpB,aAAmE;IAEnE,IAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAC/B,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEnC,IAAI,eAAe,CAAC,aAAa,CAAC,EAAE;QAClC,aAAa,CAAC,OAAO,CAAC,UAAC,KAAK;;YAC1B,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;YACjC,IAAI,OAAO,CAAA,MAAA,KAAK,CAAC,UAAU,0CAAE,IAAI,CAAA,IAAI,QAAQ;gBAC3C,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC1C,CAAC,CAAC,CAAC;KACJ;IACD,OAAO;QACL,0BAA0B,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,0BAA0B,IAAI,MAAM,CAAC,6BAA6B,CAAC;QAC5G,sBA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C,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAAA,CAAC;aAC3C;iBAAM;gBACL,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;aACtD;YAED,OAAO;gBACL,IAAI,YAAY;oBAAE,YAAY,CAAC,WAAW,EAAE,CAAC;YAC/C,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals/index.js';\n\nimport { print } from '../../utilities/index.js';\nimport type {\n DocumentNode,\n ExecutionResult,\n GraphQLError,\n} from 'graphql';\n\nimport type { Operation } from '../core/index.js';\nimport { ApolloLink } from '../core/index.js';\nimport type {\n Observer,\n ObservableSubscription} from '../../utilities/index.js';\nimport {\n Observable,\n compact,\n isNonEmptyArray,\n} from '../../utilities/index.js';\nimport type { NetworkError } from '../../errors/index.js';\nimport type { ServerError } from '../utils/index.js';\n\nexport const VERSION = 1;\n\nexport interface ErrorResponse {\n graphQLErrors?: readonly GraphQLError[];\n networkError?: NetworkError;\n response?: ExecutionResult;\n operation: Operation;\n meta: ErrorMeta;\n}\n\ntype ErrorMeta = {\n persistedQueryNotSupported: boolean;\n persistedQueryNotFound: boolean;\n}\n\ntype SHA256Function = (...args: any[]) => string | PromiseLike<string>;\ntype GenerateHashFunction = (document: DocumentNode) => string | PromiseLike<string>;\n\ninterface BaseOptions {\n disable?: (error: ErrorResponse) => boolean;\n retry?: (error: ErrorResponse) => boolean;\n useGETForHashedQueries?: boolean;\n};\n\nexport namespace PersistedQueryLink {\n interface SHA256Options extends BaseOptions {\n sha256: SHA256Function;\n generateHash?: never;\n };\n\n interface GenerateHashOptions extends BaseOptions {\n sha256?: never;\n generateHash: GenerateHashFunction;\n };\n\n export type Options = SHA256Options | GenerateHashOptions;\n}\n\nfunction processErrors(\n graphQLErrors: GraphQLError[] | readonly GraphQLError[] | undefined\n): ErrorMeta {\n const byMessage = Object.create(null),\n byCode = Object.create(null);\n\n if (isNonEmptyArray(graphQLErrors)) {\n graphQLErrors.forEach((error) => {\n byMessage[error.message] = error;\n if (typeof error.extensions?.code == \"string\")\n byCode[error.extensions.code] = error;\n });\n }\n return {\n persistedQueryNotSupported: !!(byMessage.PersistedQueryNotSupported || byCode.PERSISTED_QUERY_NOT_SUPPORTED),\n persistedQueryNotFound: !!(byMessage.PersistedQueryNotFound || byCode.PERSISTED_QUERY_NOT_FOUND),\n };\n}\n\nconst defaultOptions: Required<BaseOptions> = {\n disable: ({ meta }) => meta.persistedQueryNotSupported,\n retry: ({ meta }) => meta.persistedQueryNotSupported || meta.persistedQueryNotFound,\n useGETForHashedQueries: false,\n};\n\nfunction operationDefinesMutation(operation: Operation) {\n return operation.query.definitions.some(\n d => d.kind === 'OperationDefinition' && d.operation === 'mutation');\n}\n\nexport const createPersistedQueryLink = (\n options: PersistedQueryLink.Options,\n) => {\n const hashesByQuery = new WeakMap<\n DocumentNode,\n Promise<string>\n >();\n // Ensure a SHA-256 hash function is provided, if a custom hash\n // generation function is not provided. We don't supply a SHA-256 hash\n // function by default, to avoid forcing one as a dependency. Developers\n // should pick the most appropriate SHA-256 function (sync or async) for\n // their needs/environment, or provide a fully custom hash generation\n // function (via the `generateHash` option) if they want to handle\n // hashing with something other than SHA-256.\n invariant(\n options && (\n typeof options.sha256 === 'function' ||\n typeof options.generateHash === 'function'\n ),\n 'Missing/invalid \"sha256\" or \"generateHash\" function. Please ' +\n 'configure one using the \"createPersistedQueryLink(options)\" options ' +\n 'parameter.'\n );\n\n const {\n sha256,\n // If both a `sha256` and `generateHash` option are provided, the\n // `sha256` option will be ignored. Developers can configure and\n // use any hashing approach they want in a custom `generateHash`\n // function; they aren't limited to SHA-256.\n generateHash = (query: DocumentNode) => Promise.resolve<string>(sha256!(print(query))),\n disable,\n retry,\n useGETForHashedQueries,\n } = compact(defaultOptions, options);\n\n let supportsPersistedQueries = true;\n\n const getHashPromise = (query: DocumentNode) =>\n new Promise<string>(resolve => resolve(generateHash(query)));\n\n function getQueryHash(query: DocumentNode): Promise<string> {\n if (!query || typeof query !== 'object') {\n // If the query is not an object, we won't be able to store its hash as\n // a property of query[hashesKey], so we let generateHash(query) decide\n // what to do with the bogus query.\n return getHashPromise(query);\n }\n let hash = hashesByQuery.get(query)!;\n if (!hash) hashesByQuery.set(query, hash = getHashPromise(query));\n return hash;\n }\n\n return new ApolloLink((operation, forward) => {\n invariant(\n forward,\n 'PersistedQueryLink cannot be the last link in the chain.'\n );\n\n const { query } = operation;\n\n return new Observable((observer: Observer<ExecutionResult>) => {\n let subscription: ObservableSubscription;\n let retried = false;\n let originalFetchOptions: any;\n let setFetchOptions = false;\n const maybeRetry = (\n {\n response,\n networkError,\n }: { response?: ExecutionResult; networkError?: ServerError },\n cb: () => void,\n ) => {\n if (!retried && ((response && response.errors) || networkError)) {\n retried = true;\n\n const graphQLErrors: GraphQLError[] = [];\n\n const responseErrors = response && response.errors;\n if (isNonEmptyArray(responseErrors)) {\n graphQLErrors.push(...responseErrors);\n }\n\n // Network errors can return GraphQL errors on for example a 403\n let networkErrors;\n if (typeof networkError?.result !== 'string') {\n networkErrors =\n networkError &&\n networkError.result &&\n networkError.result.errors as GraphQLError[];\n }\n if (isNonEmptyArray(networkErrors)) {\n graphQLErrors.push(...networkErrors);\n }\n\n const disablePayload: ErrorResponse = {\n response,\n networkError,\n operation,\n graphQLErrors: isNonEmptyArray(graphQLErrors) ? graphQLErrors : void 0,\n meta: processErrors(graphQLErrors)\n };\n\n // if the server doesn't support persisted queries, don't try anymore\n supportsPersistedQueries = !disable(disablePayload);\n\n // if its not found, we can try it again, otherwise just report the error\n if (retry(disablePayload)) {\n // need to recall the link chain\n if (subscription) subscription.unsubscribe();\n // actually send the query this time\n operation.setContext({\n http: {\n includeQuery: true,\n includeExtensions: supportsPersistedQueries,\n },\n fetchOptions: {\n // Since we're including the full query, which may be\n // large, we should send it in the body of a POST request.\n // See issue #7456.\n method: 'POST',\n },\n });\n if (setFetchOptions) {\n operation.setContext({ fetchOptions: originalFetchOptions });\n }\n subscription = forward(operation).subscribe(handler);\n\n return;\n }\n }\n cb();\n };\n const handler = {\n next: (response: ExecutionResult) => {\n maybeRetry({ response }, () => observer.next!(response));\n },\n error: (networkError: ServerError) => {\n maybeRetry({ networkError }, () => observer.error!(networkError));\n },\n complete: observer.complete!.bind(observer),\n };\n\n // don't send the query the first time\n operation.setContext({\n http: {\n includeQuery: !supportsPersistedQueries,\n includeExtensions: supportsPersistedQueries,\n },\n });\n\n // If requested, set method to GET if there are no mutations. Remember the\n // original fetchOptions so we can restore them if we fall back to a\n // non-hashed request.\n if (\n useGETForHashedQueries &&\n supportsPersistedQueries &&\n !operationDefinesMutation(operation)\n ) {\n operation.setContext(\n ({ fetchOptions = {} }: { fetchOptions: Record<string, any> }) => {\n originalFetchOptions = fetchOptions;\n return {\n fetchOptions: {\n ...fetchOptions,\n method: 'GET',\n },\n };\n },\n );\n setFetchOptions = true;\n }\n\n if (supportsPersistedQueries) {\n getQueryHash(query).then((sha256Hash) => {\n operation.extensions.persistedQuery = {\n version: VERSION,\n sha256Hash,\n };\n subscription = forward(operation).subscribe(handler);\n }).catch(observer.error!.bind(observer));;\n } else {\n subscription = forward(operation).subscribe(handler);\n }\n\n return () => {\n if (subscription) subscription.unsubscribe();\n };\n });\n });\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/persisted-queries/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAIjD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAK9C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAIhF,MAAM,CAAC,IAAM,OAAO,GAAG,CAAC,CAAC;AAwCzB,SAAS,aAAa,CACpB,aAAmE;I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CAAC,UAAU,CAClB,UAAC,EAA4D;wBAA1D,oBAAiB,EAAjB,YAAY,mBAAG,EAAE,KAAA;oBAClB,oBAAoB,GAAG,YAAY,CAAC;oBACpC,OAAO;wBACL,YAAY,wBACP,YAAY,KACf,MAAM,EAAE,KAAK,GACd;qBACF,CAAC;gBACJ,CAAC,CACF,CAAC;gBACF,eAAe,GAAG,IAAI,CAAC;aACxB;YAED,IAAI,wBAAwB,EAAE;gBAC5B,YAAY,CAAC,KAAK,CAAC;qBAChB,IAAI,CAAC,UAAC,UAAU;oBACf,SAAS,CAAC,UAAU,CAAC,cAAc,GAAG;wBACpC,OAAO,EAAE,OAAO;wBAChB,UAAU,YAAA;qBACX,CAAC;oBACF,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;gBACvD,CAAC,CAAC;qBACD,KAAK,CAAC,QAAQ,CAAC,KAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;aAC1C;iBAAM;gBACL,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;aACtD;YAED,OAAO;gBACL,IAAI,YAAY;oBAAE,YAAY,CAAC,WAAW,EAAE,CAAC;YAC/C,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { invariant } from \"../../utilities/globals/index.js\";\n\nimport { print } from \"../../utilities/index.js\";\nimport type { DocumentNode, ExecutionResult, GraphQLError } from \"graphql\";\n\nimport type { Operation } from \"../core/index.js\";\nimport { ApolloLink } from \"../core/index.js\";\nimport type {\n Observer,\n ObservableSubscription,\n} from \"../../utilities/index.js\";\nimport { Observable, compact, isNonEmptyArray } from \"../../utilities/index.js\";\nimport type { NetworkError } from \"../../errors/index.js\";\nimport type { ServerError } from \"../utils/index.js\";\n\nexport const VERSION = 1;\n\nexport interface ErrorResponse {\n graphQLErrors?: readonly GraphQLError[];\n networkError?: NetworkError;\n response?: ExecutionResult;\n operation: Operation;\n meta: ErrorMeta;\n}\n\ntype ErrorMeta = {\n persistedQueryNotSupported: boolean;\n persistedQueryNotFound: boolean;\n};\n\ntype SHA256Function = (...args: any[]) => string | PromiseLike<string>;\ntype GenerateHashFunction = (\n document: DocumentNode\n) => string | PromiseLike<string>;\n\ninterface BaseOptions {\n disable?: (error: ErrorResponse) => boolean;\n retry?: (error: ErrorResponse) => boolean;\n useGETForHashedQueries?: boolean;\n}\n\nexport namespace PersistedQueryLink {\n interface SHA256Options extends BaseOptions {\n sha256: SHA256Function;\n generateHash?: never;\n }\n\n interface GenerateHashOptions extends BaseOptions {\n sha256?: never;\n generateHash: GenerateHashFunction;\n }\n\n export type Options = SHA256Options | GenerateHashOptions;\n}\n\nfunction processErrors(\n graphQLErrors: GraphQLError[] | readonly GraphQLError[] | undefined\n): ErrorMeta {\n const byMessage = Object.create(null),\n byCode = Object.create(null);\n\n if (isNonEmptyArray(graphQLErrors)) {\n graphQLErrors.forEach((error) => {\n byMessage[error.message] = error;\n if (typeof error.extensions?.code == \"string\")\n byCode[error.extensions.code] = error;\n });\n }\n return {\n persistedQueryNotSupported: !!(\n byMessage.PersistedQueryNotSupported ||\n byCode.PERSISTED_QUERY_NOT_SUPPORTED\n ),\n persistedQueryNotFound: !!(\n byMessage.PersistedQueryNotFound || byCode.PERSISTED_QUERY_NOT_FOUND\n ),\n };\n}\n\nconst defaultOptions: Required<BaseOptions> = {\n disable: ({ meta }) => meta.persistedQueryNotSupported,\n retry: ({ meta }) =>\n meta.persistedQueryNotSupported || meta.persistedQueryNotFound,\n useGETForHashedQueries: false,\n};\n\nfunction operationDefinesMutation(operation: Operation) {\n return operation.query.definitions.some(\n (d) => d.kind === \"OperationDefinition\" && d.operation === \"mutation\"\n );\n}\n\nexport const createPersistedQueryLink = (\n options: PersistedQueryLink.Options\n) => {\n const hashesByQuery = new WeakMap<DocumentNode, Promise<string>>();\n // Ensure a SHA-256 hash function is provided, if a custom hash\n // generation function is not provided. We don't supply a SHA-256 hash\n // function by default, to avoid forcing one as a dependency. Developers\n // should pick the most appropriate SHA-256 function (sync or async) for\n // their needs/environment, or provide a fully custom hash generation\n // function (via the `generateHash` option) if they want to handle\n // hashing with something other than SHA-256.\n invariant(\n options &&\n (typeof options.sha256 === \"function\" ||\n typeof options.generateHash === \"function\"),\n 'Missing/invalid \"sha256\" or \"generateHash\" function. Please ' +\n 'configure one using the \"createPersistedQueryLink(options)\" options ' +\n \"parameter.\"\n );\n\n const {\n sha256,\n // If both a `sha256` and `generateHash` option are provided, the\n // `sha256` option will be ignored. Developers can configure and\n // use any hashing approach they want in a custom `generateHash`\n // function; they aren't limited to SHA-256.\n generateHash = (query: DocumentNode) =>\n Promise.resolve<string>(sha256!(print(query))),\n disable,\n retry,\n useGETForHashedQueries,\n } = compact(defaultOptions, options);\n\n let supportsPersistedQueries = true;\n\n const getHashPromise = (query: DocumentNode) =>\n new Promise<string>((resolve) => resolve(generateHash(query)));\n\n function getQueryHash(query: DocumentNode): Promise<string> {\n if (!query || typeof query !== \"object\") {\n // If the query is not an object, we won't be able to store its hash as\n // a property of query[hashesKey], so we let generateHash(query) decide\n // what to do with the bogus query.\n return getHashPromise(query);\n }\n let hash = hashesByQuery.get(query)!;\n if (!hash) hashesByQuery.set(query, (hash = getHashPromise(query)));\n return hash;\n }\n\n return new ApolloLink((operation, forward) => {\n invariant(\n forward,\n \"PersistedQueryLink cannot be the last link in the chain.\"\n );\n\n const { query } = operation;\n\n return new Observable((observer: Observer<ExecutionResult>) => {\n let subscription: ObservableSubscription;\n let retried = false;\n let originalFetchOptions: any;\n let setFetchOptions = false;\n const maybeRetry = (\n {\n response,\n networkError,\n }: { response?: ExecutionResult; networkError?: ServerError },\n cb: () => void\n ) => {\n if (!retried && ((response && response.errors) || networkError)) {\n retried = true;\n\n const graphQLErrors: GraphQLError[] = [];\n\n const responseErrors = response && response.errors;\n if (isNonEmptyArray(responseErrors)) {\n graphQLErrors.push(...responseErrors);\n }\n\n // Network errors can return GraphQL errors on for example a 403\n let networkErrors;\n if (typeof networkError?.result !== \"string\") {\n networkErrors =\n networkError &&\n networkError.result &&\n (networkError.result.errors as GraphQLError[]);\n }\n if (isNonEmptyArray(networkErrors)) {\n graphQLErrors.push(...networkErrors);\n }\n\n const disablePayload: ErrorResponse = {\n response,\n networkError,\n operation,\n graphQLErrors: isNonEmptyArray(graphQLErrors)\n ? graphQLErrors\n : void 0,\n meta: processErrors(graphQLErrors),\n };\n\n // if the server doesn't support persisted queries, don't try anymore\n supportsPersistedQueries = !disable(disablePayload);\n\n // if its not found, we can try it again, otherwise just report the error\n if (retry(disablePayload)) {\n // need to recall the link chain\n if (subscription) subscription.unsubscribe();\n // actually send the query this time\n operation.setContext({\n http: {\n includeQuery: true,\n includeExtensions: supportsPersistedQueries,\n },\n fetchOptions: {\n // Since we're including the full query, which may be\n // large, we should send it in the body of a POST request.\n // See issue #7456.\n method: \"POST\",\n },\n });\n if (setFetchOptions) {\n operation.setContext({ fetchOptions: originalFetchOptions });\n }\n subscription = forward(operation).subscribe(handler);\n\n return;\n }\n }\n cb();\n };\n const handler = {\n next: (response: ExecutionResult) => {\n maybeRetry({ response }, () => observer.next!(response));\n },\n error: (networkError: ServerError) => {\n maybeRetry({ networkError }, () => observer.error!(networkError));\n },\n complete: observer.complete!.bind(observer),\n };\n\n // don't send the query the first time\n operation.setContext({\n http: {\n includeQuery: !supportsPersistedQueries,\n includeExtensions: supportsPersistedQueries,\n },\n });\n\n // If requested, set method to GET if there are no mutations. Remember the\n // original fetchOptions so we can restore them if we fall back to a\n // non-hashed request.\n if (\n useGETForHashedQueries &&\n supportsPersistedQueries &&\n !operationDefinesMutation(operation)\n ) {\n operation.setContext(\n ({ fetchOptions = {} }: { fetchOptions: Record<string, any> }) => {\n originalFetchOptions = fetchOptions;\n return {\n fetchOptions: {\n ...fetchOptions,\n method: \"GET\",\n },\n };\n }\n );\n setFetchOptions = true;\n }\n\n if (supportsPersistedQueries) {\n getQueryHash(query)\n .then((sha256Hash) => {\n operation.extensions.persistedQuery = {\n version: VERSION,\n sha256Hash,\n };\n subscription = forward(operation).subscribe(handler);\n })\n .catch(observer.error!.bind(observer));\n } else {\n subscription = forward(operation).subscribe(handler);\n }\n\n return () => {\n if (subscription) subscription.unsubscribe();\n };\n });\n });\n};\n"]}
@@ -8,9 +8,6 @@ var utilities = require('../../utilities');
8
8
  var core = require('../core');
9
9
 
10
10
  var VERSION = 1;
11
- exports.PersistedQueryLink = void 0;
12
- (function (PersistedQueryLink) {
13
- })(exports.PersistedQueryLink || (exports.PersistedQueryLink = {}));
14
11
  function processErrors(graphQLErrors) {
15
12
  var byMessage = Object.create(null), byCode = Object.create(null);
16
13
  if (utilities.isNonEmptyArray(graphQLErrors)) {
@@ -22,7 +19,8 @@ function processErrors(graphQLErrors) {
22
19
  });
23
20
  }
24
21
  return {
25
- persistedQueryNotSupported: !!(byMessage.PersistedQueryNotSupported || byCode.PERSISTED_QUERY_NOT_SUPPORTED),
22
+ persistedQueryNotSupported: !!(byMessage.PersistedQueryNotSupported ||
23
+ byCode.PERSISTED_QUERY_NOT_SUPPORTED),
26
24
  persistedQueryNotFound: !!(byMessage.PersistedQueryNotFound || byCode.PERSISTED_QUERY_NOT_FOUND),
27
25
  };
28
26
  }
@@ -38,24 +36,27 @@ var defaultOptions = {
38
36
  useGETForHashedQueries: false,
39
37
  };
40
38
  function operationDefinesMutation(operation) {
41
- return operation.query.definitions.some(function (d) { return d.kind === 'OperationDefinition' && d.operation === 'mutation'; });
39
+ return operation.query.definitions.some(function (d) { return d.kind === "OperationDefinition" && d.operation === "mutation"; });
42
40
  }
43
41
  var createPersistedQueryLink = function (options) {
44
42
  var hashesByQuery = new WeakMap();
45
- globals.invariant(options && (typeof options.sha256 === 'function' ||
46
- typeof options.generateHash === 'function'), 38);
47
- var _a = utilities.compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) { return Promise.resolve(sha256(utilities.print(query))); } : _b, disable = _a.disable, retry = _a.retry, useGETForHashedQueries = _a.useGETForHashedQueries;
43
+ globals.invariant(options &&
44
+ (typeof options.sha256 === "function" ||
45
+ typeof options.generateHash === "function"), 38);
46
+ var _a = utilities.compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) {
47
+ return Promise.resolve(sha256(utilities.print(query)));
48
+ } : _b, disable = _a.disable, retry = _a.retry, useGETForHashedQueries = _a.useGETForHashedQueries;
48
49
  var supportsPersistedQueries = true;
49
50
  var getHashPromise = function (query) {
50
51
  return new Promise(function (resolve) { return resolve(generateHash(query)); });
51
52
  };
52
53
  function getQueryHash(query) {
53
- if (!query || typeof query !== 'object') {
54
+ if (!query || typeof query !== "object") {
54
55
  return getHashPromise(query);
55
56
  }
56
57
  var hash = hashesByQuery.get(query);
57
58
  if (!hash)
58
- hashesByQuery.set(query, hash = getHashPromise(query));
59
+ hashesByQuery.set(query, (hash = getHashPromise(query)));
59
60
  return hash;
60
61
  }
61
62
  return new core.ApolloLink(function (operation, forward) {
@@ -76,7 +77,7 @@ var createPersistedQueryLink = function (options) {
76
77
  graphQLErrors.push.apply(graphQLErrors, responseErrors);
77
78
  }
78
79
  var networkErrors = void 0;
79
- if (typeof (networkError === null || networkError === void 0 ? void 0 : networkError.result) !== 'string') {
80
+ if (typeof (networkError === null || networkError === void 0 ? void 0 : networkError.result) !== "string") {
80
81
  networkErrors =
81
82
  networkError &&
82
83
  networkError.result &&
@@ -89,8 +90,10 @@ var createPersistedQueryLink = function (options) {
89
90
  response: response,
90
91
  networkError: networkError,
91
92
  operation: operation,
92
- graphQLErrors: utilities.isNonEmptyArray(graphQLErrors) ? graphQLErrors : void 0,
93
- meta: processErrors(graphQLErrors)
93
+ graphQLErrors: utilities.isNonEmptyArray(graphQLErrors)
94
+ ? graphQLErrors
95
+ : void 0,
96
+ meta: processErrors(graphQLErrors),
94
97
  };
95
98
  supportsPersistedQueries = !disable(disablePayload);
96
99
  if (retry(disablePayload)) {
@@ -102,7 +105,7 @@ var createPersistedQueryLink = function (options) {
102
105
  includeExtensions: supportsPersistedQueries,
103
106
  },
104
107
  fetchOptions: {
105
- method: 'POST',
108
+ method: "POST",
106
109
  },
107
110
  });
108
111
  if (setFetchOptions) {
@@ -136,19 +139,21 @@ var createPersistedQueryLink = function (options) {
136
139
  var _b = _a.fetchOptions, fetchOptions = _b === void 0 ? {} : _b;
137
140
  originalFetchOptions = fetchOptions;
138
141
  return {
139
- fetchOptions: tslib.__assign(tslib.__assign({}, fetchOptions), { method: 'GET' }),
142
+ fetchOptions: tslib.__assign(tslib.__assign({}, fetchOptions), { method: "GET" }),
140
143
  };
141
144
  });
142
145
  setFetchOptions = true;
143
146
  }
144
147
  if (supportsPersistedQueries) {
145
- getQueryHash(query).then(function (sha256Hash) {
148
+ getQueryHash(query)
149
+ .then(function (sha256Hash) {
146
150
  operation.extensions.persistedQuery = {
147
151
  version: VERSION,
148
152
  sha256Hash: sha256Hash,
149
153
  };
150
154
  subscription = forward(operation).subscribe(handler);
151
- }).catch(observer.error.bind(observer));
155
+ })
156
+ .catch(observer.error.bind(observer));
152
157
  }
153
158
  else {
154
159
  subscription = forward(operation).subscribe(handler);
@@ -1 +1 @@
1
- {"version":3,"file":"persisted-queries.cjs","sources":["index.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { invariant } from '../../utilities/globals/index.js';\nimport { print } from '../../utilities/index.js';\nimport { ApolloLink } from '../core/index.js';\nimport { Observable, compact, isNonEmptyArray, } from '../../utilities/index.js';\nexport var VERSION = 1;\n;\nexport var PersistedQueryLink;\n(function (PersistedQueryLink) {\n ;\n ;\n})(PersistedQueryLink || (PersistedQueryLink = {}));\nfunction processErrors(graphQLErrors) {\n var byMessage = Object.create(null), byCode = Object.create(null);\n if (isNonEmptyArray(graphQLErrors)) {\n graphQLErrors.forEach(function (error) {\n var _a;\n byMessage[error.message] = error;\n if (typeof ((_a = error.extensions) === null || _a === void 0 ? void 0 : _a.code) == \"string\")\n byCode[error.extensions.code] = error;\n });\n }\n return {\n persistedQueryNotSupported: !!(byMessage.PersistedQueryNotSupported || byCode.PERSISTED_QUERY_NOT_SUPPORTED),\n persistedQueryNotFound: !!(byMessage.PersistedQueryNotFound || byCode.PERSISTED_QUERY_NOT_FOUND),\n };\n}\nvar defaultOptions = {\n disable: function (_a) {\n var meta = _a.meta;\n return meta.persistedQueryNotSupported;\n },\n retry: function (_a) {\n var meta = _a.meta;\n return meta.persistedQueryNotSupported || meta.persistedQueryNotFound;\n },\n useGETForHashedQueries: false,\n};\nfunction operationDefinesMutation(operation) {\n return operation.query.definitions.some(function (d) { return d.kind === 'OperationDefinition' && d.operation === 'mutation'; });\n}\nexport var createPersistedQueryLink = function (options) {\n var hashesByQuery = new WeakMap();\n invariant(options && (typeof options.sha256 === 'function' ||\n typeof options.generateHash === 'function'), 38);\n var _a = compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) { return Promise.resolve(sha256(print(query))); } : _b, disable = _a.disable, retry = _a.retry, useGETForHashedQueries = _a.useGETForHashedQueries;\n var supportsPersistedQueries = true;\n var getHashPromise = function (query) {\n return new Promise(function (resolve) { return resolve(generateHash(query)); });\n };\n function getQueryHash(query) {\n if (!query || typeof query !== 'object') {\n return getHashPromise(query);\n }\n var hash = hashesByQuery.get(query);\n if (!hash)\n hashesByQuery.set(query, hash = getHashPromise(query));\n return hash;\n }\n return new ApolloLink(function (operation, forward) {\n invariant(forward, 39);\n var query = operation.query;\n return new Observable(function (observer) {\n var subscription;\n var retried = false;\n var originalFetchOptions;\n var setFetchOptions = false;\n var maybeRetry = function (_a, cb) {\n var response = _a.response, networkError = _a.networkError;\n if (!retried && ((response && response.errors) || networkError)) {\n retried = true;\n var graphQLErrors = [];\n var responseErrors = response && response.errors;\n if (isNonEmptyArray(responseErrors)) {\n graphQLErrors.push.apply(graphQLErrors, responseErrors);\n }\n var networkErrors = void 0;\n if (typeof (networkError === null || networkError === void 0 ? void 0 : networkError.result) !== 'string') {\n networkErrors =\n networkError &&\n networkError.result &&\n networkError.result.errors;\n }\n if (isNonEmptyArray(networkErrors)) {\n graphQLErrors.push.apply(graphQLErrors, networkErrors);\n }\n var disablePayload = {\n response: response,\n networkError: networkError,\n operation: operation,\n graphQLErrors: isNonEmptyArray(graphQLErrors) ? graphQLErrors : void 0,\n meta: processErrors(graphQLErrors)\n };\n supportsPersistedQueries = !disable(disablePayload);\n if (retry(disablePayload)) {\n if (subscription)\n subscription.unsubscribe();\n operation.setContext({\n http: {\n includeQuery: true,\n includeExtensions: supportsPersistedQueries,\n },\n fetchOptions: {\n method: 'POST',\n },\n });\n if (setFetchOptions) {\n operation.setContext({ fetchOptions: originalFetchOptions });\n }\n subscription = forward(operation).subscribe(handler);\n return;\n }\n }\n cb();\n };\n var handler = {\n next: function (response) {\n maybeRetry({ response: response }, function () { return observer.next(response); });\n },\n error: function (networkError) {\n maybeRetry({ networkError: networkError }, function () { return observer.error(networkError); });\n },\n complete: observer.complete.bind(observer),\n };\n operation.setContext({\n http: {\n includeQuery: !supportsPersistedQueries,\n includeExtensions: supportsPersistedQueries,\n },\n });\n if (useGETForHashedQueries &&\n supportsPersistedQueries &&\n !operationDefinesMutation(operation)) {\n operation.setContext(function (_a) {\n var _b = _a.fetchOptions, fetchOptions = _b === void 0 ? {} : _b;\n originalFetchOptions = fetchOptions;\n return {\n fetchOptions: __assign(__assign({}, fetchOptions), { method: 'GET' }),\n };\n });\n setFetchOptions = true;\n }\n if (supportsPersistedQueries) {\n getQueryHash(query).then(function (sha256Hash) {\n operation.extensions.persistedQuery = {\n version: VERSION,\n sha256Hash: sha256Hash,\n };\n subscription = forward(operation).subscribe(handler);\n }).catch(observer.error.bind(observer));\n ;\n }\n else {\n subscription = forward(operation).subscribe(handler);\n }\n return function () {\n if (subscription)\n subscription.unsubscribe();\n };\n });\n });\n};\n//# sourceMappingURL=index.js.map"],"names":["PersistedQueryLink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O,CAAC,CAAC;AACrE,aAAa;AACb,YAAY,OAAO,YAAY;AAC/B,gBAAgB,IAAI,YAAY;AAChC,oBAAoB,YAAY,CAAC,WAAW,EAAE,CAAC;AAC/C,aAAa,CAAC;AACd,SAAS,CAAC,CAAC;AACX,KAAK,CAAC,CAAC;AACP;;;;;"}
1
+ {"version":3,"file":"persisted-queries.cjs","sources":["index.js"],"sourcesContent":["import { __assign } from \"tslib\";\nimport { invariant } from \"../../utilities/globals/index.js\";\nimport { print } from \"../../utilities/index.js\";\nimport { ApolloLink } from \"../core/index.js\";\nimport { Observable, compact, isNonEmptyArray } from \"../../utilities/index.js\";\nexport var VERSION = 1;\nfunction processErrors(graphQLErrors) {\n var byMessage = Object.create(null), byCode = Object.create(null);\n if (isNonEmptyArray(graphQLErrors)) {\n graphQLErrors.forEach(function (error) {\n var _a;\n byMessage[error.message] = error;\n if (typeof ((_a = error.extensions) === null || _a === void 0 ? void 0 : _a.code) == \"string\")\n byCode[error.extensions.code] = error;\n });\n }\n return {\n persistedQueryNotSupported: !!(byMessage.PersistedQueryNotSupported ||\n byCode.PERSISTED_QUERY_NOT_SUPPORTED),\n persistedQueryNotFound: !!(byMessage.PersistedQueryNotFound || byCode.PERSISTED_QUERY_NOT_FOUND),\n };\n}\nvar defaultOptions = {\n disable: function (_a) {\n var meta = _a.meta;\n return meta.persistedQueryNotSupported;\n },\n retry: function (_a) {\n var meta = _a.meta;\n return meta.persistedQueryNotSupported || meta.persistedQueryNotFound;\n },\n useGETForHashedQueries: false,\n};\nfunction operationDefinesMutation(operation) {\n return operation.query.definitions.some(function (d) { return d.kind === \"OperationDefinition\" && d.operation === \"mutation\"; });\n}\nexport var createPersistedQueryLink = function (options) {\n var hashesByQuery = new WeakMap();\n invariant(options &&\n (typeof options.sha256 === \"function\" ||\n typeof options.generateHash === \"function\"), 38);\n var _a = compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) {\n return Promise.resolve(sha256(print(query)));\n } : _b, disable = _a.disable, retry = _a.retry, useGETForHashedQueries = _a.useGETForHashedQueries;\n var supportsPersistedQueries = true;\n var getHashPromise = function (query) {\n return new Promise(function (resolve) { return resolve(generateHash(query)); });\n };\n function getQueryHash(query) {\n if (!query || typeof query !== \"object\") {\n return getHashPromise(query);\n }\n var hash = hashesByQuery.get(query);\n if (!hash)\n hashesByQuery.set(query, (hash = getHashPromise(query)));\n return hash;\n }\n return new ApolloLink(function (operation, forward) {\n invariant(forward, 39);\n var query = operation.query;\n return new Observable(function (observer) {\n var subscription;\n var retried = false;\n var originalFetchOptions;\n var setFetchOptions = false;\n var maybeRetry = function (_a, cb) {\n var response = _a.response, networkError = _a.networkError;\n if (!retried && ((response && response.errors) || networkError)) {\n retried = true;\n var graphQLErrors = [];\n var responseErrors = response && response.errors;\n if (isNonEmptyArray(responseErrors)) {\n graphQLErrors.push.apply(graphQLErrors, responseErrors);\n }\n var networkErrors = void 0;\n if (typeof (networkError === null || networkError === void 0 ? void 0 : networkError.result) !== \"string\") {\n networkErrors =\n networkError &&\n networkError.result &&\n networkError.result.errors;\n }\n if (isNonEmptyArray(networkErrors)) {\n graphQLErrors.push.apply(graphQLErrors, networkErrors);\n }\n var disablePayload = {\n response: response,\n networkError: networkError,\n operation: operation,\n graphQLErrors: isNonEmptyArray(graphQLErrors)\n ? graphQLErrors\n : void 0,\n meta: processErrors(graphQLErrors),\n };\n supportsPersistedQueries = !disable(disablePayload);\n if (retry(disablePayload)) {\n if (subscription)\n subscription.unsubscribe();\n operation.setContext({\n http: {\n includeQuery: true,\n includeExtensions: supportsPersistedQueries,\n },\n fetchOptions: {\n method: \"POST\",\n },\n });\n if (setFetchOptions) {\n operation.setContext({ fetchOptions: originalFetchOptions });\n }\n subscription = forward(operation).subscribe(handler);\n return;\n }\n }\n cb();\n };\n var handler = {\n next: function (response) {\n maybeRetry({ response: response }, function () { return observer.next(response); });\n },\n error: function (networkError) {\n maybeRetry({ networkError: networkError }, function () { return observer.error(networkError); });\n },\n complete: observer.complete.bind(observer),\n };\n operation.setContext({\n http: {\n includeQuery: !supportsPersistedQueries,\n includeExtensions: supportsPersistedQueries,\n },\n });\n if (useGETForHashedQueries &&\n supportsPersistedQueries &&\n !operationDefinesMutation(operation)) {\n operation.setContext(function (_a) {\n var _b = _a.fetchOptions, fetchOptions = _b === void 0 ? {} : _b;\n originalFetchOptions = fetchOptions;\n return {\n fetchOptions: __assign(__assign({}, fetchOptions), { method: \"GET\" }),\n };\n });\n setFetchOptions = true;\n }\n if (supportsPersistedQueries) {\n getQueryHash(query)\n .then(function (sha256Hash) {\n operation.extensions.persistedQuery = {\n version: VERSION,\n sha256Hash: sha256Hash,\n };\n subscription = forward(operation).subscribe(handler);\n })\n .catch(observer.error.bind(observer));\n }\n else {\n subscription = forward(operation).subscribe(handler);\n }\n return function () {\n if (subscription)\n subscription.unsubscribe();\n };\n });\n });\n};\n//# sourceMappingURL=index.js.map"],"names":["isNonEmptyArray","invariant","compact","print","ApolloLink","Observable","__assign"],"mappings":";;;;;;;;;AAKU,IAAC,OAAO,GAAG,EAAE;AACvB,SAAS,aAAa,CAAC,aAAa,EAAE;AACtC,IAAI,IAAI,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACtE,IAAI,IAAIA,yBAAe,CAAC,aAAa,CAAC,EAAE;AACxC,QAAQ,aAAa,CAAC,OAAO,CAAC,UAAU,KAAK,EAAE;AAC/C,YAAY,IAAI,EAAE,CAAC;AACnB,YAAY,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;AAC7C,YAAY,IAAI,QAAQ,CAAC,EAAE,GAAG,KAAK,CAAC,UAAU,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,QAAQ;AACzG,gBAAgB,MAAM,CAAC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E;AAC1C,gBAAgB,YAAY,CAAC,KAAK,CAAC;AACnC,qBAAqB,IAAI,CAAC,UAAU,UAAU,EAAE;AAChD,oBAAoB,SAAS,CAAC,UAAU,CAAC,cAAc,GAAG;AAC1D,wBAAwB,OAAO,EAAE,OAAO;AACxC,wBAAwB,UAAU,EAAE,UAAU;AAC9C,qBAAqB,CAAC;AACtB,oBAAoB,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACzE,iBAAiB,CAAC;AAClB,qBAAqB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1D,aAAa;AACb,iBAAiB;AACjB,gBAAgB,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACrE,aAAa;AACb,YAAY,OAAO,YAAY;AAC/B,gBAAgB,IAAI,YAAY;AAChC,oBAAoB,YAAY,CAAC,WAAW,EAAE,CAAC;AAC/C,aAAa,CAAC;AACd,SAAS,CAAC,CAAC;AACX,KAAK,CAAC,CAAC;AACP;;;;;"}
@@ -8,9 +8,6 @@ var utilities = require('../../utilities');
8
8
  var core = require('../core');
9
9
 
10
10
  var VERSION = 1;
11
- exports.PersistedQueryLink = void 0;
12
- (function (PersistedQueryLink) {
13
- })(exports.PersistedQueryLink || (exports.PersistedQueryLink = {}));
14
11
  function processErrors(graphQLErrors) {
15
12
  var byMessage = Object.create(null), byCode = Object.create(null);
16
13
  if (utilities.isNonEmptyArray(graphQLErrors)) {
@@ -22,7 +19,8 @@ function processErrors(graphQLErrors) {
22
19
  });
23
20
  }
24
21
  return {
25
- persistedQueryNotSupported: !!(byMessage.PersistedQueryNotSupported || byCode.PERSISTED_QUERY_NOT_SUPPORTED),
22
+ persistedQueryNotSupported: !!(byMessage.PersistedQueryNotSupported ||
23
+ byCode.PERSISTED_QUERY_NOT_SUPPORTED),
26
24
  persistedQueryNotFound: !!(byMessage.PersistedQueryNotFound || byCode.PERSISTED_QUERY_NOT_FOUND),
27
25
  };
28
26
  }
@@ -38,24 +36,27 @@ var defaultOptions = {
38
36
  useGETForHashedQueries: false,
39
37
  };
40
38
  function operationDefinesMutation(operation) {
41
- return operation.query.definitions.some(function (d) { return d.kind === 'OperationDefinition' && d.operation === 'mutation'; });
39
+ return operation.query.definitions.some(function (d) { return d.kind === "OperationDefinition" && d.operation === "mutation"; });
42
40
  }
43
41
  var createPersistedQueryLink = function (options) {
44
42
  var hashesByQuery = new WeakMap();
45
- globals.invariant(options && (typeof options.sha256 === 'function' ||
46
- typeof options.generateHash === 'function'), 38);
47
- var _a = utilities.compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) { return Promise.resolve(sha256(utilities.print(query))); } : _b, disable = _a.disable, retry = _a.retry, useGETForHashedQueries = _a.useGETForHashedQueries;
43
+ globals.invariant(options &&
44
+ (typeof options.sha256 === "function" ||
45
+ typeof options.generateHash === "function"), 38);
46
+ var _a = utilities.compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) {
47
+ return Promise.resolve(sha256(utilities.print(query)));
48
+ } : _b, disable = _a.disable, retry = _a.retry, useGETForHashedQueries = _a.useGETForHashedQueries;
48
49
  var supportsPersistedQueries = true;
49
50
  var getHashPromise = function (query) {
50
51
  return new Promise(function (resolve) { return resolve(generateHash(query)); });
51
52
  };
52
53
  function getQueryHash(query) {
53
- if (!query || typeof query !== 'object') {
54
+ if (!query || typeof query !== "object") {
54
55
  return getHashPromise(query);
55
56
  }
56
57
  var hash = hashesByQuery.get(query);
57
58
  if (!hash)
58
- hashesByQuery.set(query, hash = getHashPromise(query));
59
+ hashesByQuery.set(query, (hash = getHashPromise(query)));
59
60
  return hash;
60
61
  }
61
62
  return new core.ApolloLink(function (operation, forward) {
@@ -76,7 +77,7 @@ var createPersistedQueryLink = function (options) {
76
77
  graphQLErrors.push.apply(graphQLErrors, responseErrors);
77
78
  }
78
79
  var networkErrors = void 0;
79
- if (typeof (networkError === null || networkError === void 0 ? void 0 : networkError.result) !== 'string') {
80
+ if (typeof (networkError === null || networkError === void 0 ? void 0 : networkError.result) !== "string") {
80
81
  networkErrors =
81
82
  networkError &&
82
83
  networkError.result &&
@@ -89,8 +90,10 @@ var createPersistedQueryLink = function (options) {
89
90
  response: response,
90
91
  networkError: networkError,
91
92
  operation: operation,
92
- graphQLErrors: utilities.isNonEmptyArray(graphQLErrors) ? graphQLErrors : void 0,
93
- meta: processErrors(graphQLErrors)
93
+ graphQLErrors: utilities.isNonEmptyArray(graphQLErrors)
94
+ ? graphQLErrors
95
+ : void 0,
96
+ meta: processErrors(graphQLErrors),
94
97
  };
95
98
  supportsPersistedQueries = !disable(disablePayload);
96
99
  if (retry(disablePayload)) {
@@ -102,7 +105,7 @@ var createPersistedQueryLink = function (options) {
102
105
  includeExtensions: supportsPersistedQueries,
103
106
  },
104
107
  fetchOptions: {
105
- method: 'POST',
108
+ method: "POST",
106
109
  },
107
110
  });
108
111
  if (setFetchOptions) {
@@ -136,19 +139,21 @@ var createPersistedQueryLink = function (options) {
136
139
  var _b = _a.fetchOptions, fetchOptions = _b === void 0 ? {} : _b;
137
140
  originalFetchOptions = fetchOptions;
138
141
  return {
139
- fetchOptions: tslib.__assign(tslib.__assign({}, fetchOptions), { method: 'GET' }),
142
+ fetchOptions: tslib.__assign(tslib.__assign({}, fetchOptions), { method: "GET" }),
140
143
  };
141
144
  });
142
145
  setFetchOptions = true;
143
146
  }
144
147
  if (supportsPersistedQueries) {
145
- getQueryHash(query).then(function (sha256Hash) {
148
+ getQueryHash(query)
149
+ .then(function (sha256Hash) {
146
150
  operation.extensions.persistedQuery = {
147
151
  version: VERSION,
148
152
  sha256Hash: sha256Hash,
149
153
  };
150
154
  subscription = forward(operation).subscribe(handler);
151
- }).catch(observer.error.bind(observer));
155
+ })
156
+ .catch(observer.error.bind(observer));
152
157
  }
153
158
  else {
154
159
  subscription = forward(operation).subscribe(handler);