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

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 (114) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/__cjs/cache/inmemory/writeToStore.cjs +1 -1
  3. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  4. package/__cjs/core/ObservableQuery.cjs +1 -1
  5. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  6. package/__cjs/core/QueryInfo.cjs +2 -6
  7. package/__cjs/core/QueryInfo.cjs.map +1 -1
  8. package/__cjs/link/batch/batchLink.cjs +30 -2
  9. package/__cjs/link/batch/batchLink.cjs.map +1 -1
  10. package/__cjs/link/batch/batchLink.d.cts +69 -2
  11. package/__cjs/link/batch-http/BaseBatchHttpLink.cjs +156 -0
  12. package/__cjs/link/batch-http/BaseBatchHttpLink.cjs.map +1 -0
  13. package/__cjs/link/batch-http/BaseBatchHttpLink.d.cts +68 -0
  14. package/__cjs/link/batch-http/batchHttpLink.cjs +3 -128
  15. package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
  16. package/__cjs/link/batch-http/batchHttpLink.d.cts +4 -20
  17. package/__cjs/link/batch-http/index.cjs +2 -1
  18. package/__cjs/link/batch-http/index.cjs.map +1 -1
  19. package/__cjs/link/batch-http/index.d.cts +2 -1
  20. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +3 -3
  21. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
  22. package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +20 -1
  23. package/__cjs/link/context/index.cjs +19 -0
  24. package/__cjs/link/context/index.cjs.map +1 -1
  25. package/__cjs/link/context/index.d.cts +64 -2
  26. package/__cjs/link/http/BaseHttpLink.cjs +59 -8
  27. package/__cjs/link/http/BaseHttpLink.cjs.map +1 -1
  28. package/__cjs/link/http/BaseHttpLink.d.cts +256 -2
  29. package/__cjs/link/http/HttpLink.cjs +1 -1
  30. package/__cjs/link/http/HttpLink.cjs.map +1 -1
  31. package/__cjs/link/http/HttpLink.d.cts +5 -208
  32. package/__cjs/link/http/rewriteURIForGET.cjs.map +1 -1
  33. package/__cjs/link/http/rewriteURIForGET.d.cts +2 -2
  34. package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
  35. package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +7 -7
  36. package/__cjs/link/persisted-queries/index.cjs +16 -0
  37. package/__cjs/link/persisted-queries/index.cjs.map +1 -1
  38. package/__cjs/link/persisted-queries/index.d.cts +181 -0
  39. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +48 -0
  40. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
  41. package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +115 -0
  42. package/__cjs/link/retry/retryLink.cjs +25 -3
  43. package/__cjs/link/retry/retryLink.cjs.map +1 -1
  44. package/__cjs/link/retry/retryLink.d.cts +82 -9
  45. package/__cjs/link/schema/index.cjs +20 -0
  46. package/__cjs/link/schema/index.cjs.map +1 -1
  47. package/__cjs/link/schema/index.d.cts +128 -6
  48. package/__cjs/link/ws/index.cjs +18 -0
  49. package/__cjs/link/ws/index.cjs.map +1 -1
  50. package/__cjs/link/ws/index.d.cts +56 -5
  51. package/__cjs/react/hooks/useSyncExternalStore.cjs +2 -6
  52. package/__cjs/react/hooks/useSyncExternalStore.cjs.map +1 -1
  53. package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +2 -6
  54. package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs.map +1 -1
  55. package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
  56. package/__cjs/version.cjs +1 -1
  57. package/cache/inmemory/writeToStore.js +1 -1
  58. package/cache/inmemory/writeToStore.js.map +1 -1
  59. package/core/ObservableQuery.js +1 -1
  60. package/core/ObservableQuery.js.map +1 -1
  61. package/core/QueryInfo.js +1 -2
  62. package/core/QueryInfo.js.map +1 -1
  63. package/link/batch/batchLink.d.ts +69 -2
  64. package/link/batch/batchLink.js +30 -2
  65. package/link/batch/batchLink.js.map +1 -1
  66. package/link/batch-http/BaseBatchHttpLink.d.ts +68 -0
  67. package/link/batch-http/BaseBatchHttpLink.js +152 -0
  68. package/link/batch-http/BaseBatchHttpLink.js.map +1 -0
  69. package/link/batch-http/batchHttpLink.d.ts +5 -21
  70. package/link/batch-http/batchHttpLink.js +1 -125
  71. package/link/batch-http/batchHttpLink.js.map +1 -1
  72. package/link/batch-http/index.d.ts +2 -1
  73. package/link/batch-http/index.js +2 -1
  74. package/link/batch-http/index.js.map +1 -1
  75. package/link/client-awareness/ClientAwarenessLink.d.ts +21 -2
  76. package/link/client-awareness/ClientAwarenessLink.js +3 -3
  77. package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
  78. package/link/context/index.d.ts +65 -3
  79. package/link/context/index.js +19 -0
  80. package/link/context/index.js.map +1 -1
  81. package/link/http/BaseHttpLink.d.ts +257 -3
  82. package/link/http/BaseHttpLink.js +59 -8
  83. package/link/http/BaseHttpLink.js.map +1 -1
  84. package/link/http/HttpLink.d.ts +6 -209
  85. package/link/http/HttpLink.js +1 -1
  86. package/link/http/HttpLink.js.map +1 -1
  87. package/link/http/rewriteURIForGET.d.ts +2 -2
  88. package/link/http/rewriteURIForGET.js.map +1 -1
  89. package/link/http/selectHttpOptionsAndBody.d.ts +7 -7
  90. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  91. package/link/persisted-queries/index.d.ts +182 -1
  92. package/link/persisted-queries/index.js +16 -0
  93. package/link/persisted-queries/index.js.map +1 -1
  94. package/link/remove-typename/removeTypenameFromVariables.d.ts +115 -0
  95. package/link/remove-typename/removeTypenameFromVariables.js +48 -0
  96. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  97. package/link/retry/retryLink.d.ts +83 -10
  98. package/link/retry/retryLink.js +25 -3
  99. package/link/retry/retryLink.js.map +1 -1
  100. package/link/schema/index.d.ts +129 -7
  101. package/link/schema/index.js +20 -0
  102. package/link/schema/index.js.map +1 -1
  103. package/link/ws/index.d.ts +56 -5
  104. package/link/ws/index.js +18 -0
  105. package/link/ws/index.js.map +1 -1
  106. package/package.json +1 -1
  107. package/react/hooks/useSyncExternalStore.js +1 -1
  108. package/react/hooks/useSyncExternalStore.js.map +1 -1
  109. package/react/hooks-compiled/useSyncExternalStore.js +1 -1
  110. package/react/hooks-compiled/useSyncExternalStore.js.map +1 -1
  111. package/utilities/internal/removeDirectivesFromDocument.js +1 -2
  112. package/utilities/internal/removeDirectivesFromDocument.js.map +1 -1
  113. package/utilities/subscriptions/relay/index.js.map +1 -1
  114. package/version.js +1 -1
