@graphql-tools/executor-http
Advanced tools
Comparing version 1.2.9-alpha-b51767203d7e1a3b8638f0c19c21693bd3aab678 to 1.2.9-alpha-de123fe5656cdb7244ee022ff2f6f8b14e8651bf
# @graphql-tools/executor-http | ||
## 1.2.9-alpha-b51767203d7e1a3b8638f0c19c21693bd3aab678 | ||
## 1.2.9-alpha-de123fe5656cdb7244ee022ff2f6f8b14e8651bf | ||
### Patch Changes | ||
- [#727](https://github.com/graphql-hive/gateway/pull/727) [`b517672`](https://github.com/graphql-hive/gateway/commit/b51767203d7e1a3b8638f0c19c21693bd3aab678) Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates: | ||
- [#726](https://github.com/graphql-hive/gateway/pull/726) [`6334b2e`](https://github.com/graphql-hive/gateway/commit/6334b2e5d4942693121ab7d44a96fa80408aace1) Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates: | ||
- Added dependency [`@whatwg-node/promise-helpers@^1.0.0` ↗︎](https://www.npmjs.com/package/@whatwg-node/promise-helpers/v/1.0.0) (to `dependencies`) | ||
- [#727](https://github.com/graphql-hive/gateway/pull/727) [`c54a080`](https://github.com/graphql-hive/gateway/commit/c54a080b8b9c477ed55dd7c23fc8fcae9139bec8) Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates: | ||
- Updated dependency [`@whatwg-node/disposablestack@^0.0.6` ↗︎](https://www.npmjs.com/package/@whatwg-node/disposablestack/v/0.0.6) (from `^0.0.5`, in `dependencies`) | ||
@@ -10,0 +14,0 @@ |
import { defaultPrintFn, serializeExecutionRequest } from '@graphql-tools/executor-common'; | ||
import { isAsyncIterable, isPromise, mapMaybePromise, createGraphQLError, inspect, mapAsyncIterator, mergeIncrementalResult, memoize1, getOperationASTFromRequest } from '@graphql-tools/utils'; | ||
import { isAsyncIterable, createGraphQLError, inspect, mapAsyncIterator, mergeIncrementalResult, memoize1, getOperationASTFromRequest } from '@graphql-tools/utils'; | ||
import { DisposableSymbols } from '@whatwg-node/disposablestack'; | ||
import { FormData, File, TextEncoder, crypto, TextDecoder, fetch } from '@whatwg-node/fetch'; | ||
import { isPromise, handleMaybePromise } from '@whatwg-node/promise-helpers'; | ||
import { ValueOrPromise } from 'value-or-promise'; | ||
@@ -20,11 +21,14 @@ import { extractFiles, isExtractableFile } from 'extract-files'; | ||
function iterate() { | ||
return mapMaybePromise(iterator.next(), ({ value, done }) => { | ||
if (value != null) { | ||
values.push(value); | ||
return handleMaybePromise( | ||
() => iterator.next(), | ||
({ value, done }) => { | ||
if (value != null) { | ||
values.push(value); | ||
} | ||
if (done) { | ||
return values; | ||
} | ||
return iterate(); | ||
} | ||
if (done) { | ||
return values; | ||
} | ||
return iterate(); | ||
}); | ||
); | ||
} | ||
@@ -69,4 +73,4 @@ return iterate(); | ||
if (upload != null) { | ||
return mapMaybePromise( | ||
upload?.promise || upload, | ||
return handleMaybePromise( | ||
() => upload?.promise || upload, | ||
(upload2) => { | ||
@@ -77,4 +81,4 @@ const filename = upload2.filename || upload2.name || upload2.path || `blob-${indexStr}`; | ||
} else if (isAsyncIterable(upload2)) { | ||
return mapMaybePromise( | ||
collectAsyncIterableValues(upload2), | ||
return handleMaybePromise( | ||
() => collectAsyncIterableValues(upload2), | ||
(chunks) => { | ||
@@ -90,4 +94,4 @@ const blobPart = new Uint8Array(chunks); | ||
} else if (isGraphQLUpload(upload2)) { | ||
return mapMaybePromise( | ||
collectAsyncIterableValues(upload2.createReadStream()), | ||
return handleMaybePromise( | ||
() => collectAsyncIterableValues(upload2.createReadStream()), | ||
(chunks) => { | ||
@@ -156,4 +160,4 @@ const blobPart = new Uint8Array(chunks); | ||
const utf8 = textEncoder.encode(str); | ||
return mapMaybePromise( | ||
crypto.subtle.digest("SHA-256", utf8), | ||
return handleMaybePromise( | ||
() => crypto.subtle.digest("SHA-256", utf8), | ||
(hashBuffer) => { | ||
@@ -362,21 +366,24 @@ let hashHex = ""; | ||
serializeFn = function serializeWithAPQ() { | ||
return mapMaybePromise(hashSHA256(query), (sha256Hash) => { | ||
const extensions = request.extensions || {}; | ||
extensions["persistedQuery"] = { | ||
version: 1, | ||
sha256Hash | ||
}; | ||
return serializeExecutionRequest({ | ||
executionRequest: { | ||
...request, | ||
extensions | ||
}, | ||
excludeQuery, | ||
printFn | ||
}); | ||
}); | ||
return handleMaybePromise( | ||
() => hashSHA256(query), | ||
(sha256Hash) => { | ||
const extensions = request.extensions || {}; | ||
extensions["persistedQuery"] = { | ||
version: 1, | ||
sha256Hash | ||
}; | ||
return serializeExecutionRequest({ | ||
executionRequest: { | ||
...request, | ||
extensions | ||
}, | ||
excludeQuery, | ||
printFn | ||
}); | ||
} | ||
); | ||
}; | ||
} | ||
return mapMaybePromise( | ||
serializeFn(), | ||
return handleMaybePromise( | ||
() => serializeFn(), | ||
(body) => new ValueOrPromise(() => { | ||
@@ -407,4 +414,4 @@ switch (method) { | ||
upstreamErrorExtensions.request.body = body; | ||
return mapMaybePromise( | ||
createFormDataFromVariables(body, { | ||
return handleMaybePromise( | ||
() => createFormDataFromVariables(body, { | ||
File: options?.File, | ||
@@ -544,4 +551,4 @@ FormData: options?.FormData | ||
executor = function apqExecutor(request) { | ||
return mapMaybePromise( | ||
baseExecutor(request, true), | ||
return handleMaybePromise( | ||
() => baseExecutor(request, true), | ||
(res) => { | ||
@@ -576,9 +583,12 @@ if (res.errors?.some( | ||
} | ||
return mapMaybePromise(prevExecutor(request), (res) => { | ||
result = res; | ||
if (result?.errors?.length) { | ||
return retryAttempt(); | ||
return handleMaybePromise( | ||
() => prevExecutor(request), | ||
(res) => { | ||
result = res; | ||
if (result?.errors?.length) { | ||
return retryAttempt(); | ||
} | ||
return result; | ||
} | ||
return result; | ||
}); | ||
); | ||
} | ||
@@ -585,0 +595,0 @@ return retryAttempt(); |
{ | ||
"name": "@graphql-tools/executor-http", | ||
"version": "1.2.9-alpha-b51767203d7e1a3b8638f0c19c21693bd3aab678", | ||
"version": "1.2.9-alpha-de123fe5656cdb7244ee022ff2f6f8b14e8651bf", | ||
"type": "module", | ||
@@ -47,2 +47,3 @@ "description": "A set of utils for faster development of GraphQL tools", | ||
"@whatwg-node/fetch": "^0.10.4", | ||
"@whatwg-node/promise-helpers": "^1.0.0", | ||
"extract-files": "^11.0.0", | ||
@@ -49,0 +50,0 @@ "meros": "^1.2.1", |
Sorry, the diff of this file is not supported yet
79090
1362
11