@apollo/client 4.0.0-rc.8 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/CHANGELOG.md +2488 -0
  2. package/README.md +6 -2
  3. package/__cjs/cache/inmemory/inMemoryCache.cjs +2 -2
  4. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  5. package/__cjs/cache/inmemory/policies.cjs +18 -12
  6. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  7. package/__cjs/cache/inmemory/writeToStore.cjs +1 -1
  8. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  9. package/__cjs/core/ObservableQuery.cjs +1 -1
  10. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  11. package/__cjs/core/ObservableQuery.d.cts +1 -1
  12. package/__cjs/core/QueryInfo.cjs +2 -6
  13. package/__cjs/core/QueryInfo.cjs.map +1 -1
  14. package/__cjs/core/index.cjs.map +1 -1
  15. package/__cjs/core/index.d.cts +1 -1
  16. package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
  17. package/__cjs/incremental/handlers/defer20220824.d.cts +9 -6
  18. package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
  19. package/__cjs/incremental/handlers/notImplemented.d.cts +11 -0
  20. package/__cjs/link/batch/batchLink.cjs +30 -2
  21. package/__cjs/link/batch/batchLink.cjs.map +1 -1
  22. package/__cjs/link/batch/batchLink.d.cts +69 -2
  23. package/__cjs/link/batch-http/BaseBatchHttpLink.cjs +156 -0
  24. package/__cjs/link/batch-http/BaseBatchHttpLink.cjs.map +1 -0
  25. package/__cjs/link/batch-http/BaseBatchHttpLink.d.cts +68 -0
  26. package/__cjs/link/batch-http/batchHttpLink.cjs +3 -128
  27. package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
  28. package/__cjs/link/batch-http/batchHttpLink.d.cts +4 -20
  29. package/__cjs/link/batch-http/index.cjs +2 -1
  30. package/__cjs/link/batch-http/index.cjs.map +1 -1
  31. package/__cjs/link/batch-http/index.d.cts +2 -1
  32. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +3 -3
  33. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
  34. package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +20 -1
  35. package/__cjs/link/context/index.cjs +19 -0
  36. package/__cjs/link/context/index.cjs.map +1 -1
  37. package/__cjs/link/context/index.d.cts +64 -2
  38. package/__cjs/link/core/ApolloLink.cjs.map +1 -1
  39. package/__cjs/link/core/ApolloLink.d.cts +5 -2
  40. package/__cjs/link/core/types.d.cts +0 -4
  41. package/__cjs/link/http/BaseHttpLink.cjs +59 -8
  42. package/__cjs/link/http/BaseHttpLink.cjs.map +1 -1
  43. package/__cjs/link/http/BaseHttpLink.d.cts +256 -2
  44. package/__cjs/link/http/HttpLink.cjs +1 -1
  45. package/__cjs/link/http/HttpLink.cjs.map +1 -1
  46. package/__cjs/link/http/HttpLink.d.cts +5 -208
  47. package/__cjs/link/http/rewriteURIForGET.cjs.map +1 -1
  48. package/__cjs/link/http/rewriteURIForGET.d.cts +2 -2
  49. package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
  50. package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +7 -7
  51. package/__cjs/link/index.cjs.map +1 -1
  52. package/__cjs/link/index.d.cts +2 -1
  53. package/__cjs/link/persisted-queries/index.cjs +16 -0
  54. package/__cjs/link/persisted-queries/index.cjs.map +1 -1
  55. package/__cjs/link/persisted-queries/index.d.cts +181 -0
  56. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +48 -0
  57. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
  58. package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +115 -0
  59. package/__cjs/link/retry/retryLink.cjs +25 -3
  60. package/__cjs/link/retry/retryLink.cjs.map +1 -1
  61. package/__cjs/link/retry/retryLink.d.cts +82 -9
  62. package/__cjs/link/schema/index.cjs +20 -0
  63. package/__cjs/link/schema/index.cjs.map +1 -1
  64. package/__cjs/link/schema/index.d.cts +128 -6
  65. package/__cjs/link/ws/index.cjs +18 -0
  66. package/__cjs/link/ws/index.cjs.map +1 -1
  67. package/__cjs/link/ws/index.d.cts +56 -5
  68. package/__cjs/local-state/LocalState.cjs.map +1 -1
  69. package/__cjs/masking/GraphQLCodegenDataMasking.d.cts +10 -42
  70. package/__cjs/masking/PreserveTypes.cjs +3 -0
  71. package/__cjs/masking/PreserveTypes.cjs.map +1 -0
  72. package/__cjs/masking/PreserveTypes.d.cts +26 -0
  73. package/__cjs/masking/index.cjs.map +1 -1
  74. package/__cjs/masking/index.d.cts +1 -1
  75. package/__cjs/masking/internal/types.d.cts +0 -1
  76. package/__cjs/masking/types.d.cts +6 -23
  77. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  78. package/__cjs/react/hooks/useBackgroundQuery.d.cts +2 -1
  79. package/__cjs/react/hooks/useLazyQuery.d.cts +1 -1
  80. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  81. package/__cjs/react/hooks/useLoadableQuery.d.cts +2 -1
  82. package/__cjs/react/hooks/useQuery.d.cts +1 -1
  83. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  84. package/__cjs/react/hooks/useQueryRefHandlers.d.cts +2 -1
  85. package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
  86. package/__cjs/react/hooks/useReadQuery.d.cts +1 -1
  87. package/__cjs/react/hooks/useSyncExternalStore.cjs +2 -6
  88. package/__cjs/react/hooks/useSyncExternalStore.cjs.map +1 -1
  89. package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
  90. package/__cjs/react/query-preloader/createQueryPreloader.d.cts +1 -1
  91. package/__cjs/react/types/deprecated.d.cts +1 -1
  92. package/__cjs/react/types/types.documentation.d.cts +1 -1
  93. package/__cjs/testing/core/mocking/mockSubscriptionLink.d.cts +1 -1
  94. package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
  95. package/__cjs/testing/react/MockedProvider.d.cts +5 -0
  96. package/__cjs/utilities/common/stripTypename.cjs +11 -0
  97. package/__cjs/utilities/common/stripTypename.cjs.map +1 -1
  98. package/__cjs/utilities/common/stripTypename.d.cts +11 -0
  99. package/__cjs/utilities/graphql/DocumentTransform.cjs +84 -1
  100. package/__cjs/utilities/graphql/DocumentTransform.cjs.map +1 -1
  101. package/__cjs/utilities/graphql/DocumentTransform.d.cts +94 -5
  102. package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs +27 -0
  103. package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs.map +1 -1
  104. package/__cjs/utilities/graphql/isFormattedExecutionResult.d.cts +27 -0
  105. package/__cjs/utilities/graphql/operations.cjs +54 -3
  106. package/__cjs/utilities/graphql/operations.cjs.map +1 -1
  107. package/__cjs/utilities/graphql/operations.d.cts +54 -3
  108. package/__cjs/utilities/graphql/storeUtils.cjs +9 -0
  109. package/__cjs/utilities/graphql/storeUtils.cjs.map +1 -1
  110. package/__cjs/utilities/graphql/storeUtils.d.cts +9 -0
  111. package/__cjs/utilities/graphql/transform.cjs +12 -1
  112. package/__cjs/utilities/graphql/transform.cjs.map +1 -1
  113. package/__cjs/utilities/graphql/transform.d.cts +12 -1
  114. package/__cjs/utilities/internal/canonicalStringify.cjs +30 -7
  115. package/__cjs/utilities/internal/canonicalStringify.cjs.map +1 -1
  116. package/__cjs/utilities/internal/canonicalStringify.d.cts +30 -7
  117. package/__cjs/utilities/internal/getMainDefinition.cjs +36 -8
  118. package/__cjs/utilities/internal/getMainDefinition.cjs.map +1 -1
  119. package/__cjs/utilities/internal/getMainDefinition.d.cts +36 -8
  120. package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +2 -6
  121. package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs.map +1 -1
  122. package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +1 -1
  123. package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
  124. package/__cjs/v4-migration.cjs +9 -0
  125. package/__cjs/v4-migration.cjs.map +1 -0
  126. package/__cjs/v4-migration.d.cts +826 -0
  127. package/__cjs/version.cjs +1 -1
  128. package/__cjs/version.cjs.map +1 -1
  129. package/cache/inmemory/inMemoryCache.js +2 -2
  130. package/cache/inmemory/inMemoryCache.js.map +1 -1
  131. package/cache/inmemory/policies.js +18 -12
  132. package/cache/inmemory/policies.js.map +1 -1
  133. package/cache/inmemory/writeToStore.js +1 -1
  134. package/cache/inmemory/writeToStore.js.map +1 -1
  135. package/core/ObservableQuery.d.ts +1 -1
  136. package/core/ObservableQuery.js +1 -1
  137. package/core/ObservableQuery.js.map +1 -1
  138. package/core/QueryInfo.js +1 -2
  139. package/core/QueryInfo.js.map +1 -1
  140. package/core/index.d.ts +1 -1
  141. package/core/index.js.map +1 -1
  142. package/incremental/handlers/defer20220824.d.ts +9 -6
  143. package/incremental/handlers/defer20220824.js.map +1 -1
  144. package/incremental/handlers/notImplemented.d.ts +11 -0
  145. package/incremental/handlers/notImplemented.js.map +1 -1
  146. package/legacyEntryPoints/v4-migration/index.d.ts +1 -0
  147. package/legacyEntryPoints/v4-migration/index.js +1 -0
  148. package/legacyEntryPoints/v4-migration/v4-migration.cjs +1 -0
  149. package/legacyEntryPoints/v4-migration/v4-migration.d.cts +1 -0
  150. package/link/batch/batchLink.d.ts +69 -2
  151. package/link/batch/batchLink.js +30 -2
  152. package/link/batch/batchLink.js.map +1 -1
  153. package/link/batch-http/BaseBatchHttpLink.d.ts +68 -0
  154. package/link/batch-http/BaseBatchHttpLink.js +152 -0
  155. package/link/batch-http/BaseBatchHttpLink.js.map +1 -0
  156. package/link/batch-http/batchHttpLink.d.ts +5 -21
  157. package/link/batch-http/batchHttpLink.js +1 -125
  158. package/link/batch-http/batchHttpLink.js.map +1 -1
  159. package/link/batch-http/index.d.ts +2 -1
  160. package/link/batch-http/index.js +2 -1
  161. package/link/batch-http/index.js.map +1 -1
  162. package/link/client-awareness/ClientAwarenessLink.d.ts +21 -2
  163. package/link/client-awareness/ClientAwarenessLink.js +3 -3
  164. package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
  165. package/link/context/index.d.ts +65 -3
  166. package/link/context/index.js +19 -0
  167. package/link/context/index.js.map +1 -1
  168. package/link/core/ApolloLink.d.ts +5 -2
  169. package/link/core/ApolloLink.js.map +1 -1
  170. package/link/core/types.d.ts +0 -4
  171. package/link/core/types.js.map +1 -1
  172. package/link/http/BaseHttpLink.d.ts +257 -3
  173. package/link/http/BaseHttpLink.js +59 -8
  174. package/link/http/BaseHttpLink.js.map +1 -1
  175. package/link/http/HttpLink.d.ts +6 -209
  176. package/link/http/HttpLink.js +1 -1
  177. package/link/http/HttpLink.js.map +1 -1
  178. package/link/http/rewriteURIForGET.d.ts +2 -2
  179. package/link/http/rewriteURIForGET.js.map +1 -1
  180. package/link/http/selectHttpOptionsAndBody.d.ts +7 -7
  181. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  182. package/link/index.d.ts +2 -1
  183. package/link/index.js.map +1 -1
  184. package/link/persisted-queries/index.d.ts +182 -1
  185. package/link/persisted-queries/index.js +16 -0
  186. package/link/persisted-queries/index.js.map +1 -1
  187. package/link/remove-typename/removeTypenameFromVariables.d.ts +115 -0
  188. package/link/remove-typename/removeTypenameFromVariables.js +48 -0
  189. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  190. package/link/retry/retryLink.d.ts +83 -10
  191. package/link/retry/retryLink.js +25 -3
  192. package/link/retry/retryLink.js.map +1 -1
  193. package/link/schema/index.d.ts +129 -7
  194. package/link/schema/index.js +20 -0
  195. package/link/schema/index.js.map +1 -1
  196. package/link/ws/index.d.ts +56 -5
  197. package/link/ws/index.js +18 -0
  198. package/link/ws/index.js.map +1 -1
  199. package/local-state/LocalState.js.map +1 -1
  200. package/masking/GraphQLCodegenDataMasking.d.ts +10 -42
  201. package/masking/GraphQLCodegenDataMasking.js.map +1 -1
  202. package/masking/PreserveTypes.d.ts +26 -0
  203. package/masking/PreserveTypes.js +2 -0
  204. package/masking/PreserveTypes.js.map +1 -0
  205. package/masking/index.d.ts +1 -1
  206. package/masking/index.js.map +1 -1
  207. package/masking/internal/types.d.ts +0 -1
  208. package/masking/internal/types.js.map +1 -1
  209. package/masking/types.d.ts +6 -23
  210. package/masking/types.js.map +1 -1
  211. package/package.json +8 -2
  212. package/react/hooks/useBackgroundQuery.d.ts +2 -1
  213. package/react/hooks/useBackgroundQuery.js.map +1 -1
  214. package/react/hooks/useLazyQuery.d.ts +1 -1
  215. package/react/hooks/useLoadableQuery.d.ts +2 -1
  216. package/react/hooks/useLoadableQuery.js.map +1 -1
  217. package/react/hooks/useQuery.d.ts +1 -1
  218. package/react/hooks/useQueryRefHandlers.d.ts +2 -1
  219. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  220. package/react/hooks/useReadQuery.d.ts +1 -1
  221. package/react/hooks/useReadQuery.js.map +1 -1
  222. package/react/hooks/useSyncExternalStore.js +1 -1
  223. package/react/hooks/useSyncExternalStore.js.map +1 -1
  224. package/react/hooks-compiled/useBackgroundQuery.d.ts +2 -1
  225. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  226. package/react/hooks-compiled/useLazyQuery.d.ts +1 -1
  227. package/react/hooks-compiled/useLoadableQuery.d.ts +2 -1
  228. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  229. package/react/hooks-compiled/useQuery.d.ts +1 -1
  230. package/react/hooks-compiled/useQueryRefHandlers.d.ts +2 -1
  231. package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
  232. package/react/hooks-compiled/useReadQuery.d.ts +1 -1
  233. package/react/hooks-compiled/useReadQuery.js.map +1 -1
  234. package/react/hooks-compiled/useSyncExternalStore.js +1 -1
  235. package/react/hooks-compiled/useSyncExternalStore.js.map +1 -1
  236. package/react/query-preloader/createQueryPreloader.d.ts +1 -1
  237. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  238. package/react/types/deprecated.d.ts +1 -1
  239. package/react/types/deprecated.js.map +1 -1
  240. package/react/types/types.documentation.d.ts +1 -1
  241. package/react/types/types.documentation.js.map +1 -1
  242. package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
  243. package/testing/react/MockedProvider.d.ts +5 -0
  244. package/testing/react/MockedProvider.js.map +1 -1
  245. package/utilities/common/stripTypename.d.ts +11 -0
  246. package/utilities/common/stripTypename.js +11 -0
  247. package/utilities/common/stripTypename.js.map +1 -1
  248. package/utilities/graphql/DocumentTransform.d.ts +94 -5
  249. package/utilities/graphql/DocumentTransform.js +84 -1
  250. package/utilities/graphql/DocumentTransform.js.map +1 -1
  251. package/utilities/graphql/isFormattedExecutionResult.d.ts +27 -0
  252. package/utilities/graphql/isFormattedExecutionResult.js +27 -0
  253. package/utilities/graphql/isFormattedExecutionResult.js.map +1 -1
  254. package/utilities/graphql/operations.d.ts +54 -3
  255. package/utilities/graphql/operations.js +54 -3
  256. package/utilities/graphql/operations.js.map +1 -1
  257. package/utilities/graphql/storeUtils.d.ts +9 -0
  258. package/utilities/graphql/storeUtils.js +9 -0
  259. package/utilities/graphql/storeUtils.js.map +1 -1
  260. package/utilities/graphql/transform.d.ts +12 -1
  261. package/utilities/graphql/transform.js +12 -1
  262. package/utilities/graphql/transform.js.map +1 -1
  263. package/utilities/internal/canonicalStringify.d.ts +30 -7
  264. package/utilities/internal/canonicalStringify.js +30 -7
  265. package/utilities/internal/canonicalStringify.js.map +1 -1
  266. package/utilities/internal/getMainDefinition.d.ts +37 -9
  267. package/utilities/internal/getMainDefinition.js +36 -8
  268. package/utilities/internal/getMainDefinition.js.map +1 -1
  269. package/utilities/internal/removeDirectivesFromDocument.js +1 -2
  270. package/utilities/internal/removeDirectivesFromDocument.js.map +1 -1
  271. package/utilities/internal/types/DocumentationTypes.d.ts +1 -1
  272. package/utilities/subscriptions/relay/index.js.map +1 -1
  273. package/v4-migration.d.ts +826 -0
  274. package/v4-migration.js +8 -0
  275. package/v4-migration.js.map +1 -0
  276. package/version.js +1 -1
  277. package/version.js.map +1 -1