@@ -1,6 +1,260 @@
1
+ import type { ASTNode, print } from "graphql";
1
2
  import { ApolloLink } from "@apollo/client/link";
2
- import type { HttpLink } from "./HttpLink.cjs";
3
+ export declare namespace BaseHttpLink {
4
+ /**
5
+ * Options passed to `BaseHttpLink` through [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context). Previous
6
+ * non-terminating links in the link chain also can set these values to
7
+ * customize the behavior of `BaseHttpLink` for each operation.
8
+ *
9
+ * > [!NOTE]
10
+ * > Some of these values can also be provided to the `HttpLink` constructor.
11
+ * > If a value is provided to both, the value in `context` takes precedence.
12
+ */
13
+ interface ContextOptions {
14
+ /**
15
+ * The URL of the GraphQL endpoint to send requests to. Can also be a
16
+ * function that accepts an `ApolloLink.Operation` object and returns the
17
+ * string URL to use for that operation.
18
+ *
19
+ * @defaultValue "/graphql"
20
+ */
21
+ uri?: string | BaseHttpLink.UriFunction;
22
+ /**
23
+ * An object representing headers to include in every HTTP request.
24
+ *
25
+ * @example
26
+ *
27
+ * ```json
28
+ * {
29
+ * "Authorization": "Bearer 1234"
30
+ * }
31
+ * ```
32
+ */
33
+ headers?: Record<string, string>;
34
+ /**
35
+ * The credentials policy to use for each `fetch` call.
36
+ */
37
+ credentials?: RequestCredentials;
38
+ /**
39
+ * Any overrides of the fetch options argument to pass to the fetch call.
40
+ *
41
+ * An object containing options to use for each call to `fetch`. If a
42
+ * particular option is not included in this object, the default value of
43
+ * that option is used.
44
+ *
45
+ * > [!NOTE]
46
+ * > If you set `fetchOptions.method` to `GET`, `HttpLink` follows [standard
47
+ * > GraphQL HTTP GET encoding](http://graphql.org/learn/serving-over-http/#get-request).
48
+ *
49
+ * See [available options](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
50
+ */
51
+ fetchOptions?: RequestInit;
52
+ /**
53
+ * An object that configures advanced functionality, such as support for
54
+ * persisted queries.
55
+ */
56
+ http?: BaseHttpLink.HttpOptions;
57
+ }
58
+ /**
59
+ * Options passed to `BaseHttpLink` through the `http` property of a request
60
+ * context.
61
+ */
62
+ interface HttpOptions {
63
+ /**
64
+ * If `true`, includes the `extensions` field in operations sent to your
65
+ * GraphQL endpoint.
66
+ *
67
+ * @defaultValue true
68
+ */
69
+ includeExtensions?: boolean;
70
+ /**
71
+ * If `false`, the GraphQL query string is not included in the request. Set
72
+ * this option if you're sending a request that uses a [persisted query](https://www.apollographql.com/docs/react/api/link/persisted-queries/).
73
+ *
74
+ * @defaultValue `true`
75
+ */
76
+ includeQuery?: boolean;
77
+ /**
78
+ * If `true`, header names won't be automatically normalized to lowercase.
79
+ * This allows for non-http-spec-compliant servers that might expect
80
+ * capitalized header names.
81
+ *
82
+ * @defaultValue false
83
+ */
84
+ preserveHeaderCase?: boolean;
85
+ /**
86
+ * A list of additional `accept` headers to include in the request,
87
+ * as defined in https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.2
88
+ *
89
+ * @example
90
+ *
91
+ * ```json
92
+ * ["application/custom+json;q=1.0"]
93
+ * ```
94
+ */
95
+ accept?: string[];
96
+ }
97
+ namespace Shared {
98
+ /** These options are shared between `BaseHttpLink` and `BaseBatchHttpLink` */
99
+ interface Options {
100
+ /**
101
+ * The URL of the GraphQL endpoint to send requests to. Can also be a
102
+ * function that accepts an `ApolloLink.Operation` object and returns the
103
+ * string URL to use for that operation.
104
+ *
105
+ * @defaultValue "/graphql"
106
+ */
107
+ uri?: string | BaseHttpLink.UriFunction;
108
+ /**
109
+ * If `true`, includes the `extensions` field in operations sent to your
110
+ * GraphQL endpoint.
111
+ *
112
+ * @defaultValue true
113
+ */
114
+ includeExtensions?: boolean;
115
+ /**
116
+ * A function to use instead of calling the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) directly
117
+ * when sending HTTP requests to your GraphQL endpoint. The function must
118
+ * conform to the signature of `fetch`.
119
+ *
120
+ * By default, the Fetch API is used unless it isn't available in your
121
+ * runtime environment.
122
+ *
123
+ * See [Customizing `fetch`](https://apollographql.com/docs/react/api/link/introduction#customizing-fetch).
124
+ */
125
+ fetch?: typeof fetch;
126
+ /**
127
+ * An object representing headers to include in every HTTP request.
128
+ *
129
+ * @example
130
+ *
131
+ * ```json
132
+ * {
133
+ * "Authorization": "Bearer 1234"
134
+ * }
135
+ * ```
136
+ */
137
+ headers?: Record<string, string>;
138
+ /**
139
+ * If `true`, header names won't be automatically normalized to lowercase.
140
+ * This allows for non-http-spec-compliant servers that might expect
141
+ * capitalized header names.
142
+ *
143
+ * @defaultValue false
144
+ */
145
+ preserveHeaderCase?: boolean;
146
+ /**
147
+ * The credentials policy to use for each `fetch` call.
148
+ */
149
+ credentials?: RequestCredentials;
150
+ /**
151
+ * Any overrides of the fetch options argument to pass to the fetch call.
152
+ *
153
+ * An object containing options to use for each call to `fetch`. If a
154
+ * particular option is not included in this object, the default value of
155
+ * that option is used.
156
+ *
157
+ * > [!NOTE]
158
+ * > If you set `fetchOptions.method` to `GET`, `HttpLink` follows [standard
159
+ * > GraphQL HTTP GET encoding](http://graphql.org/learn/serving-over-http/#get-request).
160
+ *
161
+ * See [available options](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
162
+ */
163
+ fetchOptions?: RequestInit;
164
+ /**
165
+ * If `true`, unused variables from the operation will not be stripped from
166
+ * the request and will instead be sent to the GraphQL endpoint.
167
+ *
168
+ * @remarks
169
+ * Unused variables are likely to trigger server-side validation errors,
170
+ * per https://spec.graphql.org/draft/#sec-All-Variables-Used.
171
+ * `includeUnusedVariables` can be useful if your server deviates
172
+ * from the GraphQL specification by not strictly enforcing that rule.
173
+ *
174
+ * @defaultValue false
175
+ */
176
+ includeUnusedVariables?: boolean;
177
+ /**
178
+ * A function to use when transforming a GraphQL document into a string. It
179
+ * accepts an `ASTNode` (typically a `DocumentNode`) and the original `print`
180
+ * function as arguments, and is expected to return a string. This option
181
+ * enables you to, for example, use `stripIgnoredCharacters` to remove
182
+ * whitespace from queries.
183
+ *
184
+ * By default the [GraphQL `print` function](https://graphql.org/graphql-js/language/#print) is used.
185
+ *
186
+ * @example
187
+ *
188
+ * ```ts
189
+ * import { stripIgnoredCharacters } from "graphql";
190
+ *
191
+ * const httpLink = new HttpLink({
192
+ * uri: "/graphql",
193
+ * print: (ast, originalPrint) => stripIgnoredCharacters(originalPrint(ast)),
194
+ * });
195
+ * ```
196
+ */
197
+ print?: BaseHttpLink.Printer;
198
+ }
199
+ }
200
+ /**
201
+ * Options provided to the `BaseHttpLink` constructor.
202
+ *
203
+ * > [!NOTE]
204
+ * > Some of these options are also available to override in [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context).
205
+ * > Context options override the options passed to the constructor. Treat
206
+ * > these options as default values that are used when the request context
207
+ * > does not override the value.
208
+ */
209
+ interface Options extends Shared.Options {
210
+ /**
211
+ * If `true`, the link uses an HTTP `GET` request when sending query
212
+ * operations to your GraphQL endpoint. Mutation operations continue to use
213
+ * `POST` requests. If you want all operations to use `GET` requests,
214
+ * set `fetchOptions.method` instead.
215
+ *
216
+ * @defaultValue false
217
+ */
218
+ useGETForQueries?: boolean;
219
+ }
220
+ interface Body {
221
+ query?: string;
222
+ operationName?: string;
223
+ variables?: Record<string, any>;
224
+ extensions?: Record<string, any>;
225
+ }
226
+ type Printer = (node: ASTNode, originalPrint: typeof print) => string;
227
+ type UriFunction = (operation: ApolloLink.Operation) => string;
228
+ }
229
+ /**
230
+ * `BaseHttpLink` is a terminating link that sends a GraphQL operation to a
231
+ * remote endpoint over HTTP. It serves as a base link to `HttpLink`.
232
+ *
233
+ * @remarks
234
+ *
235
+ * `BaseHttpLink` supports both POST and GET requests, and you can configure
236
+ * HTTP options on a per-operation basis. You can use these options for
237
+ * authentication, persisted queries, dynamic URIs, and other granular updates.
238
+ *
239
+ * > [!NOTE]
240
+ * > Prefer using `HttpLink` over `BaseHttpLink`. Use `BaseHttpLink` when you
241
+ * > need to disable client awareness features and would like to tree-shake
242
+ * > the implementation of `ClientAwarenessLink` out of your app bundle.
243
+ *
244
+ * @example
245
+ *
246
+ * ```ts
247
+ * import { BaseHttpLink } from "@apollo/client/link/http";
248
+ *
249
+ * const link = new BaseHttpLink({
250
+ * uri: "http://localhost:4000/graphql",
251
+ * headers: {
252
+ * authorization: `Bearer ${token}`,
253
+ * },
254
+ * });
255
+ * ```
256
+ */
3
257
  export declare class BaseHttpLink extends ApolloLink {
4
- constructor(linkOptions?: HttpLink.Options);
258
+ constructor(options?: BaseHttpLink.Options);
5
259
  }
