@graphql-tools/url-loader 7.4.2-alpha-16b9e69f.0 → 7.4.2
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/index.d.ts +4 -0
- package/index.js +15 -15
- package/index.mjs +15 -15
- package/package.json +4 -5
package/index.d.ts
CHANGED
|
@@ -81,6 +81,10 @@ export interface LoadFromUrlOptions extends BaseLoaderOptions, Partial<Introspec
|
|
|
81
81
|
* Additional options to pass to the graphql-sse client.
|
|
82
82
|
*/
|
|
83
83
|
graphqlSseOptions?: Omit<GraphQLSSEClientOptions, 'url' | 'headers' | 'fetchFn' | 'abortControllerImpl'>;
|
|
84
|
+
/**
|
|
85
|
+
* Fetch SDL with Apollo Federation introspection query
|
|
86
|
+
*/
|
|
87
|
+
federation?: boolean;
|
|
84
88
|
}
|
|
85
89
|
/**
|
|
86
90
|
* This loader loads a schema from a URL. The loaded schema is a fully-executable,
|
package/index.js
CHANGED
|
@@ -30,7 +30,6 @@ const wrap = require('@graphql-tools/wrap');
|
|
|
30
30
|
const graphqlWs = require('graphql-ws');
|
|
31
31
|
const graphqlSse = require('graphql-sse');
|
|
32
32
|
const WebSocket = _interopDefault(require('isomorphic-ws'));
|
|
33
|
-
const isPromise = _interopDefault(require('is-promise'));
|
|
34
33
|
const extractFiles = require('extract-files');
|
|
35
34
|
const FormData = _interopDefault(require('form-data'));
|
|
36
35
|
const subscriptionsTransportWs = require('subscriptions-transport-ws');
|
|
@@ -313,12 +312,15 @@ class UrlLoader {
|
|
|
313
312
|
}
|
|
314
313
|
createFormDataFromVariables({ query, variables, operationName, extensions, }) {
|
|
315
314
|
const vars = Object.assign({}, variables);
|
|
316
|
-
const { clone, files } = extractFiles.extractFiles(vars, 'variables', ((v) => extractFiles.isExtractableFile(v) || (v === null || v === void 0 ? void 0 : v.promise) || utils.isAsyncIterable(v) ||
|
|
317
|
-
const map =
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
315
|
+
const { clone, files } = extractFiles.extractFiles(vars, 'variables', ((v) => extractFiles.isExtractableFile(v) || (v === null || v === void 0 ? void 0 : v.promise) || utils.isAsyncIterable(v) || (v === null || v === void 0 ? void 0 : v.then)));
|
|
316
|
+
const map = {};
|
|
317
|
+
const uploads = [];
|
|
318
|
+
let currIndex = 0;
|
|
319
|
+
for (const [file, curr] of files) {
|
|
320
|
+
map[currIndex] = curr;
|
|
321
|
+
uploads[currIndex] = file;
|
|
322
|
+
currIndex++;
|
|
323
|
+
}
|
|
322
324
|
const form = new FormData();
|
|
323
325
|
form.append('operations', JSON.stringify({
|
|
324
326
|
query,
|
|
@@ -327,22 +329,20 @@ class UrlLoader {
|
|
|
327
329
|
extensions,
|
|
328
330
|
}));
|
|
329
331
|
form.append('map', JSON.stringify(map));
|
|
330
|
-
return valueOrPromise.ValueOrPromise.all(
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
}).then(([i, u]) => {
|
|
334
|
-
if (u === null || u === void 0 ? void 0 : u.promise) {
|
|
332
|
+
return valueOrPromise.ValueOrPromise.all(uploads.map((u$, i) => new valueOrPromise.ValueOrPromise(() => u$).then(u => {
|
|
333
|
+
const indexStr = i.toString();
|
|
334
|
+
if (u != null && 'promise' in u) {
|
|
335
335
|
return u.promise.then((upload) => {
|
|
336
336
|
const stream = upload.createReadStream();
|
|
337
|
-
form.append(
|
|
337
|
+
form.append(indexStr, stream, {
|
|
338
338
|
filename: upload.filename,
|
|
339
339
|
contentType: upload.mimetype,
|
|
340
340
|
});
|
|
341
341
|
});
|
|
342
342
|
}
|
|
343
343
|
else {
|
|
344
|
-
form.append(
|
|
345
|
-
filename:
|
|
344
|
+
form.append(indexStr, u, {
|
|
345
|
+
filename: u.name || u.path || indexStr,
|
|
346
346
|
contentType: u.type,
|
|
347
347
|
});
|
|
348
348
|
}
|
package/index.mjs
CHANGED
|
@@ -5,7 +5,6 @@ import { introspectSchema, wrapSchema } from '@graphql-tools/wrap';
|
|
|
5
5
|
import { createClient } from 'graphql-ws';
|
|
6
6
|
import { createClient as createClient$1 } from 'graphql-sse';
|
|
7
7
|
import WebSocket from 'isomorphic-ws';
|
|
8
|
-
import isPromise from 'is-promise';
|
|
9
8
|
import { extractFiles, isExtractableFile } from 'extract-files';
|
|
10
9
|
import FormData from 'form-data';
|
|
11
10
|
import { SubscriptionClient } from 'subscriptions-transport-ws';
|
|
@@ -289,12 +288,15 @@ class UrlLoader {
|
|
|
289
288
|
}
|
|
290
289
|
createFormDataFromVariables({ query, variables, operationName, extensions, }) {
|
|
291
290
|
const vars = Object.assign({}, variables);
|
|
292
|
-
const { clone, files } = extractFiles(vars, 'variables', ((v) => isExtractableFile(v) || (v === null || v === void 0 ? void 0 : v.promise) || isAsyncIterable(v) ||
|
|
293
|
-
const map =
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
291
|
+
const { clone, files } = extractFiles(vars, 'variables', ((v) => isExtractableFile(v) || (v === null || v === void 0 ? void 0 : v.promise) || isAsyncIterable(v) || (v === null || v === void 0 ? void 0 : v.then)));
|
|
292
|
+
const map = {};
|
|
293
|
+
const uploads = [];
|
|
294
|
+
let currIndex = 0;
|
|
295
|
+
for (const [file, curr] of files) {
|
|
296
|
+
map[currIndex] = curr;
|
|
297
|
+
uploads[currIndex] = file;
|
|
298
|
+
currIndex++;
|
|
299
|
+
}
|
|
298
300
|
const form = new FormData();
|
|
299
301
|
form.append('operations', JSON.stringify({
|
|
300
302
|
query,
|
|
@@ -303,22 +305,20 @@ class UrlLoader {
|
|
|
303
305
|
extensions,
|
|
304
306
|
}));
|
|
305
307
|
form.append('map', JSON.stringify(map));
|
|
306
|
-
return ValueOrPromise.all(
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
}).then(([i, u]) => {
|
|
310
|
-
if (u === null || u === void 0 ? void 0 : u.promise) {
|
|
308
|
+
return ValueOrPromise.all(uploads.map((u$, i) => new ValueOrPromise(() => u$).then(u => {
|
|
309
|
+
const indexStr = i.toString();
|
|
310
|
+
if (u != null && 'promise' in u) {
|
|
311
311
|
return u.promise.then((upload) => {
|
|
312
312
|
const stream = upload.createReadStream();
|
|
313
|
-
form.append(
|
|
313
|
+
form.append(indexStr, stream, {
|
|
314
314
|
filename: upload.filename,
|
|
315
315
|
contentType: upload.mimetype,
|
|
316
316
|
});
|
|
317
317
|
});
|
|
318
318
|
}
|
|
319
319
|
else {
|
|
320
|
-
form.append(
|
|
321
|
-
filename:
|
|
320
|
+
form.append(indexStr, u, {
|
|
321
|
+
filename: u.name || u.path || indexStr,
|
|
322
322
|
contentType: u.type,
|
|
323
323
|
});
|
|
324
324
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/url-loader",
|
|
3
|
-
"version": "7.4.2
|
|
3
|
+
"version": "7.4.2",
|
|
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"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-tools/delegate": "8.4.1
|
|
11
|
-
"@graphql-tools/utils": "8.
|
|
12
|
-
"@graphql-tools/wrap": "8.3.1
|
|
10
|
+
"@graphql-tools/delegate": "^8.4.1",
|
|
11
|
+
"@graphql-tools/utils": "^8.5.1",
|
|
12
|
+
"@graphql-tools/wrap": "^8.3.1",
|
|
13
13
|
"@n1ru4l/graphql-live-query": "0.8.1",
|
|
14
14
|
"@types/websocket": "1.0.4",
|
|
15
15
|
"@types/ws": "^8.0.0",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"form-data": "4.0.0",
|
|
21
21
|
"graphql-sse": "^1.0.1",
|
|
22
22
|
"graphql-ws": "^5.4.1",
|
|
23
|
-
"is-promise": "4.0.0",
|
|
24
23
|
"isomorphic-ws": "4.0.1",
|
|
25
24
|
"meros": "1.1.4",
|
|
26
25
|
"subscriptions-transport-ws": "^0.10.0",
|