@@ -37,5 +37,5 @@ export class HttpLink extends ApolloLink {
37
37
  * @deprecated
38
38
  * Use `HttpLink` from `@apollo/client/link/http` instead.
39
39
  */
40
- export const createHttpLink = (linkOptions = {}) => new HttpLink(linkOptions);
40
+ export const createHttpLink = (options = {}) => new HttpLink(options);
41
41
  //# sourceMappingURL=HttpLink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HttpLink.js","sourceRoot":"","sources":["../../../src/link/http/HttpLink.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAG3E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA+MjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,QAAS,SAAQ,UAAU;IACtC,YAAY,UAA0D,EAAE;QACtE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;YAC/C,IAAI,mBAAmB,CAAC,OAAO,CAAC;YAChC,IAAI,YAAY,CAAC,OAAO,CAAC;SAC1B,CAAC,CAAC;QACH,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACvC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,cAA8D,EAAE,EAChE,EAAE,CAAC,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC","sourcesContent":["import type { ASTNode } from \"graphql\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\nimport { ClientAwarenessLink } from \"@apollo/client/link/client-awareness\";\nimport type { print } from \"@apollo/client/utilities\";\n\nimport { BaseHttpLink } from \"./BaseHttpLink.js\";\n\nexport declare namespace HttpLink {\n /**\n * Options passed to `HttpLink` through [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context). Previous\n * non-terminating links in the link chain also can set these values to\n * customize the behavior of `HttpLink` for each operation.\n *\n * > [!NOTE]\n * > Some of these values can also be provided to the `HttpLink` constructor.\n * > If a value is provided to both, the value in `context` takes precedence.\n */\n interface ContextOptions {\n /** {@inheritDoc @apollo/client/link/http!HttpLink.Shared.Options#uri:member} */\n uri?: string | HttpLink.UriFunction;\n\n /** {@inheritDoc @apollo/client/link/http!HttpLink.Shared.Options#headers:member} */\n headers?: Record<string, string>;\n\n /** {@inheritDoc @apollo/client/link/http!HttpLink.Shared.Options#credentials:member} */\n credentials?: RequestCredentials;\n\n /** {@inheritDoc @apollo/client/link/http!HttpLink.Shared.Options#fetchOptions:member} */\n fetchOptions?: RequestInit;\n\n /**\n * An object that configures advanced `HttpLink` functionality, such as\n * support for persisted queries.\n */\n http?: HttpLink.HttpOptions;\n }\n\n /**\n * Options passed to `HttpLink` through the `http` property of a request\n * context.\n */\n export interface HttpOptions {\n /** {@inheritDoc @apollo/client/link/http!HttpLink.Shared.Options#includeExtensions:member} */\n includeExtensions?: boolean;\n\n /**\n * If `false`, the GraphQL query string is not included in the request. Set\n * this option if you're sending a request that uses a [persisted query](https://www.apollographql.com/docs/react/api/link/persisted-queries/).\n *\n * @defaultValue true\n */\n includeQuery?: boolean;\n\n /** {@inheritDoc @apollo/client/link/http!HttpLink.Shared.Options#preserveHeaderCase:member} */\n preserveHeaderCase?: boolean;\n\n /**\n * A list of additional `accept` headers to include in the request,\n * as defined in https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.2\n *\n * @example\n *\n * ```json\n * [\"application/custom+json;q=1.0\"]\n * ```\n */\n accept?: string[];\n }\n\n export namespace Shared {\n /** These options are shared between `HttpLink` and `BatchHttpLink` */\n export interface Options {\n /**\n * The URL of the GraphQL endpoint to send requests to. Can also be a\n * function that accepts an `ApolloLink.Operation` object and returns the\n * string URL to use for that operation.\n *\n * @defaultValue \"/graphql\"\n */\n uri?: string | HttpLink.UriFunction;\n\n /**\n * If `true`, includes the `extensions` field in operations sent to your\n * GraphQL endpoint.\n *\n * @defaultValue true\n */\n includeExtensions?: boolean;\n\n /**\n * A function to use instead of calling the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) directly\n * when sending HTTP requests to your GraphQL endpoint. The function must\n * conform to the signature of `fetch`.\n *\n * By default, the Fetch API is used unless it isn't available in your\n * runtime environment.\n *\n * See [Customizing `fetch`](https://apollographql.com/docs/react/api/link/introduction#customizing-fetch).\n */\n fetch?: typeof fetch;\n\n /**\n * An object representing headers to include in every HTTP request.\n *\n * @example\n *\n * ```json\n * {\n * \"Authorization\": \"Bearer 1234\"\n * }\n * ```\n */\n headers?: Record<string, string>;\n\n /**\n * If `true`, header names won't be automatically normalized to lowercase.\n * This allows for non-http-spec-compliant servers that might expect\n * capitalized header names.\n *\n * @defaultValue false\n */\n preserveHeaderCase?: boolean;\n\n /**\n * The credentials policy to use for each `fetch` call.\n */\n credentials?: RequestCredentials;\n\n /**\n * Any overrides of the fetch options argument to pass to the fetch call.\n *\n * An object containing options to use for each call to `fetch`. If a\n * particular option is not included in this object, the default value of\n * that option is used.\n *\n * > [!NOTE]\n * > If you set `fetchOptions.method` to `GET`, `HttpLink` follows [standard\n * > GraphQL HTTP GET encoding](http://graphql.org/learn/serving-over-http/#get-request).\n *\n * See [available options](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n */\n fetchOptions?: RequestInit;\n\n /**\n * If `true`, unused variables from the operation will not be stripped from\n * the request and will instead be sent to the GraphQL endpoint.\n *\n * @remarks\n * Unused variables are likely to trigger server-side validation errors,\n * per https://spec.graphql.org/draft/#sec-All-Variables-Used.\n * `includeUnusedVariables` can be useful if your server deviates\n * from the GraphQL specification by not strictly enforcing that rule.\n *\n * @defaultValue false\n */\n includeUnusedVariables?: boolean;\n /**\n * A function to use when transforming a GraphQL document into a string. It\n * accepts an `ASTNode` (typically a `DocumentNode`) and the original `print`\n * function as arguments, and is expected to return a string. This option\n * enables you to, for example, use `stripIgnoredCharacters` to remove\n * whitespace from queries.\n *\n * By default the [GraphQL `print` function](https://graphql.org/graphql-js/language/#print) is used.\n *\n * @example\n *\n * ```ts\n * import { stripIgnoredCharacters } from \"graphql\";\n *\n * const httpLink = new HttpLink({\n * uri: \"/graphql\",\n * print: (ast, originalPrint) => stripIgnoredCharacters(originalPrint(ast)),\n * });\n * ```\n */\n print?: HttpLink.Printer;\n }\n }\n\n /**\n * Options provided to the `HttpLink` constructor.\n *\n * > [!NOTE]\n * > Some of these options are also available to override in [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context).\n * > Context options override the options passed to the constructor. Treat\n * > these options as default values that are used when the request context\n * > does not override the value.\n */\n interface Options extends Shared.Options {\n /**\n * If `true`, the link uses an HTTP `GET` request when sending query\n * operations to your GraphQL endpoint. Mutation operations continue to use\n * `POST` requests. If you want all operations to use `GET` requests,\n * set `fetchOptions.method` instead.\n *\n * @defaultValue false\n */\n useGETForQueries?: boolean;\n }\n\n interface Body {\n query?: string;\n operationName?: string;\n variables?: Record<string, any>;\n extensions?: Record<string, any>;\n }\n\n type Printer = (node: ASTNode, originalPrint: typeof print) => string;\n type UriFunction = (operation: ApolloLink.Operation) => string;\n}\n\n/**\n * `HttpLink` is a terminating link that sends a GraphQL operation to a remote\n * endpoint over HTTP. It combines the functionality of `BaseHttpLink` and\n * `ClientAwarenessLink` into a single link.\n *\n * @remarks\n *\n * `HttpLink` supports both POST and GET requests, and you can configure HTTP\n * options on a per-operation basis. You can use these options for\n * authentication, persisted queries, dynamic URIs, and other granular updates.\n *\n * @example\n *\n * ```ts\n * import { HttpLink } from \"@apollo/client\";\n *\n * const link = new HttpLink({\n * uri: \"http://localhost:4000/graphql\",\n * // Additional options\n * });\n * ```\n */\nexport class HttpLink extends ApolloLink {\n constructor(options: HttpLink.Options & ClientAwarenessLink.Options = {}) {\n const { left, right, request } = ApolloLink.from([\n new ClientAwarenessLink(options),\n new BaseHttpLink(options),\n ]);\n super(request);\n Object.assign(this, { left, right });\n }\n}\n\n/**\n * @deprecated\n * Use `HttpLink` from `@apollo/client/link/http` instead.\n */\nexport const createHttpLink = (\n linkOptions: HttpLink.Options & ClientAwarenessLink.Options = {}\n) => new HttpLink(linkOptions);\n"]}
1
+ {"version":3,"file":"HttpLink.js","sourceRoot":"","sources":["../../../src/link/http/HttpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA4BjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,QAAS,SAAQ,UAAU;IACtC,YAAY,UAA4B,EAAE;QACxC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;YAC/C,IAAI,mBAAmB,CAAC,OAAO,CAAC;YAChC,IAAI,YAAY,CAAC,OAAO,CAAC;SAC1B,CAAC,CAAC;QACH,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACvC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,UAA4B,EAAE,EAAE,EAAE,CAC/D,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC","sourcesContent":["import { ApolloLink } from \"@apollo/client/link\";\nimport { ClientAwarenessLink } from \"@apollo/client/link/client-awareness\";\n\nimport { BaseHttpLink } from \"./BaseHttpLink.js\";\n\nexport declare namespace HttpLink {\n /**\n * Options passed to `HttpLink` through [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context). Previous\n * non-terminating links in the link chain also can set these values to\n * customize the behavior of `HttpLink` for each operation.\n *\n * > [!NOTE]\n * > Some of these values can also be provided to the `HttpLink` constructor.\n * > If a value is provided to both, the value in `context` takes precedence.\n */\n interface ContextOptions\n extends BaseHttpLink.ContextOptions,\n ClientAwarenessLink.ContextOptions {}\n\n /**\n * Options provided to the `HttpLink` constructor.\n *\n * > [!NOTE]\n * > Some of these options are also available to override in [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context).\n * > Context options override the options passed to the constructor. Treat\n * > these options as default values that are used when the request context\n * > does not override the value.\n */\n interface Options extends BaseHttpLink.Options, ClientAwarenessLink.Options {}\n}\n\n/**\n * `HttpLink` is a terminating link that sends a GraphQL operation to a remote\n * endpoint over HTTP. It combines the functionality of `BaseHttpLink` and\n * `ClientAwarenessLink` into a single link.\n *\n * @remarks\n *\n * `HttpLink` supports both POST and GET requests, and you can configure HTTP\n * options on a per-operation basis. You can use these options for\n * authentication, persisted queries, dynamic URIs, and other granular updates.\n *\n * @example\n *\n * ```ts\n * import { HttpLink } from \"@apollo/client\";\n *\n * const link = new HttpLink({\n * uri: \"http://localhost:4000/graphql\",\n * // Additional options\n * });\n * ```\n */\nexport class HttpLink extends ApolloLink {\n constructor(options: HttpLink.Options = {}) {\n const { left, right, request } = ApolloLink.from([\n new ClientAwarenessLink(options),\n new BaseHttpLink(options),\n ]);\n super(request);\n Object.assign(this, { left, right });\n }\n}\n\n/**\n * @deprecated\n * Use `HttpLink` from `@apollo/client/link/http` instead.\n */\nexport const createHttpLink = (options: HttpLink.Options = {}) =>\n new HttpLink(options);\n"]}
@@ -1,5 +1,5 @@
1
- import type { HttpLink } from "./HttpLink.js";
2
- export declare function rewriteURIForGET(chosenURI: string, body: HttpLink.Body): {
1
+ import type { BaseHttpLink } from "./BaseHttpLink.js";
2
+ export declare function rewriteURIForGET(chosenURI: string, body: BaseHttpLink.Body): {
3
3
  parseError: unknown;
4
4
  newURI?: undefined;
5
5
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"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AC;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,MAAM,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,MAAM,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IACtE,MAAM,MAAM,GACV,WAAW,GAAG,iBAAiB,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;IACrE,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC","sourcesContent":["import type { HttpLink } from \"./HttpLink.js\";\n\n// For GET operations, returns the given URI rewritten with parameters, or a\n// parse error.\nexport function rewriteURIForGET(chosenURI: string, body: HttpLink.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 = JSON.stringify(body.variables);\n } catch (parseError) {\n return { parseError };\n }\n addQueryParam(\"variables\", serializedVariables);\n }\n if (body.extensions) {\n let serializedExtensions;\n try {\n serializedExtensions = JSON.stringify(body.extensions);\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":"AAEA,4EAA4E;AAC5E,eAAe;AACf,MAAM,UAAU,gBAAgB,CAAC,SAAiB,EAAE,IAAuB;IACzE,yEAAyE;IACzE,yCAAyC;IACzC,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,EAAE;QACnD,WAAW,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,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,CAAC;QACxB,IAAI,CAAC;YACH,mBAAmB,GAAG,IAAI,CAAC,SAAS,C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ink.js\";\n\n// For GET operations, returns the given URI rewritten with parameters, or a\n// parse error.\nexport function rewriteURIForGET(chosenURI: string, body: BaseHttpLink.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 = JSON.stringify(body.variables);\n } catch (parseError) {\n return { parseError };\n }\n addQueryParam(\"variables\", serializedVariables);\n }\n if (body.extensions) {\n let serializedExtensions;\n try {\n serializedExtensions = JSON.stringify(body.extensions);\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,13 +1,13 @@
1
1
  import type { ApolloLink } from "@apollo/client/link";
2
- import type { HttpLink } from "./HttpLink.js";
2
+ import type { BaseHttpLink } from "./BaseHttpLink.js";
3
3
  interface HttpConfig {
4
- http?: HttpLink.HttpOptions;
4
+ http?: BaseHttpLink.HttpOptions;
5
5
  options?: any;
6
6
  headers?: Record<string, string>;
7
7
  credentials?: any;
8
8
  }
9
9
  export declare const fallbackHttpConfig: {
10
- http: HttpLink.HttpOptions;
10
+ http: BaseHttpLink.HttpOptions;
11
11
  headers: {
12
12
  accept: string;
13
13
  "content-type": string;
@@ -16,14 +16,14 @@ export declare const fallbackHttpConfig: {
16
16
  method: string;
17
17
  };
18
18
  };
19
- export declare const defaultPrinter: HttpLink.Printer;
19
+ export declare const defaultPrinter: BaseHttpLink.Printer;
20
20
  export declare function selectHttpOptionsAndBody(operation: ApolloLink.Operation, fallbackConfig: HttpConfig, ...configs: Array<HttpConfig>): {
21
21
  options: HttpConfig & Record<string, any>;
22
- body: HttpLink.Body;
22
+ body: BaseHttpLink.Body;
23
23
  };
24
- export declare function selectHttpOptionsAndBodyInternal(operation: ApolloLink.Operation, printer: HttpLink.Printer, ...configs: HttpConfig[]): {
24
+ export declare function selectHttpOptionsAndBodyInternal(operation: ApolloLink.Operation, printer: BaseHttpLink.Printer, ...configs: HttpConfig[]): {
25
25
  options: HttpConfig & Record<string, any>;
26
- body: HttpLink.Body;
26
+ body: BaseHttpLink.Body;
27
27
  };
28
28
  export {};
29
29
  //# sourceMappingURL=selectHttpOptionsAndBody.d.ts.map
@@ -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;AAWjD,MAAM,kBAAkB,GAAyB;IAC/C,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,IAAI;IACvB,kBAAkB,EAAE,KAAK;CAC1B,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,qEAAqE;IACrE,MAAM,EAAE,0DAA0D;IAClE,6EAA6E;IAC7E,4EAA4E;IAC5E,8EAA8E;IAC9E,6EAA6E;IAC7E,2EAA2E;IAC3E,wEAAwE;IACxE,4EAA4E;IAC5E,6EAA6E;IAC7E,2EAA2E;IAC3E,iEAAiE;IACjE,6GAA6G;IAC7G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,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC5C,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG;YAC/B,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC;SACrB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAA2B,EAAE,CAAC;IACrD,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACvC,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 { ApolloLink } from \"@apollo/client/link\";\nimport { print } from \"@apollo/client/utilities\";\n\nimport type { HttpLink } from \"./HttpLink.js\";\n\ninterface HttpConfig {\n http?: HttpLink.HttpOptions;\n options?: any;\n headers?: Record<string, string>;\n credentials?: any;\n}\n\nconst defaultHttpOptions: HttpLink.HttpOptions = {\n includeQuery: true,\n includeExtensions: true,\n preserveHeaderCase: false,\n};\n\nconst defaultHeaders = {\n // headers are case insensitive (https://stackoverflow.com/a/5259004)\n accept: \"application/graphql-response+json,application/json;q=0.9\",\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: HttpLink.Printer = (ast, printer) => printer(ast);\n\nexport function selectHttpOptionsAndBody(\n operation: ApolloLink.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: ApolloLink.Operation,\n printer: HttpLink.Printer,\n ...configs: HttpConfig[]\n) {\n let options = {} as HttpConfig & Record<string, any>;\n let http = {} as HttpLink.HttpOptions;\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 options.headers!.accept = (config.http?.accept || [])\n .concat(options.headers!.accept)\n .join(\",\");\n\n http = {\n ...http,\n ...config.http,\n };\n });\n\n options.headers = removeDuplicateHeaders(\n options.headers!,\n http.preserveHeaderCase\n );\n\n //The body depends on the http options\n const { operationName, extensions, variables, query } = operation;\n const body: HttpLink.Body = { operationName, variables };\n\n if (http.includeExtensions && Object.keys(extensions || {}).length)\n (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: Record<string, string> = {};\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: Record<string, { originalName: string; value: string }> =\n {};\n Object.keys(Object(headers)).forEach((name) => {\n headerData[name.toLowerCase()] = {\n originalName: name,\n value: headers[name],\n };\n });\n\n const normalizedHeaders: Record<string, string> = {};\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;AAWjD,MAAM,kBAAkB,GAA6B;IACnD,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,IAAI;IACvB,kBAAkB,EAAE,KAAK;CAC1B,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,qEAAqE;IACrE,MAAM,EAAE,0DAA0D;IAClE,6EAA6E;IAC7E,4EAA4E;IAC5E,8EAA8E;IAC9E,6EAA6E;IAC7E,2EAA2E;IAC3E,wEAAwE;IACxE,4EAA4E;IAC5E,6EAA6E;IAC7E,2EAA2E;IAC3E,iEAAiE;IACjE,6GAA6G;IAC7G,oBAAoB;IACpB,cAAc,EAAE,kBAAkB;CACnC,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,MAAM,EAAE,MAAM;CACf,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,cAAc;CACxB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAyB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CACnE,OAAO,CAAC,GAAG,CAAC,CAAC;AAEf,MAAM,UAAU,wBAAwB,CACtC,SAA+B,EAC/B,cAA0B,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AAY,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;IAC5E,CAAC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import type { ApolloLink } from \"@apollo/client/link\";\nimport { print } from \"@apollo/client/utilities\";\n\nimport type { BaseHttpLink } from \"./BaseHttpLink.js\";\n\ninterface HttpConfig {\n http?: BaseHttpLink.HttpOptions;\n options?: any;\n headers?: Record<string, string>;\n credentials?: any;\n}\n\nconst defaultHttpOptions: BaseHttpLink.HttpOptions = {\n includeQuery: true,\n includeExtensions: true,\n preserveHeaderCase: false,\n};\n\nconst defaultHeaders = {\n // headers are case insensitive (https://stackoverflow.com/a/5259004)\n accept: \"application/graphql-response+json,application/json;q=0.9\",\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: BaseHttpLink.Printer = (ast, printer) =>\n printer(ast);\n\nexport function selectHttpOptionsAndBody(\n operation: ApolloLink.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: ApolloLink.Operation,\n printer: BaseHttpLink.Printer,\n ...configs: HttpConfig[]\n) {\n let options = {} as HttpConfig & Record<string, any>;\n let http = {} as BaseHttpLink.HttpOptions;\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 options.headers!.accept = (config.http?.accept || [])\n .concat(options.headers!.accept)\n .join(\",\");\n\n http = {\n ...http,\n ...config.http,\n };\n });\n\n options.headers = removeDuplicateHeaders(\n options.headers!,\n http.preserveHeaderCase\n );\n\n //The body depends on the http options\n const { operationName, extensions, variables, query } = operation;\n const body: BaseHttpLink.Body = { operationName, variables };\n\n if (http.includeExtensions && Object.keys(extensions || {}).length)\n (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: Record<string, string> = {};\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: Record<string, { originalName: string; value: string }> =\n {};\n Object.keys(Object(headers)).forEach((name) => {\n headerData[name.toLowerCase()] = {\n originalName: name,\n value: headers[name],\n };\n });\n\n const normalizedHeaders: Record<string, string> = {};\n Object.keys(headerData).forEach((name) => {\n normalizedHeaders[headerData[name].originalName] = headerData[name].value;\n });\n return normalizedHeaders;\n}\n"]}
package/link/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
+ export type { DocumentNode } from "graphql";
1
2
  export { empty } from "./core/empty.js";
2
3
  export { from } from "./core/from.js";
3
4
  export { split } from "./core/split.js";
4
5
  export { concat } from "./core/concat.js";
5
6
  export { execute } from "./core/execute.js";
6
7
  export { ApolloLink } from "./core/ApolloLink.js";
7
- export type { AdditionalApolloLinkResultTypes, ApolloPayloadResult, DocumentNode, } from "./core/types.js";
8
+ export type { ApolloPayloadResult } from "./core/types.js";
8
9
  export type { FetchResult, GraphQLRequest, Operation, RequestHandler, } from "./core/deprecated.js";
9
10
  //# sourceMappingURL=index.d.ts.map
package/link/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/link/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { empty } from \"./core/empty.js\";\nexport { from } from \"./core/from.js\";\nexport { split } from \"./core/split.js\";\nexport { concat } from \"./core/concat.js\";\nexport { execute } from \"./core/execute.js\";\nexport { ApolloLink } from \"./core/ApolloLink.js\";\n\nexport type {\n AdditionalApolloLinkResultTypes,\n ApolloPayloadResult,\n DocumentNode,\n} from \"./core/types.js\";\n\nexport type {\n FetchResult,\n GraphQLRequest,\n Operation,\n RequestHandler,\n} from \"./core/deprecated.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/link/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export type { DocumentNode } from \"graphql\";\n\nexport { empty } from \"./core/empty.js\";\nexport { from } from \"./core/from.js\";\nexport { split } from \"./core/split.js\";\nexport { concat } from \"./core/concat.js\";\nexport { execute } from \"./core/execute.js\";\nexport { ApolloLink } from \"./core/ApolloLink.js\";\n\nexport type { ApolloPayloadResult } from \"./core/types.js\";\n\nexport type {\n FetchResult,\n GraphQLRequest,\n Operation,\n RequestHandler,\n} from \"./core/deprecated.js\";\n"]}
@@ -3,34 +3,199 @@ import type { ErrorLike } from "@apollo/client";
3
3
  import { ApolloLink } from "@apollo/client/link";
4
4
  export declare const VERSION = 1;
5
5
  export declare namespace PersistedQueryLink {
6
+ namespace PersistedQueryLinkDocumentationTypes {
7
+ /**
8
+ * A SHA-256 hash function for hashing query strings.
9
+ *
10
+ * @param queryString - The query string to hash
11
+ * @returns The SHA-256 hash or a promise that resolves to the SHA-256 hash
12
+ *
13
+ * @example
14
+ *
15
+ * ```ts
16
+ * import { sha256 } from "crypto-hash";
17
+ *
18
+ * const link = new PersistedQueryLink({ sha256 });
19
+ * ```
20
+ */
21
+ function SHA256Function(queryString: string): string | PromiseLike<string>;
22
+ /**
23
+ * A function that generates a hash for a GraphQL document.
24
+ *
25
+ * @param document - The GraphQL document to hash
26
+ * @returns The hash string or a promise that resolves to the hash string
27
+ *
28
+ * @example
29
+ *
30
+ * ```ts
31
+ * import { print } from "graphql";
32
+ * import { sha256 } from "crypto-hash";
33
+ *
34
+ * const link = new PersistedQueryLink({
35
+ * generateHash: async (document) => {
36
+ * const query = print(document);
37
+ * return sha256(query);
38
+ * },
39
+ * });
40
+ * ```
41
+ */
42
+ function GenerateHashFunction(document: DocumentNode): string | PromiseLike<string>;
43
+ }
6
44
  namespace Base {
45
+ /**
46
+ * Base options shared between SHA256 and custom hash configurations.
47
+ */
7
48
  interface Options {
49
+ /**
50
+ * A function to disable persisted queries for the current session.
51
+ *
52
+ * This function is called when an error occurs and determines whether
53
+ * to disable persisted queries for all future requests in this session.
54
+ *
55
+ * @defaultValue Disables on `PersistedQueryNotSupported` errors
56
+ */
8
57
  disable?: (options: PersistedQueryLink.DisableFunctionOptions) => boolean;
58
+ /**
59
+ * A function to determine whether to retry a request with the full query.
60
+ *
61
+ * When a persisted query fails, this function determines whether to
62
+ * retry the request with the full query text included.
63
+ *
64
+ * @defaultValue Retries on `PersistedQueryNotSupported` or `PersistedQueryNotFound` errors
65
+ */
9
66
  retry?: (options: PersistedQueryLink.RetryFunctionOptions) => boolean;
67
+ /**
68
+ * Whether to use HTTP GET for hashed queries (excluding mutations).
69
+ *
70
+ * > [!NOTE]
71
+ * > If you want to use `GET` for non-mutation queries whether or not they
72
+ * > are hashed, pass `useGETForQueries: true` option to `HttpLink`
73
+ * > instead. If you want to use GET for all requests, pass `fetchOptions: {method: 'GET'}`
74
+ * > to `HttpLink`.
75
+ *
76
+ * @defaultValue `false`
77
+ */
10
78
  useGETForHashedQueries?: boolean;
11
79
  }
12
80
  }
81
+ /**
82
+ * Metadata about persisted query errors extracted from the response.
83
+ */
13
84
  interface ErrorMeta {
85
+ /**
86
+ * Whether the server responded with a "PersistedQueryNotSupported" error.
87
+ *
88
+ * When `true`, indicates the server doesn't support persisted queries
89
+ * or has disabled them for this client.
90
+ */
14
91
  persistedQueryNotSupported: boolean;
92
+ /**
93
+ * Whether the server responded with a "PersistedQueryNotFound" error.
94
+ *
95
+ * When `true`, indicates the server doesn't recognize the query hash
96
+ * and needs the full query text.
97
+ */
15
98
  persistedQueryNotFound: boolean;
16
99
  }
100
+ /**
101
+ * A function that generates a hash for a GraphQL document.
102
+ *
103
+ * @param document - The GraphQL document to hash
104
+ * @returns The hash string or a promise that resolves to the hash string
105
+ *
106
+ * @example
107
+ *
108
+ * ```ts
109
+ * import { print } from "graphql";
110
+ * import { sha256 } from "crypto-hash";
111
+ *
112
+ * const link = new PersistedQueryLink({
113
+ * generateHash: async (document) => {
114
+ * const query = print(document);
115
+ * return sha256(query);
116
+ * },
117
+ * });
118
+ * ```
119
+ */
17
120
  type GenerateHashFunction = (document: DocumentNode) => string | PromiseLike<string>;
121
+ /**
122
+ * A SHA-256 hash function for hashing query strings.
123
+ *
124
+ * @param queryString - The query string to hash
125
+ * @returns The SHA-256 hash or a promise that resolves to the SHA-256 hash
126
+ *
127
+ * @example
128
+ *
129
+ * ```ts
130
+ * import { sha256 } from "crypto-hash";
131
+ *
132
+ * const link = new PersistedQueryLink({ sha256 });
133
+ * ```
134
+ */
18
135
  type SHA256Function = (queryString: string) => string | PromiseLike<string>;
136
+ /**
137
+ * Options for using SHA-256 hashing with persisted queries.
138
+ *
139
+ * Use this configuration when you want the link to handle query
140
+ * printing and hashing using a SHA-256 function.
141
+ */
19
142
  interface SHA256Options extends Base.Options {
143
+ /**
144
+ * The SHA-256 hash function to use for hashing queries. This function
145
+ * receives the printed query string and should return a SHA-256 hash. Can
146
+ * be synchronous or asynchronous.
147
+ */
20
148
  sha256: PersistedQueryLink.SHA256Function;
21
149
  generateHash?: never;
22
150
  }
151
+ /**
152
+ * Options for using custom hash generation with persisted queries.
153
+ *
154
+ * Use this configuration when you need custom control over how
155
+ * query hashes are generated (e.g., using pre-computed hashes).
156
+ */
23
157
  interface GenerateHashOptions extends Base.Options {
24
158
  sha256?: never;
159
+ /**
160
+ * A custom function for generating query hashes. This function receives
161
+ * the GraphQL document and should return a hash. Useful for custom hashing
162
+ * strategies or when using build-time generated hashes.
163
+ */
25
164
  generateHash: PersistedQueryLink.GenerateHashFunction;
26
165
  }
166
+ /**
167
+ * Configuration options for creating a `PersistedQueryLink`.
168
+ *
169
+ * You must provide either a `sha256` function or a custom `generateHash`
170
+ * function, but not both.
171
+ */
27
172
  type Options = PersistedQueryLink.SHA256Options | PersistedQueryLink.GenerateHashOptions;
173
+ /**
174
+ * Options passed to the `retry` function when a persisted query request
175
+ * fails.
176
+ */
28
177
  interface RetryFunctionOptions {
178
+ /**
179
+ * The error that occurred during the request.
180
+ */
29
181
  error: ErrorLike;
182
+ /**
183
+ * The GraphQL operation that failed.
184
+ */
30
185
  operation: ApolloLink.Operation;
186
+ /**
187
+ * Metadata about the persisted query error.
188
+ */
31
189
  meta: PersistedQueryLink.ErrorMeta;
190
+ /**
191
+ * The GraphQL result, if available.
192
+ */
32
193
  result?: FormattedExecutionResult;
33
194
  }
195
+ /**
196
+ * Options passed to the `disable` function when a persisted query request
197
+ * fails.
198
+ */
34
199
  interface DisableFunctionOptions extends PersistedQueryLink.RetryFunctionOptions {
35
200
  }
36
201
  }
@@ -39,8 +204,24 @@ export declare namespace PersistedQueryLink {
39
204
  * Use `PersistedQueryLink` from `@apollo/client/link/persisted-queries` instead.
40
205
  */
41
206
  export declare const createPersistedQueryLink: (options: PersistedQueryLink.Options) => PersistedQueryLink;
207
+ /**
208
+ * `PersistedQueryLink` is a non-terminating link that enables the use of
209
+ * persisted queries, a technique that reduces bandwidth by sending query hashes
210
+ * instead of full query strings.
211
+ *
212
+ * @example
213
+ *
214
+ * ```ts
215
+ * import { PersistedQueryLink } from "@apollo/client/link/persisted-queries";
216
+ * import { sha256 } from "crypto-hash";
217
+ *
218
+ * const link = new PersistedQueryLink({
219
+ * sha256: (queryString) => sha256(queryString),
220
+ * });
221
+ * ```
222
+ */
42
223
  export declare class PersistedQueryLink extends ApolloLink {
43
224
  constructor(options: PersistedQueryLink.Options);
44
225
  resetHashCache: () => void;
45
226
  }
46
- //# sourceMappingURL=index.d.ts.map
227
+ //# sourceMappingURL=index.d.ts.map
@@ -35,6 +35,22 @@ function operationDefinesMutation(operation) {
35
35
  * Use `PersistedQueryLink` from `@apollo/client/link/persisted-queries` instead.
36
36
  */
37
37
  export const createPersistedQueryLink = (options) => new PersistedQueryLink(options);
38
+ /**
39
+ * `PersistedQueryLink` is a non-terminating link that enables the use of
40
+ * persisted queries, a technique that reduces bandwidth by sending query hashes
41
+ * instead of full query strings.
42
+ *
43
+ * @example
44
+ *
45
+ * ```ts
46
+ * import { PersistedQueryLink } from "@apollo/client/link/persisted-queries";
47
+ * import { sha256 } from "crypto-hash";
48
+ *
49
+ * const link = new PersistedQueryLink({
50
+ * sha256: (queryString) => sha256(queryString),
51
+ * });
52
+ * ```
53
+ */
38
54
  export class PersistedQueryLink extends ApolloLink {
39
55
  constructor(options) {
40
56
  let hashesByQuery;