6
260
  //# sourceMappingURL=BaseHttpLink.d.cts.map
@@ -41,6 +41,6 @@ exports.HttpLink = HttpLink;
41
41
  * @deprecated
42
42
  * Use `HttpLink` from `@apollo/client/link/http` instead.
43
43
  */
44
- const createHttpLink = (linkOptions = {}) => new HttpLink(linkOptions);
44
+ const createHttpLink = (options = {}) => new HttpLink(options);
45
45
  exports.createHttpLink = createHttpLink;
46
46
  //# sourceMappingURL=HttpLink.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"HttpLink.cjs","sources":["../../../../src/link/http/HttpLink.ts"],"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"],"names":[],"mappings":";;;AAEA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAGA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,qBAAA,CAAA;AA+MA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;CAqBA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esContent":["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"],"names":[],"mappings":";;;AAAA,CAAA,CAAA,CAAA,CA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CAAA,CAAA,CAAA,EAAA,CAAuC,CAAC;IACtC;AACF;AATA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAWA,CAAA,CAAA;;;CAGA,CAAA;AACO,CAAP,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAA8B,CAAC,CAA/B,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAA2D,CAA3D,CAA6D,EAAE,CAA/D,EACE,CADF,CAAA,EACM,CADN,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACc,CAAC,CADf,CAAA,CAAA,CAAA,CAAA,CAAA,CACsB,CAAC;AADV,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;"}
