@apollo/client 4.0.0-rc.7 → 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.
- package/CHANGELOG.md +36 -0
- package/__cjs/cache/inmemory/writeToStore.cjs +1 -1
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.cjs +1 -1
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/QueryInfo.cjs +2 -6
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/index.cjs +1 -2
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +1 -2
- package/__cjs/invariantErrorCodes.cjs +9 -9
- package/__cjs/link/batch/batchLink.cjs +31 -5
- package/__cjs/link/batch/batchLink.cjs.map +1 -1
- package/__cjs/link/batch/batchLink.d.cts +102 -26
- package/__cjs/link/batch/batching.cjs.map +1 -1
- package/__cjs/link/batch/batching.d.cts +2 -2
- package/__cjs/link/batch/index.cjs +1 -2
- package/__cjs/link/batch/index.cjs.map +1 -1
- package/__cjs/link/batch/index.d.cts +1 -2
- package/__cjs/link/batch-http/BaseBatchHttpLink.cjs +156 -0
- package/__cjs/link/batch-http/BaseBatchHttpLink.cjs.map +1 -0
- package/__cjs/link/batch-http/BaseBatchHttpLink.d.cts +68 -0
- package/__cjs/link/batch-http/batchHttpLink.cjs +25 -130
- package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
- package/__cjs/link/batch-http/batchHttpLink.d.cts +40 -16
- package/__cjs/link/batch-http/index.cjs +2 -1
- package/__cjs/link/batch-http/index.cjs.map +1 -1
- package/__cjs/link/batch-http/index.d.cts +2 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +36 -3
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +55 -3
- package/__cjs/link/context/index.cjs +19 -0
- package/__cjs/link/context/index.cjs.map +1 -1
- package/__cjs/link/context/index.d.cts +64 -2
- package/__cjs/link/error/index.cjs +44 -0
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +64 -4
- package/__cjs/link/http/BaseHttpLink.cjs +60 -10
- package/__cjs/link/http/BaseHttpLink.cjs.map +1 -1
- package/__cjs/link/http/BaseHttpLink.d.cts +256 -2
- package/__cjs/link/http/HttpLink.cjs +23 -1
- package/__cjs/link/http/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +41 -141
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/index.cjs +1 -3
- package/__cjs/link/http/index.cjs.map +1 -1
- package/__cjs/link/http/index.d.cts +0 -2
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/rewriteURIForGET.cjs +2 -3
- package/__cjs/link/http/rewriteURIForGET.cjs.map +1 -1
- package/__cjs/link/http/rewriteURIForGET.d.cts +2 -2
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
- package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +7 -7
- package/__cjs/link/persisted-queries/index.cjs +18 -2
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/persisted-queries/index.d.cts +204 -24
- package/__cjs/link/remove-typename/index.cjs.map +1 -1
- package/__cjs/link/remove-typename/index.d.cts +0 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +48 -0
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +124 -8
- package/__cjs/link/retry/delayFunction.cjs.map +1 -1
- package/__cjs/link/retry/delayFunction.d.cts +2 -39
- package/__cjs/link/retry/retryFunction.cjs.map +1 -1
- package/__cjs/link/retry/retryFunction.d.cts +2 -29
- package/__cjs/link/retry/retryLink.cjs +35 -10
- package/__cjs/link/retry/retryLink.cjs.map +1 -1
- package/__cjs/link/retry/retryLink.d.cts +129 -4
- package/__cjs/link/schema/index.cjs +20 -0
- package/__cjs/link/schema/index.cjs.map +1 -1
- package/__cjs/link/schema/index.d.cts +129 -7
- package/__cjs/link/subscriptions/index.cjs +23 -0
- package/__cjs/link/subscriptions/index.cjs.map +1 -1
- package/__cjs/link/subscriptions/index.d.cts +23 -0
- package/__cjs/link/ws/index.cjs +35 -1
- package/__cjs/link/ws/index.cjs.map +1 -1
- package/__cjs/link/ws/index.d.cts +63 -5
- package/__cjs/react/hooks/useSyncExternalStore.cjs +2 -6
- package/__cjs/react/hooks/useSyncExternalStore.cjs.map +1 -1
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +2 -6
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs.map +1 -1
- package/__cjs/utilities/subscriptions/relay/index.cjs +1 -2
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/version.cjs +1 -1
- package/cache/inmemory/writeToStore.js +1 -1
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ObservableQuery.js +1 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.js +1 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/index.d.ts +1 -2
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/invariantErrorCodes.js +9 -9
- package/link/batch/batchLink.d.ts +103 -27
- package/link/batch/batchLink.js +30 -3
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.d.ts +2 -2
- package/link/batch/batching.js.map +1 -1
- package/link/batch/index.d.ts +1 -2
- package/link/batch/index.js +1 -1
- package/link/batch/index.js.map +1 -1
- package/link/batch-http/BaseBatchHttpLink.d.ts +68 -0
- package/link/batch-http/BaseBatchHttpLink.js +152 -0
- package/link/batch-http/BaseBatchHttpLink.js.map +1 -0
- package/link/batch-http/batchHttpLink.d.ts +40 -16
- package/link/batch-http/batchHttpLink.js +23 -127
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/batch-http/index.d.ts +2 -1
- package/link/batch-http/index.js +2 -1
- package/link/batch-http/index.js.map +1 -1
- package/link/client-awareness/ClientAwarenessLink.d.ts +56 -4
- package/link/client-awareness/ClientAwarenessLink.js +36 -3
- package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
- package/link/context/index.d.ts +65 -3
- package/link/context/index.js +19 -0
- package/link/context/index.js.map +1 -1
- package/link/error/index.d.ts +65 -5
- package/link/error/index.js +44 -0
- package/link/error/index.js.map +1 -1
- package/link/http/BaseHttpLink.d.ts +257 -3
- package/link/http/BaseHttpLink.js +60 -10
- package/link/http/BaseHttpLink.js.map +1 -1
- package/link/http/HttpLink.d.ts +41 -141
- package/link/http/HttpLink.js +23 -1
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/index.d.ts +0 -2
- package/link/http/index.js +0 -1
- package/link/http/index.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/rewriteURIForGET.d.ts +2 -2
- package/link/http/rewriteURIForGET.js +2 -3
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +7 -7
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/persisted-queries/index.d.ts +205 -25
- package/link/persisted-queries/index.js +18 -2
- package/link/persisted-queries/index.js.map +1 -1
- package/link/remove-typename/index.d.ts +0 -1
- package/link/remove-typename/index.js.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.d.ts +124 -8
- package/link/remove-typename/removeTypenameFromVariables.js +48 -0
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/retry/delayFunction.d.ts +2 -39
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/retryFunction.d.ts +2 -29
- package/link/retry/retryFunction.js.map +1 -1
- package/link/retry/retryLink.d.ts +130 -5
- package/link/retry/retryLink.js +36 -11
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +130 -8
- package/link/schema/index.js +20 -0
- package/link/schema/index.js.map +1 -1
- package/link/subscriptions/index.d.ts +23 -0
- package/link/subscriptions/index.js +23 -0
- package/link/subscriptions/index.js.map +1 -1
- package/link/ws/index.d.ts +63 -5
- package/link/ws/index.js +31 -1
- package/link/ws/index.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/hooks-compiled/useSyncExternalStore.js +1 -1
- package/react/hooks-compiled/useSyncExternalStore.js.map +1 -1
- package/utilities/internal/removeDirectivesFromDocument.js +1 -2
- package/utilities/internal/removeDirectivesFromDocument.js.map +1 -1
- package/utilities/subscriptions/relay/index.js +1 -2
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/version.js +1 -1
- package/__cjs/link/http/serializeFetchParameter.cjs +0 -18
- package/__cjs/link/http/serializeFetchParameter.cjs.map +0 -1
- package/__cjs/link/http/serializeFetchParameter.d.cts +0 -6
- package/link/http/serializeFetchParameter.d.ts +0 -6
- package/link/http/serializeFetchParameter.js +0 -14
- package/link/http/serializeFetchParameter.js.map +0 -1
package/link/http/HttpLink.d.ts
CHANGED
|
@@ -1,158 +1,58 @@
|
|
|
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
|
|
3
|
+
import { BaseHttpLink } from "./BaseHttpLink.js";
|
|
5
4
|
export declare namespace HttpLink {
|
|
6
5
|
/**
|
|
7
|
-
* Options passed to `HttpLink` through request context.
|
|
6
|
+
* Options passed to `HttpLink` through [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context). Previous
|
|
7
|
+
* non-terminating links in the link chain also can set these values to
|
|
8
|
+
* customize the behavior of `HttpLink` for each operation.
|
|
9
|
+
*
|
|
10
|
+
* > [!NOTE]
|
|
11
|
+
* > Some of these values can also be provided to the `HttpLink` constructor.
|
|
12
|
+
* > If a value is provided to both, the value in `context` takes precedence.
|
|
8
13
|
*/
|
|
9
|
-
interface ContextOptions {
|
|
10
|
-
/**
|
|
11
|
-
* The URL of the GraphQL endpoint to send requests to. Can also be a
|
|
12
|
-
* function that accepts an `Operation` object and returns the string URL to
|
|
13
|
-
* use for that operation.
|
|
14
|
-
*/
|
|
15
|
-
uri?: string | UriFunction;
|
|
16
|
-
/**
|
|
17
|
-
* An object representing headers to include in the HTTP request, such as
|
|
18
|
-
* `{Authorization: 'Bearer abc123'}`.
|
|
19
|
-
*/
|
|
20
|
-
headers?: Record<string, string>;
|
|
21
|
-
/**
|
|
22
|
-
* The credentials policy to use for this fetch call. Can be `omit`, `include`,
|
|
23
|
-
* or `same-origin`.
|
|
24
|
-
*/
|
|
25
|
-
credentials?: RequestCredentials;
|
|
26
|
-
/**
|
|
27
|
-
* An object containing options to use for this call to `fetch`. If a
|
|
28
|
-
* particular option is not included in this object, the default value of
|
|
29
|
-
* that option is used.
|
|
30
|
-
*
|
|
31
|
-
* Note that if you set `fetchOptions.method` to `GET`, `HttpLink` follows
|
|
32
|
-
* [standard GraphQL HTTP GET encoding](http://graphql.org/learn/serving-over-http/#get-request).
|
|
33
|
-
*/
|
|
34
|
-
fetchOptions?: RequestInit;
|
|
35
|
-
/**
|
|
36
|
-
* An object that configures advanced `HttpLink` functionality, such as
|
|
37
|
-
* support for persisted queries.
|
|
38
|
-
*/
|
|
39
|
-
http?: HttpLink.HttpOptions;
|
|
14
|
+
interface ContextOptions extends BaseHttpLink.ContextOptions, ClientAwarenessLink.ContextOptions {
|
|
40
15
|
}
|
|
41
16
|
/**
|
|
42
|
-
* Options
|
|
43
|
-
*
|
|
17
|
+
* Options provided to the `HttpLink` constructor.
|
|
18
|
+
*
|
|
19
|
+
* > [!NOTE]
|
|
20
|
+
* > Some of these options are also available to override in [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context).
|
|
21
|
+
* > Context options override the options passed to the constructor. Treat
|
|
22
|
+
* > these options as default values that are used when the request context
|
|
23
|
+
* > does not override the value.
|
|
44
24
|
*/
|
|
45
|
-
interface
|
|
46
|
-
/**
|
|
47
|
-
* If `true`, includes the `extensions` field in operations sent to your
|
|
48
|
-
* GraphQL endpoint.
|
|
49
|
-
*
|
|
50
|
-
* @defaultValue true
|
|
51
|
-
*/
|
|
52
|
-
includeExtensions?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* If `false`, the GraphQL query string is not included in the request. Set
|
|
55
|
-
* this option if you're sending a request that uses a [persisted query](https://www.apollographql.com/docs/react/api/link/persisted-queries/).
|
|
56
|
-
*
|
|
57
|
-
* @defaultValue true
|
|
58
|
-
*/
|
|
59
|
-
includeQuery?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* If set to true, header names won't be automatically normalized to
|
|
62
|
-
* lowercase. This allows for non-http-spec-compliant servers that might
|
|
63
|
-
* expect capitalized header names.
|
|
64
|
-
*
|
|
65
|
-
* @defaultValue false
|
|
66
|
-
*/
|
|
67
|
-
preserveHeaderCase?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* A list of additional `accept` headers to include in the request,
|
|
70
|
-
* as defined in
|
|
71
|
-
* https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.2
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
*
|
|
75
|
-
* ```json
|
|
76
|
-
* ["application/custom+json;q=1.0"]
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
accept?: string[];
|
|
25
|
+
interface Options extends BaseHttpLink.Options, ClientAwarenessLink.Options {
|
|
80
26
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Options for the `HttpLink` constructor.
|
|
83
|
-
*/
|
|
84
|
-
interface Options {
|
|
85
|
-
/**
|
|
86
|
-
* The URI to use when fetching operations.
|
|
87
|
-
*
|
|
88
|
-
* Defaults to '/graphql'.
|
|
89
|
-
*/
|
|
90
|
-
uri?: string | UriFunction;
|
|
91
|
-
/**
|
|
92
|
-
* Passes the extensions field to your graphql server.
|
|
93
|
-
*
|
|
94
|
-
* Defaults to true.
|
|
95
|
-
*/
|
|
96
|
-
includeExtensions?: boolean;
|
|
97
|
-
/**
|
|
98
|
-
* A `fetch`-compatible API to use when making requests.
|
|
99
|
-
*/
|
|
100
|
-
fetch?: typeof fetch;
|
|
101
|
-
/**
|
|
102
|
-
* An object representing values to be sent as headers on the request.
|
|
103
|
-
*/
|
|
104
|
-
headers?: Record<string, string>;
|
|
105
|
-
/**
|
|
106
|
-
* If set to true, header names won't be automatically normalized to
|
|
107
|
-
* lowercase. This allows for non-http-spec-compliant servers that might
|
|
108
|
-
* expect capitalized header names.
|
|
109
|
-
*/
|
|
110
|
-
preserveHeaderCase?: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* The credentials policy you want to use for the fetch call.
|
|
113
|
-
*/
|
|
114
|
-
credentials?: string;
|
|
115
|
-
/**
|
|
116
|
-
* Any overrides of the fetch options argument to pass to the fetch call.
|
|
117
|
-
*/
|
|
118
|
-
fetchOptions?: any;
|
|
119
|
-
/**
|
|
120
|
-
* If set to true, use the HTTP GET method for query operations. Mutations
|
|
121
|
-
* will still use the method specified in fetchOptions.method (which defaults
|
|
122
|
-
* to POST).
|
|
123
|
-
*/
|
|
124
|
-
useGETForQueries?: boolean;
|
|
125
|
-
/**
|
|
126
|
-
* If set to true, the default behavior of stripping unused variables
|
|
127
|
-
* from the request will be disabled.
|
|
128
|
-
*
|
|
129
|
-
* Unused variables are likely to trigger server-side validation errors,
|
|
130
|
-
* per https://spec.graphql.org/draft/#sec-All-Variables-Used, but this
|
|
131
|
-
* includeUnusedVariables option can be useful if your server deviates
|
|
132
|
-
* from the GraphQL specification by not strictly enforcing that rule.
|
|
133
|
-
*/
|
|
134
|
-
includeUnusedVariables?: boolean;
|
|
135
|
-
/**
|
|
136
|
-
* A function to substitute for the default query print function. Can be
|
|
137
|
-
* used to apply changes to the results of the print function.
|
|
138
|
-
*/
|
|
139
|
-
print?: Printer;
|
|
140
|
-
}
|
|
141
|
-
interface Body {
|
|
142
|
-
query?: string;
|
|
143
|
-
operationName?: string;
|
|
144
|
-
variables?: Record<string, any>;
|
|
145
|
-
extensions?: Record<string, any>;
|
|
146
|
-
}
|
|
147
|
-
type Printer = (node: ASTNode, originalPrint: typeof print) => string;
|
|
148
|
-
type UriFunction = (operation: ApolloLink.Operation) => string;
|
|
149
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* `HttpLink` is a terminating link that sends a GraphQL operation to a remote
|
|
30
|
+
* endpoint over HTTP. It combines the functionality of `BaseHttpLink` and
|
|
31
|
+
* `ClientAwarenessLink` into a single link.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
*
|
|
35
|
+
* `HttpLink` supports both POST and GET requests, and you can configure HTTP
|
|
36
|
+
* options on a per-operation basis. You can use these options for
|
|
37
|
+
* authentication, persisted queries, dynamic URIs, and other granular updates.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { HttpLink } from "@apollo/client";
|
|
43
|
+
*
|
|
44
|
+
* const link = new HttpLink({
|
|
45
|
+
* uri: "http://localhost:4000/graphql",
|
|
46
|
+
* // Additional options
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
150
50
|
export declare class HttpLink extends ApolloLink {
|
|
151
|
-
constructor(options?: HttpLink.Options
|
|
51
|
+
constructor(options?: HttpLink.Options);
|
|
152
52
|
}
|
|
153
53
|
/**
|
|
154
54
|
* @deprecated
|
|
155
55
|
* Use `HttpLink` from `@apollo/client/link/http` instead.
|
|
156
56
|
*/
|
|
157
|
-
export declare const createHttpLink: (
|
|
57
|
+
export declare const createHttpLink: (options?: HttpLink.Options) => HttpLink;
|
|
158
58
|
//# sourceMappingURL=HttpLink.d.ts.map
|
package/link/http/HttpLink.js
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { ApolloLink } from "@apollo/client/link";
|
|
2
2
|
import { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
|
|
3
3
|
import { BaseHttpLink } from "./BaseHttpLink.js";
|
|
4
|
+
/**
|
|
5
|
+
* `HttpLink` is a terminating link that sends a GraphQL operation to a remote
|
|
6
|
+
* endpoint over HTTP. It combines the functionality of `BaseHttpLink` and
|
|
7
|
+
* `ClientAwarenessLink` into a single link.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
*
|
|
11
|
+
* `HttpLink` supports both POST and GET requests, and you can configure HTTP
|
|
12
|
+
* options on a per-operation basis. You can use these options for
|
|
13
|
+
* authentication, persisted queries, dynamic URIs, and other granular updates.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { HttpLink } from "@apollo/client";
|
|
19
|
+
*
|
|
20
|
+
* const link = new HttpLink({
|
|
21
|
+
* uri: "http://localhost:4000/graphql",
|
|
22
|
+
* // Additional options
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
4
26
|
export class HttpLink extends ApolloLink {
|
|
5
27
|
constructor(options = {}) {
|
|
6
28
|
const { left, right, request } = ApolloLink.from([
|
|
@@ -15,5 +37,5 @@ export class HttpLink extends ApolloLink {
|
|
|
15
37
|
* @deprecated
|
|
16
38
|
* Use `HttpLink` from `@apollo/client/link/http` instead.
|
|
17
39
|
*/
|
|
18
|
-
export const createHttpLink = (
|
|
40
|
+
export const createHttpLink = (options = {}) => new HttpLink(options);
|
|
19
41
|
//# sourceMappingURL=HttpLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpLink.js","sourceRoot":"","sources":["../../../src/link/http/HttpLink.ts"],"names":[],"mappings":"
|
|
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
1
|
import { invariant } from "@apollo/client/utilities/invariant";
|
|
2
2
|
export const checkFetcher = (fetcher) => {
|
|
3
|
-
invariant(fetcher || typeof fetch !== "undefined",
|
|
3
|
+
invariant(fetcher || typeof fetch !== "undefined", 59);
|
|
4
4
|
};
|
|
5
5
|
//# sourceMappingURL=checkFetcher.js.map
|
package/link/http/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { parseAndCheckHttpResponse } from "./parseAndCheckHttpResponse.js";
|
|
2
|
-
export type { ClientParseError } from "./serializeFetchParameter.js";
|
|
3
|
-
export { serializeFetchParameter } from "./serializeFetchParameter.js";
|
|
4
2
|
export { defaultPrinter, fallbackHttpConfig, selectHttpOptionsAndBody, selectHttpOptionsAndBodyInternal, } from "./selectHttpOptionsAndBody.js";
|
|
5
3
|
export { checkFetcher } from "./checkFetcher.js";
|
|
6
4
|
export { createSignalIfSupported } from "./createSignalIfSupported.js";
|
package/link/http/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { parseAndCheckHttpResponse } from "./parseAndCheckHttpResponse.js";
|
|
2
|
-
export { serializeFetchParameter } from "./serializeFetchParameter.js";
|
|
3
2
|
export { defaultPrinter, fallbackHttpConfig, selectHttpOptionsAndBody, selectHttpOptionsAndBodyInternal, // needed by ../batch-http but not public
|
|
4
3
|
} from "./selectHttpOptionsAndBody.js";
|
|
5
4
|
export { checkFetcher } from "./checkFetcher.js";
|
package/link/http/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACxB,gCAAgC,EAAE,yCAAyC;EAC5E,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["export { parseAndCheckHttpResponse } from \"./parseAndCheckHttpResponse.js\";\nexport {\n defaultPrinter,\n fallbackHttpConfig,\n selectHttpOptionsAndBody,\n selectHttpOptionsAndBodyInternal, // needed by ../batch-http but not public\n} from \"./selectHttpOptionsAndBody.js\";\nexport { checkFetcher } from \"./checkFetcher.js\";\nexport { createSignalIfSupported } from \"./createSignalIfSupported.js\";\nexport { selectURI } from \"./selectURI.js\";\nexport { BaseHttpLink } from \"./BaseHttpLink.js\";\nexport { createHttpLink, HttpLink } from \"./HttpLink.js\";\nexport { rewriteURIForGET } from \"./rewriteURIForGET.js\";\n"]}
|
|
@@ -33,7 +33,7 @@ async function* consumeMultipartBody(response) {
|
|
|
33
33
|
/;\s*boundary=(?:'([^']+)'|"([^"]+)"|([^"'].+?))\s*(?:;|$)/i);
|
|
34
34
|
const boundary = "\r\n--" + (match?.findLast((val) => !!val) || "-");
|
|
35
35
|
let buffer = "";
|
|
36
|
-
invariant(response.body && typeof response.body.getReader === "function",
|
|
36
|
+
invariant(response.body && typeof response.body.getReader === "function", 60);
|
|
37
37
|
const stream = response.body;
|
|
38
38
|
const reader = stream.getReader();
|
|
39
39
|
let done = false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function rewriteURIForGET(chosenURI: string, 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,4 +1,3 @@
|
|
|
1
|
-
import { serializeFetchParameter } from "./serializeFetchParameter.js";
|
|
2
1
|
// For GET operations, returns the given URI rewritten with parameters, or a
|
|
3
2
|
// parse error.
|
|
4
3
|
export function rewriteURIForGET(chosenURI, body) {
|
|
@@ -17,7 +16,7 @@ export function rewriteURIForGET(chosenURI, body) {
|
|
|
17
16
|
if (body.variables) {
|
|
18
17
|
let serializedVariables;
|
|
19
18
|
try {
|
|
20
|
-
serializedVariables =
|
|
19
|
+
serializedVariables = JSON.stringify(body.variables);
|
|
21
20
|
}
|
|
22
21
|
catch (parseError) {
|
|
23
22
|
return { parseError };
|
|
@@ -27,7 +26,7 @@ export function rewriteURIForGET(chosenURI, body) {
|
|
|
27
26
|
if (body.extensions) {
|
|
28
27
|
let serializedExtensions;
|
|
29
28
|
try {
|
|
30
|
-
serializedExtensions =
|
|
29
|
+
serializedExtensions = JSON.stringify(body.extensions);
|
|
31
30
|
}
|
|
32
31
|
catch (parseError) {
|
|
33
32
|
return { parseError };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewriteURIForGET.js","sourceRoot":"","sources":["../../../src/link/http/rewriteURIForGET.ts"],"names":[],"mappings":"
|
|
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,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,OAAO,EAAE,UAAU,EAAE,CAAC;QACxB,CAAC;QACD,aAAa,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,IAAI,oBAAoB,CAAC;QACzB,IAAI,CAAC;YACH,oBAAoB,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,OAAO,EAAE,UAAU,EAAE,CAAC;QACxB,CAAC;QACD,aAAa,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;IACpD,CAAC;IAED,+CAA+C;IAC/C,mEAAmE;IACnE,0EAA0E;IAC1E,yEAAyE;IACzE,kEAAkE;IAClE,mEAAmE;IACnE,IAAI,QAAQ,GAAG,EAAE,EACf,WAAW,GAAG,SAAS,CAAC;IAC1B,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 { 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"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ApolloLink } from "@apollo/client/link";
|
|
2
|
-
import type {
|
|
2
|
+
import type { BaseHttpLink } from "./BaseHttpLink.js";
|
|
3
3
|
interface HttpConfig {
|
|
4
|
-
http?:
|
|
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:
|
|
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:
|
|
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:
|
|
22
|
+
body: BaseHttpLink.Body;
|
|
23
23
|
};
|
|
24
|
-
export declare function selectHttpOptionsAndBodyInternal(operation: ApolloLink.Operation, printer:
|
|
24
|
+
export declare function selectHttpOptionsAndBodyInternal(operation: ApolloLink.Operation, printer: BaseHttpLink.Printer, ...configs: HttpConfig[]): {
|
|
25
25
|
options: HttpConfig & Record<string, any>;
|
|
26
|
-
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,
|
|
1
|
+
{"version":3,"file":"selectHttpOptionsAndBody.js","sourceRoot":"","sources":["../../../src/link/http/selectHttpOptionsAndBody.ts"],"names":[],"mappings":"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","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"]}
|