@graphql-tools/executor-http
Advanced tools
Comparing version
# @graphql-tools/executor-http | ||
## 2.0.1-alpha-3653a8eb54929c0cbadfd14455fd9e352ac71f89 | ||
### Patch Changes | ||
- [#1124](https://github.com/graphql-hive/gateway/pull/1124) [`fddb9d4`](https://github.com/graphql-hive/gateway/commit/fddb9d4dfb100aa219e16117faef03abe3d80261) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Handle server sent events stream chunk containing multiple events | ||
- [#1121](https://github.com/graphql-hive/gateway/pull/1121) [`ef0e24c`](https://github.com/graphql-hive/gateway/commit/ef0e24c55ed26320d139a83b1de5b75d5c1bfe4e) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Gracefully handle event stream reading errors and cancellations | ||
- [#1124](https://github.com/graphql-hive/gateway/pull/1124) [`3653a8e`](https://github.com/graphql-hive/gateway/commit/3653a8eb54929c0cbadfd14455fd9e352ac71f89) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Flush incoming chunk before closing the stream | ||
## 2.0.0 | ||
@@ -4,0 +14,0 @@ |
@@ -405,3 +405,4 @@ import { abortSignalAny } from '@graphql-hive/signal'; | ||
const reader = body.getReader(); | ||
reader.closed.then(stop).catch(stop); | ||
let closed = false; | ||
reader.closed.then(() => closed = true).catch((reason) => closed = reason); | ||
stop.then(() => { | ||
@@ -424,3 +425,20 @@ subscriptionCtrl?.abort(); | ||
} | ||
const { done, value: chunk } = await reader.read(); | ||
let done, chunk; | ||
try { | ||
const result = await reader.read(); | ||
done = result.done; | ||
chunk = result.value; | ||
} catch (err) { | ||
if (signal?.aborted) { | ||
await push(createResultForAbort(signal.reason)); | ||
return stop(); | ||
} | ||
const errErr = err instanceof Error ? err : new Error(String(err)); | ||
await push({ | ||
errors: [ | ||
createGraphQLError(errErr.message, { originalError: errErr }) | ||
] | ||
}); | ||
return stop(); | ||
} | ||
if (done) { | ||
@@ -442,3 +460,3 @@ return stop(); | ||
} | ||
const event = msg.split("event:")[1]?.trim(); | ||
const event = msg.split("event:")[1]?.trim().split("\n")[0]?.trim(); | ||
if (event === "complete") { | ||
@@ -448,2 +466,5 @@ return stop(); | ||
} | ||
if (closed) { | ||
return stop(); | ||
} | ||
return pump(); | ||
@@ -450,0 +471,0 @@ } |
{ | ||
"name": "@graphql-tools/executor-http", | ||
"version": "2.0.0", | ||
"version": "2.0.1-alpha-3653a8eb54929c0cbadfd14455fd9e352ac71f89", | ||
"type": "module", | ||
@@ -59,5 +59,5 @@ "description": "A set of utils for faster development of GraphQL tools", | ||
"graphql-yoga": "^5.13.4", | ||
"pkgroll": "2.12.1" | ||
"pkgroll": "2.12.2" | ||
}, | ||
"sideEffects": false | ||
} |
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
101132
2.19%1826
2.35%2
100%