@@ -1,7 +1,6 @@
1
- import type { ASTNode } from "graphql";
2
1
  import { ApolloLink } from "@apollo/client/link";
3
2
  import { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
4
- import type { print } from "@apollo/client/utilities";
3
+ import { BaseHttpLink } from "./BaseHttpLink.cjs";
5
4
  export declare namespace HttpLink {
6
5
  /**
7
6
  * Options passed to `HttpLink` through [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context). Previous
@@ -12,192 +11,7 @@ export declare namespace HttpLink {
12
11
  * > Some of these values can also be provided to the `HttpLink` constructor.
13
12
  * > If a value is provided to both, the value in `context` takes precedence.
14
13
  */
15
- interface ContextOptions {
16
- /**
17
- * The URL of the GraphQL endpoint to send requests to. Can also be a
18
- * function that accepts an `ApolloLink.Operation` object and returns the
19
- * string URL to use for that operation.
20
- *
21
- * @defaultValue "/graphql"
22
- */
23
- uri?: string | HttpLink.UriFunction;
24
- /**
25
- * An object representing headers to include in every HTTP request.
26
- *
27
- * @example
28
- *
29
- * ```json
30
- * {
31
- * "Authorization": "Bearer 1234"
32
- * }
33
- * ```
34
- */
35
- headers?: Record<string, string>;
36
- /**
37
- * The credentials policy to use for each `fetch` call.
38
- */
39
- credentials?: RequestCredentials;
40
- /**
41
- * Any overrides of the fetch options argument to pass to the fetch call.
42
- *
43
- * An object containing options to use for each call to `fetch`. If a
44
- * particular option is not included in this object, the default value of
45
- * that option is used.
46
- *
47
- * > [!NOTE]
48
- * > If you set `fetchOptions.method` to `GET`, `HttpLink` follows [standard
49
- * > GraphQL HTTP GET encoding](http://graphql.org/learn/serving-over-http/#get-request).
50
- *
51
- * See [available options](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
52
- */
53
- fetchOptions?: RequestInit;
54
- /**
55
- * An object that configures advanced `HttpLink` functionality, such as
56
- * support for persisted queries.
57
- */
58
- http?: HttpLink.HttpOptions;
59
- }
60
- /**
61
- * Options passed to `HttpLink` through the `http` property of a request
62
- * context.
63
- */
64
- interface HttpOptions {
65
- /**
66
- * If `true`, includes the `extensions` field in operations sent to your
67
- * GraphQL endpoint.
68
- *
69
- * @defaultValue true
70
- */
71
- includeExtensions?: boolean;
72
- /**
73
- * If `false`, the GraphQL query string is not included in the request. Set
74
- * this option if you're sending a request that uses a [persisted query](https://www.apollographql.com/docs/react/api/link/persisted-queries/).
75
- *
76
- * @defaultValue true
77
- */
78
- includeQuery?: boolean;
79
- /**
80
- * If `true`, header names won't be automatically normalized to lowercase.
81
- * This allows for non-http-spec-compliant servers that might expect
82
- * capitalized header names.
83
- *
84
- * @defaultValue false
85
- */
86
- preserveHeaderCase?: boolean;
87
- /**
88
- * A list of additional `accept` headers to include in the request,
89
- * as defined in https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.2
90
- *
91
- * @example
92
- *
93
- * ```json
94
- * ["application/custom+json;q=1.0"]
95
- * ```
96
- */
97
- accept?: string[];
98
- }
99
- namespace Shared {
100
- /** These options are shared between `HttpLink` and `BatchHttpLink` */
101
- interface Options {
102
- /**
103
- * The URL of the GraphQL endpoint to send requests to. Can also be a
104
- * function that accepts an `ApolloLink.Operation` object and returns the
105
- * string URL to use for that operation.
106
- *
107
- * @defaultValue "/graphql"
108
- */
109
- uri?: string | HttpLink.UriFunction;
110
- /**
111
- * If `true`, includes the `extensions` field in operations sent to your
112
- * GraphQL endpoint.
113
- *
114
- * @defaultValue true
115
- */
116
- includeExtensions?: boolean;
117
- /**
118
- * A function to use instead of calling the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) directly
119
- * when sending HTTP requests to your GraphQL endpoint. The function must
120
- * conform to the signature of `fetch`.
121
- *
122
- * By default, the Fetch API is used unless it isn't available in your
123
- * runtime environment.
124
- *
125
- * See [Customizing `fetch`](https://apollographql.com/docs/react/api/link/introduction#customizing-fetch).
126
- */
127
- fetch?: typeof fetch;
128
- /**
129
- * An object representing headers to include in every HTTP request.
130
- *
131
- * @example
132
- *
133
- * ```json
134
- * {
135
- * "Authorization": "Bearer 1234"
136
- * }
137
- * ```
138
- */
139
- headers?: Record<string, string>;
140
- /**
141
- * If `true`, header names won't be automatically normalized to lowercase.
142
- * This allows for non-http-spec-compliant servers that might expect
143
- * capitalized header names.
144
- *
145
- * @defaultValue false
146
- */
147
- preserveHeaderCase?: boolean;
148
- /**
149
- * The credentials policy to use for each `fetch` call.
150
- */
151
- credentials?: RequestCredentials;
152
- /**
153
- * Any overrides of the fetch options argument to pass to the fetch call.
154
- *
155
- * An object containing options to use for each call to `fetch`. If a
156
- * particular option is not included in this object, the default value of
157
- * that option is used.
158
- *
159
- * > [!NOTE]
160
- * > If you set `fetchOptions.method` to `GET`, `HttpLink` follows [standard
161
- * > GraphQL HTTP GET encoding](http://graphql.org/learn/serving-over-http/#get-request).
162
- *
163
- * See [available options](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
164
- */
165
- fetchOptions?: RequestInit;
166
- /**
167
- * If `true`, unused variables from the operation will not be stripped from
168
- * the request and will instead be sent to the GraphQL endpoint.
169
- *
170
- * @remarks
171
- * Unused variables are likely to trigger server-side validation errors,
172
- * per https://spec.graphql.org/draft/#sec-All-Variables-Used.
173
- * `includeUnusedVariables` can be useful if your server deviates
174
- * from the GraphQL specification by not strictly enforcing that rule.
175
- *
176
- * @defaultValue false
177
- */
178
- includeUnusedVariables?: boolean;
179
- /**
180
- * A function to use when transforming a GraphQL document into a string. It
181
- * accepts an `ASTNode` (typically a `DocumentNode`) and the original `print`
182
- * function as arguments, and is expected to return a string. This option
183
- * enables you to, for example, use `stripIgnoredCharacters` to remove
184
- * whitespace from queries.
185
- *
186
- * By default the [GraphQL `print` function](https://graphql.org/graphql-js/language/#print) is used.
187
- *
188
- * @example
189
- *
190
- * ```ts
191
- * import { stripIgnoredCharacters } from "graphql";
192
- *
193
- * const httpLink = new HttpLink({
194
- * uri: "/graphql",
195
- * print: (ast, originalPrint) => stripIgnoredCharacters(originalPrint(ast)),
196
- * });
197
- * ```
198
- */
199
- print?: HttpLink.Printer;
200
- }
14
+ interface ContextOptions extends BaseHttpLink.ContextOptions, ClientAwarenessLink.ContextOptions {
201
15
  }
202
16
  /**
203
17
  * Options provided to the `HttpLink` constructor.
@@ -208,25 +22,8 @@ export declare namespace HttpLink {
208
22
  * > these options as default values that are used when the request context
209
23
  * > does not override the value.
210
24
  */
211
- interface Options extends Shared.Options {
212
- /**
213
- * If `true`, the link uses an HTTP `GET` request when sending query
214
- * operations to your GraphQL endpoint. Mutation operations continue to use
215
- * `POST` requests. If you want all operations to use `GET` requests,
216
- * set `fetchOptions.method` instead.
217
- *
218
- * @defaultValue false
219
- */
220
- useGETForQueries?: boolean;
221
- }
222
- interface Body {
223
- query?: string;
224
- operationName?: string;
225
- variables?: Record<string, any>;
226
- extensions?: Record<string, any>;
25
+ interface Options extends BaseHttpLink.Options, ClientAwarenessLink.Options {
227
26
  }
228
- type Printer = (node: ASTNode, originalPrint: typeof print) => string;
229
- type UriFunction = (operation: ApolloLink.Operation) => string;
230
27
  }
231
28
  /**
232
29
  * `HttpLink` is a terminating link that sends a GraphQL operation to a remote
@@ -251,11 +48,11 @@ export declare namespace HttpLink {
251
48
  * ```
252
49
  */
253
50
  export declare class HttpLink extends ApolloLink {
254
- constructor(options?: HttpLink.Options & ClientAwarenessLink.Options);
51
+ constructor(options?: HttpLink.Options);
255
52
  }
256
53
  /**
257
54
  * @deprecated
258
55
  * Use `HttpLink` from `@apollo/client/link/http` instead.
259
56
  */
260
- export declare const createHttpLink: (linkOptions?: HttpLink.Options & ClientAwarenessLink.Options) => HttpLink;
57
+ export declare const createHttpLink: (options?: HttpLink.Options) => HttpLink;
261
58
  //# sourceMappingURL=HttpLink.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rewriteURIForGET.cjs","sources":["../../../../src/link/http/rewriteURIForGET.ts"],"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"],"names":[],"mappings":";;AAIA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAFA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAA;AACA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA,CAA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mB;AACnB;"}
1
+ {"version":3,"file":"rewriteURIForGET.cjs","sources":["../../../../src/link/http/rewriteURIForGET.ts"],"sourcesContent":["import type { BaseHttpLink } from \"./BaseHttpLink.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"],"names":[],"mappings":";;AAIA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,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EAAyD,CAAC,EAAE,EAAE,CAA9D,CAAA,EAAkE,EAAE,CAApE,CAAA,CAAuE;IACrE,CAAF,CAAA,CAAA,CAAA,EAAQ,CAAR,CAAA,CAAA,CAAA,CAAA,EAAA,EACI,CADJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EACkB,CADlB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EACsC,CADtC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACiD,CAAC,CADlD,CAAA,CAAA,CACsD,CAAC,CADvD,CAAA,CAC0D,EAD1D,EAC8D,CAD9D,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACsE;IACpE,CAAF,CAAA,CAAA,CAAA,CAAA,EAAS,EAAE,CAAX,CAAA,CAAA,CAAA,CAAA,EAAA,CAAmB;AACnB;"}
@@ -1,5 +1,5 @@
1
- import type { HttpLink } from "./HttpLink.cjs";
2
- export declare function rewriteURIForGET(chosenURI: string, body: HttpLink.Body): {
1
+ import type { BaseHttpLink } from "./BaseHttpLink.cjs";
2
+ export declare function rewriteURIForGET(chosenURI: string, body: BaseHttpLink.Body): {
3
3
  parseError: unknown;
4
4
  newURI?: undefined;
5
5
  } | {