@graphql-tools/executor-http
Advanced tools
Comparing version 1.1.12 to 1.1.13-alpha-0e90237539ec552599afec644f27844d09daf6c5
# @graphql-tools/executor-http | ||
## 1.1.13-alpha-0e90237539ec552599afec644f27844d09daf6c5 | ||
### Patch Changes | ||
- [#274](https://github.com/graphql-hive/gateway/pull/274) [`3f1a0fa`](https://github.com/graphql-hive/gateway/commit/3f1a0fa9f1f3b91542d00a0211d7def8ef30827e) Thanks [@ardatan](https://github.com/ardatan)! - Improve multipart support | ||
## 1.1.12 | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { isAsyncIterable, isPromise, fakePromise, createGraphQLError, inspect, mapAsyncIterator, mergeIncrementalResult, memoize1, getOperationASTFromRequest, mapMaybePromise } from '@graphql-tools/utils'; | ||
import { isAsyncIterable, isPromise, mapMaybePromise, memoize1, createGraphQLError, inspect, mapAsyncIterator, mergeIncrementalResult, getOperationASTFromRequest } from '@graphql-tools/utils'; | ||
import { DisposableSymbols } from '@whatwg-node/disposablestack'; | ||
@@ -15,2 +15,18 @@ import { File, FormData, TextDecoder, fetch } from '@whatwg-node/fetch'; | ||
function collectAsyncIterableValues(asyncIterable) { | ||
const values = []; | ||
const iterator = asyncIterable[Symbol.asyncIterator](); | ||
function iterate() { | ||
return mapMaybePromise(iterator.next(), ({ value, done }) => { | ||
if (value != null) { | ||
values.push(value); | ||
} | ||
if (done) { | ||
return values; | ||
} | ||
return iterate(); | ||
}); | ||
} | ||
return iterate(); | ||
} | ||
function createFormDataFromVariables({ | ||
@@ -65,28 +81,37 @@ query, | ||
if (upload != null) { | ||
const filename = upload.filename || upload.name || upload.path || `blob-${indexStr}`; | ||
if (isPromise(upload)) { | ||
return upload.then( | ||
(resolvedUpload) => handleUpload(resolvedUpload, i) | ||
); | ||
} else if (isBlob(upload)) { | ||
form.append(indexStr, upload, filename); | ||
} else if (isGraphQLUpload(upload)) { | ||
const stream = upload.createReadStream(); | ||
const chunks = []; | ||
return fakePromise(void 0).then(async () => { | ||
for await (const chunk of stream) { | ||
if (chunk) { | ||
chunks.push(...chunk); | ||
} | ||
return mapMaybePromise( | ||
upload?.promise || upload, | ||
(upload2) => { | ||
const filename = upload2.filename || upload2.name || upload2.path || `blob-${indexStr}`; | ||
if (isBlob(upload2)) { | ||
form.append(indexStr, upload2, filename); | ||
} else if (isAsyncIterable(upload2)) { | ||
return mapMaybePromise( | ||
collectAsyncIterableValues(upload2), | ||
(chunks) => { | ||
const blobPart = new Uint8Array(chunks); | ||
form.append( | ||
indexStr, | ||
new FileCtor([blobPart], filename), | ||
filename | ||
); | ||
} | ||
); | ||
} else if (isGraphQLUpload(upload2)) { | ||
return mapMaybePromise( | ||
collectAsyncIterableValues(upload2.createReadStream()), | ||
(chunks) => { | ||
const blobPart = new Uint8Array(chunks); | ||
form.append( | ||
indexStr, | ||
new FileCtor([blobPart], filename, { type: upload2.mimetype }), | ||
filename | ||
); | ||
} | ||
); | ||
} else { | ||
form.append(indexStr, new FileCtor([upload2], filename), filename); | ||
} | ||
const blobPart = new Uint8Array(chunks); | ||
form.append( | ||
indexStr, | ||
new FileCtor([blobPart], filename, { type: upload.mimetype }), | ||
filename | ||
); | ||
}); | ||
} else { | ||
form.append(indexStr, new FileCtor([upload], filename), filename); | ||
} | ||
} | ||
); | ||
} | ||
@@ -111,11 +136,5 @@ } | ||
const printCache = /* @__PURE__ */ new WeakMap(); | ||
function defaultPrintFn(document) { | ||
let printed = printCache.get(document); | ||
if (!printed) { | ||
printed = stripIgnoredCharacters(print(document)); | ||
printCache.set(document, printed); | ||
} | ||
return printed; | ||
} | ||
const defaultPrintFn = memoize1(function defaultPrintFn2(document) { | ||
return stripIgnoredCharacters(print(document)); | ||
}); | ||
@@ -122,0 +141,0 @@ function createAbortErrorReason() { |
{ | ||
"name": "@graphql-tools/executor-http", | ||
"version": "1.1.12", | ||
"version": "1.1.13-alpha-0e90237539ec552599afec644f27844d09daf6c5", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A set of utils for faster development of GraphQL tools", |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
63684
1205
2