@graphql-tools/executor-http 1.1.12 → 1.1.13-alpha-b1f2cd0ac670dec709b2fe1a50496e079d68604b
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 +6 -0
- package/dist/index.cjs +49 -33
- package/dist/index.js +50 -34
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @graphql-tools/executor-http
|
|
2
2
|
|
|
3
|
+
## 1.1.13-alpha-b1f2cd0ac670dec709b2fe1a50496e079d68604b
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#274](https://github.com/graphql-hive/gateway/pull/274) [`2d13b51`](https://github.com/graphql-hive/gateway/commit/2d13b512f2deb7e3640f3948c7c6631caf4f4346) Thanks [@ardatan](https://github.com/ardatan)! - Improve multipart support
|
|
8
|
+
|
|
3
9
|
## 1.1.12
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -14,6 +14,22 @@ function isGraphQLUpload(upload) {
|
|
|
14
14
|
return typeof upload.createReadStream === "function";
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
function collectAsyncIterableValues(asyncIterable) {
|
|
18
|
+
const values = [];
|
|
19
|
+
const iterator = asyncIterable[Symbol.asyncIterator]();
|
|
20
|
+
function iterate() {
|
|
21
|
+
return utils.mapMaybePromise(iterator.next(), ({ value, done }) => {
|
|
22
|
+
if (value != null) {
|
|
23
|
+
values.push(value);
|
|
24
|
+
}
|
|
25
|
+
if (done) {
|
|
26
|
+
return values;
|
|
27
|
+
}
|
|
28
|
+
return iterate();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return iterate();
|
|
32
|
+
}
|
|
17
33
|
function createFormDataFromVariables({
|
|
18
34
|
query,
|
|
19
35
|
variables,
|
|
@@ -63,32 +79,38 @@ function createFormDataFromVariables({
|
|
|
63
79
|
function handleUpload(upload, i) {
|
|
64
80
|
const indexStr = i.toString();
|
|
65
81
|
if (upload != null) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
return utils.mapMaybePromise(upload?.promise || upload, (upload2) => {
|
|
83
|
+
const filename = upload2.filename || upload2.name || upload2.path || `blob-${indexStr}`;
|
|
84
|
+
if (isBlob(upload2)) {
|
|
85
|
+
form.append(indexStr, upload2, filename);
|
|
86
|
+
} else if (utils.isAsyncIterable(upload2)) {
|
|
87
|
+
return utils.mapMaybePromise(
|
|
88
|
+
collectAsyncIterableValues(upload2),
|
|
89
|
+
(chunks) => {
|
|
90
|
+
const blobPart = new Uint8Array(chunks);
|
|
91
|
+
form.append(
|
|
92
|
+
indexStr,
|
|
93
|
+
new FileCtor([blobPart], filename),
|
|
94
|
+
filename
|
|
95
|
+
);
|
|
80
96
|
}
|
|
81
|
-
}
|
|
82
|
-
const blobPart = new Uint8Array(chunks);
|
|
83
|
-
form.append(
|
|
84
|
-
indexStr,
|
|
85
|
-
new FileCtor([blobPart], filename, { type: upload.mimetype }),
|
|
86
|
-
filename
|
|
87
97
|
);
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
98
|
+
} else if (isGraphQLUpload(upload2)) {
|
|
99
|
+
return utils.mapMaybePromise(
|
|
100
|
+
collectAsyncIterableValues(upload2.createReadStream()),
|
|
101
|
+
(chunks) => {
|
|
102
|
+
const blobPart = new Uint8Array(chunks);
|
|
103
|
+
form.append(
|
|
104
|
+
indexStr,
|
|
105
|
+
new FileCtor([blobPart], filename, { type: upload2.mimetype }),
|
|
106
|
+
filename
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
} else {
|
|
111
|
+
form.append(indexStr, new FileCtor([upload2], filename), filename);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
92
114
|
}
|
|
93
115
|
}
|
|
94
116
|
const jobs = [];
|
|
@@ -108,15 +130,9 @@ function isBlob(obj) {
|
|
|
108
130
|
return typeof obj.arrayBuffer === "function";
|
|
109
131
|
}
|
|
110
132
|
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (!printed) {
|
|
115
|
-
printed = graphql.stripIgnoredCharacters(graphql.print(document));
|
|
116
|
-
printCache.set(document, printed);
|
|
117
|
-
}
|
|
118
|
-
return printed;
|
|
119
|
-
}
|
|
133
|
+
const defaultPrintFn = utils.memoize1(function defaultPrintFn2(document) {
|
|
134
|
+
return graphql.stripIgnoredCharacters(graphql.print(document));
|
|
135
|
+
});
|
|
120
136
|
|
|
121
137
|
function createAbortErrorReason() {
|
|
122
138
|
return new Error("Executor was disposed.");
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAsyncIterable, isPromise,
|
|
1
|
+
import { isAsyncIterable, isPromise, mapMaybePromise, memoize1, createGraphQLError, inspect, mapAsyncIterator, mergeIncrementalResult, getOperationASTFromRequest } from '@graphql-tools/utils';
|
|
2
2
|
import { DisposableSymbols } from '@whatwg-node/disposablestack';
|
|
3
3
|
import { File, FormData, TextDecoder, fetch } from '@whatwg-node/fetch';
|
|
4
4
|
import { ValueOrPromise } from 'value-or-promise';
|
|
@@ -12,6 +12,22 @@ function isGraphQLUpload(upload) {
|
|
|
12
12
|
return typeof upload.createReadStream === "function";
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
function collectAsyncIterableValues(asyncIterable) {
|
|
16
|
+
const values = [];
|
|
17
|
+
const iterator = asyncIterable[Symbol.asyncIterator]();
|
|
18
|
+
function iterate() {
|
|
19
|
+
return mapMaybePromise(iterator.next(), ({ value, done }) => {
|
|
20
|
+
if (value != null) {
|
|
21
|
+
values.push(value);
|
|
22
|
+
}
|
|
23
|
+
if (done) {
|
|
24
|
+
return values;
|
|
25
|
+
}
|
|
26
|
+
return iterate();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return iterate();
|
|
30
|
+
}
|
|
15
31
|
function createFormDataFromVariables({
|
|
16
32
|
query,
|
|
17
33
|
variables,
|
|
@@ -61,32 +77,38 @@ function createFormDataFromVariables({
|
|
|
61
77
|
function handleUpload(upload, i) {
|
|
62
78
|
const indexStr = i.toString();
|
|
63
79
|
if (upload != null) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
(
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
return mapMaybePromise(upload?.promise || upload, (upload2) => {
|
|
81
|
+
const filename = upload2.filename || upload2.name || upload2.path || `blob-${indexStr}`;
|
|
82
|
+
if (isBlob(upload2)) {
|
|
83
|
+
form.append(indexStr, upload2, filename);
|
|
84
|
+
} else if (isAsyncIterable(upload2)) {
|
|
85
|
+
return mapMaybePromise(
|
|
86
|
+
collectAsyncIterableValues(upload2),
|
|
87
|
+
(chunks) => {
|
|
88
|
+
const blobPart = new Uint8Array(chunks);
|
|
89
|
+
form.append(
|
|
90
|
+
indexStr,
|
|
91
|
+
new FileCtor([blobPart], filename),
|
|
92
|
+
filename
|
|
93
|
+
);
|
|
78
94
|
}
|
|
79
|
-
}
|
|
80
|
-
const blobPart = new Uint8Array(chunks);
|
|
81
|
-
form.append(
|
|
82
|
-
indexStr,
|
|
83
|
-
new FileCtor([blobPart], filename, { type: upload.mimetype }),
|
|
84
|
-
filename
|
|
85
95
|
);
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
96
|
+
} else if (isGraphQLUpload(upload2)) {
|
|
97
|
+
return mapMaybePromise(
|
|
98
|
+
collectAsyncIterableValues(upload2.createReadStream()),
|
|
99
|
+
(chunks) => {
|
|
100
|
+
const blobPart = new Uint8Array(chunks);
|
|
101
|
+
form.append(
|
|
102
|
+
indexStr,
|
|
103
|
+
new FileCtor([blobPart], filename, { type: upload2.mimetype }),
|
|
104
|
+
filename
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
} else {
|
|
109
|
+
form.append(indexStr, new FileCtor([upload2], filename), filename);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
90
112
|
}
|
|
91
113
|
}
|
|
92
114
|
const jobs = [];
|
|
@@ -106,15 +128,9 @@ function isBlob(obj) {
|
|
|
106
128
|
return typeof obj.arrayBuffer === "function";
|
|
107
129
|
}
|
|
108
130
|
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (!printed) {
|
|
113
|
-
printed = stripIgnoredCharacters(print(document));
|
|
114
|
-
printCache.set(document, printed);
|
|
115
|
-
}
|
|
116
|
-
return printed;
|
|
117
|
-
}
|
|
131
|
+
const defaultPrintFn = memoize1(function defaultPrintFn2(document) {
|
|
132
|
+
return stripIgnoredCharacters(print(document));
|
|
133
|
+
});
|
|
118
134
|
|
|
119
135
|
function createAbortErrorReason() {
|
|
120
136
|
return new Error("Executor was disposed.");
|
package/package.json
CHANGED