@graphql-tools/url-loader 7.11.0-alpha-9b9d680a.0 → 7.12.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.
- package/cjs/index.js +9 -14
- package/esm/index.js +9 -14
- package/package.json +5 -5
- package/typings/index.d.ts +4 -2
package/cjs/index.js
CHANGED
|
@@ -164,7 +164,9 @@ class UrlLoader {
|
|
|
164
164
|
accept = 'text/event-stream';
|
|
165
165
|
}
|
|
166
166
|
const endpoint = ((_a = request.extensions) === null || _a === void 0 ? void 0 : _a.endpoint) || HTTP_URL;
|
|
167
|
-
const headers = Object.assign({
|
|
167
|
+
const headers = Object.assign({
|
|
168
|
+
accept,
|
|
169
|
+
}, options === null || options === void 0 ? void 0 : options.headers, ((_b = request.extensions) === null || _b === void 0 ? void 0 : _b.headers) || {});
|
|
168
170
|
const query = (0, graphql_1.print)(request.document);
|
|
169
171
|
const requestBody = {
|
|
170
172
|
query,
|
|
@@ -180,7 +182,7 @@ class UrlLoader {
|
|
|
180
182
|
}
|
|
181
183
|
}, options.timeout);
|
|
182
184
|
}
|
|
183
|
-
const credentials = (options === null || options === void 0 ? void 0 : options.credentials) || 'same-origin';
|
|
185
|
+
const credentials = (options === null || options === void 0 ? void 0 : options.credentials) !== 'disable' ? (options === null || options === void 0 ? void 0 : options.credentials) || 'same-origin' : null;
|
|
184
186
|
return new value_or_promise_1.ValueOrPromise(() => {
|
|
185
187
|
switch (method) {
|
|
186
188
|
case 'GET':
|
|
@@ -190,11 +192,8 @@ class UrlLoader {
|
|
|
190
192
|
});
|
|
191
193
|
return fetch(finalUrl, {
|
|
192
194
|
method: 'GET',
|
|
193
|
-
credentials,
|
|
194
|
-
headers
|
|
195
|
-
accept,
|
|
196
|
-
...headers,
|
|
197
|
-
},
|
|
195
|
+
...(credentials != null ? { credentials } : {}),
|
|
196
|
+
headers,
|
|
198
197
|
signal: controller.signal,
|
|
199
198
|
});
|
|
200
199
|
case 'POST':
|
|
@@ -202,12 +201,9 @@ class UrlLoader {
|
|
|
202
201
|
return new value_or_promise_1.ValueOrPromise(() => this.createFormDataFromVariables(requestBody))
|
|
203
202
|
.then(form => fetch(endpoint, {
|
|
204
203
|
method: 'POST',
|
|
205
|
-
credentials,
|
|
204
|
+
...(credentials != null ? { credentials } : {}),
|
|
206
205
|
body: form,
|
|
207
|
-
headers
|
|
208
|
-
accept,
|
|
209
|
-
...headers,
|
|
210
|
-
},
|
|
206
|
+
headers,
|
|
211
207
|
signal: controller.signal,
|
|
212
208
|
}))
|
|
213
209
|
.resolve();
|
|
@@ -215,10 +211,9 @@ class UrlLoader {
|
|
|
215
211
|
else {
|
|
216
212
|
return fetch(endpoint, {
|
|
217
213
|
method: 'POST',
|
|
218
|
-
credentials,
|
|
214
|
+
...(credentials != null ? { credentials } : {}),
|
|
219
215
|
body: JSON.stringify(requestBody),
|
|
220
216
|
headers: {
|
|
221
|
-
accept,
|
|
222
217
|
'content-type': 'application/json',
|
|
223
218
|
...headers,
|
|
224
219
|
},
|
package/esm/index.js
CHANGED
|
@@ -160,7 +160,9 @@ export class UrlLoader {
|
|
|
160
160
|
accept = 'text/event-stream';
|
|
161
161
|
}
|
|
162
162
|
const endpoint = ((_a = request.extensions) === null || _a === void 0 ? void 0 : _a.endpoint) || HTTP_URL;
|
|
163
|
-
const headers = Object.assign({
|
|
163
|
+
const headers = Object.assign({
|
|
164
|
+
accept,
|
|
165
|
+
}, options === null || options === void 0 ? void 0 : options.headers, ((_b = request.extensions) === null || _b === void 0 ? void 0 : _b.headers) || {});
|
|
164
166
|
const query = print(request.document);
|
|
165
167
|
const requestBody = {
|
|
166
168
|
query,
|
|
@@ -176,7 +178,7 @@ export class UrlLoader {
|
|
|
176
178
|
}
|
|
177
179
|
}, options.timeout);
|
|
178
180
|
}
|
|
179
|
-
const credentials = (options === null || options === void 0 ? void 0 : options.credentials) || 'same-origin';
|
|
181
|
+
const credentials = (options === null || options === void 0 ? void 0 : options.credentials) !== 'disable' ? (options === null || options === void 0 ? void 0 : options.credentials) || 'same-origin' : null;
|
|
180
182
|
return new ValueOrPromise(() => {
|
|
181
183
|
switch (method) {
|
|
182
184
|
case 'GET':
|
|
@@ -186,11 +188,8 @@ export class UrlLoader {
|
|
|
186
188
|
});
|
|
187
189
|
return fetch(finalUrl, {
|
|
188
190
|
method: 'GET',
|
|
189
|
-
credentials,
|
|
190
|
-
headers
|
|
191
|
-
accept,
|
|
192
|
-
...headers,
|
|
193
|
-
},
|
|
191
|
+
...(credentials != null ? { credentials } : {}),
|
|
192
|
+
headers,
|
|
194
193
|
signal: controller.signal,
|
|
195
194
|
});
|
|
196
195
|
case 'POST':
|
|
@@ -198,12 +197,9 @@ export class UrlLoader {
|
|
|
198
197
|
return new ValueOrPromise(() => this.createFormDataFromVariables(requestBody))
|
|
199
198
|
.then(form => fetch(endpoint, {
|
|
200
199
|
method: 'POST',
|
|
201
|
-
credentials,
|
|
200
|
+
...(credentials != null ? { credentials } : {}),
|
|
202
201
|
body: form,
|
|
203
|
-
headers
|
|
204
|
-
accept,
|
|
205
|
-
...headers,
|
|
206
|
-
},
|
|
202
|
+
headers,
|
|
207
203
|
signal: controller.signal,
|
|
208
204
|
}))
|
|
209
205
|
.resolve();
|
|
@@ -211,10 +207,9 @@ export class UrlLoader {
|
|
|
211
207
|
else {
|
|
212
208
|
return fetch(endpoint, {
|
|
213
209
|
method: 'POST',
|
|
214
|
-
credentials,
|
|
210
|
+
...(credentials != null ? { credentials } : {}),
|
|
215
211
|
body: JSON.stringify(requestBody),
|
|
216
212
|
headers: {
|
|
217
|
-
accept,
|
|
218
213
|
'content-type': 'application/json',
|
|
219
214
|
...headers,
|
|
220
215
|
},
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/url-loader",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.12.0",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-tools/delegate": "8.8.0
|
|
11
|
-
"@graphql-tools/utils": "8.8.0
|
|
12
|
-
"@graphql-tools/wrap": "8.5.0
|
|
10
|
+
"@graphql-tools/delegate": "8.8.0",
|
|
11
|
+
"@graphql-tools/utils": "8.8.0",
|
|
12
|
+
"@graphql-tools/wrap": "8.5.0",
|
|
13
13
|
"@n1ru4l/graphql-live-query": "^0.9.0",
|
|
14
14
|
"@types/ws": "^8.0.0",
|
|
15
15
|
"cross-undici-fetch": "^0.4.0",
|
|
16
16
|
"dset": "^3.1.2",
|
|
17
17
|
"extract-files": "^11.0.0",
|
|
18
18
|
"graphql-ws": "^5.4.1",
|
|
19
|
-
"isomorphic-ws": "^
|
|
19
|
+
"isomorphic-ws": "^5.0.0",
|
|
20
20
|
"meros": "^1.1.4",
|
|
21
21
|
"sync-fetch": "^0.4.0",
|
|
22
22
|
"tslib": "^2.4.0",
|
package/typings/index.d.ts
CHANGED
|
@@ -88,9 +88,11 @@ export interface LoadFromUrlOptions extends BaseLoaderOptions, Partial<Introspec
|
|
|
88
88
|
*/
|
|
89
89
|
timeout?: number;
|
|
90
90
|
/**
|
|
91
|
-
* Request Credentials
|
|
91
|
+
* Request Credentials (default: 'same-origin')
|
|
92
|
+
* You can pass `disable` if you don't want this to be set in `Request`
|
|
93
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials
|
|
92
94
|
*/
|
|
93
|
-
credentials?: RequestCredentials;
|
|
95
|
+
credentials?: RequestCredentials | 'disable';
|
|
94
96
|
/**
|
|
95
97
|
* Connection Parameters for WebSockets connection
|
|
96
98
|
*/
|