@envelop/core 2.0.1-alpha-0d78849.0 → 2.1.0
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.js +15 -6
- package/index.mjs +15 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -534,6 +534,7 @@ function createEnvelopOrchestrator(plugins) {
|
|
|
534
534
|
const afterCalls = [];
|
|
535
535
|
const subscribeErrorHandlers = [];
|
|
536
536
|
let context = args.contextValue || {};
|
|
537
|
+
let result;
|
|
537
538
|
for (const onSubscribe of beforeCallbacks.subscribe) {
|
|
538
539
|
const after = await onSubscribe({
|
|
539
540
|
subscribeFn,
|
|
@@ -544,6 +545,9 @@ function createEnvelopOrchestrator(plugins) {
|
|
|
544
545
|
context = { ...context, ...extension };
|
|
545
546
|
},
|
|
546
547
|
args: args,
|
|
548
|
+
setResultAndStopExecution: stopResult => {
|
|
549
|
+
result = stopResult;
|
|
550
|
+
},
|
|
547
551
|
});
|
|
548
552
|
if (after) {
|
|
549
553
|
if (after.onSubscribeResult) {
|
|
@@ -553,16 +557,21 @@ function createEnvelopOrchestrator(plugins) {
|
|
|
553
557
|
subscribeErrorHandlers.push(after.onSubscribeError);
|
|
554
558
|
}
|
|
555
559
|
}
|
|
560
|
+
if (result !== undefined) {
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
556
563
|
}
|
|
557
564
|
if (onResolversHandlers.length) {
|
|
558
565
|
context[resolversHooksSymbol] = onResolversHandlers;
|
|
559
566
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
567
|
+
if (result === undefined) {
|
|
568
|
+
result = await subscribeFn({
|
|
569
|
+
...args,
|
|
570
|
+
contextValue: context,
|
|
571
|
+
// Casted for GraphQL.js 15 compatibility
|
|
572
|
+
// Can be removed once we drop support for GraphQL.js 15
|
|
573
|
+
});
|
|
574
|
+
}
|
|
566
575
|
const onNextHandler = [];
|
|
567
576
|
const onEndHandler = [];
|
|
568
577
|
for (const afterCb of afterCalls) {
|
package/index.mjs
CHANGED
|
@@ -530,6 +530,7 @@ function createEnvelopOrchestrator(plugins) {
|
|
|
530
530
|
const afterCalls = [];
|
|
531
531
|
const subscribeErrorHandlers = [];
|
|
532
532
|
let context = args.contextValue || {};
|
|
533
|
+
let result;
|
|
533
534
|
for (const onSubscribe of beforeCallbacks.subscribe) {
|
|
534
535
|
const after = await onSubscribe({
|
|
535
536
|
subscribeFn,
|
|
@@ -540,6 +541,9 @@ function createEnvelopOrchestrator(plugins) {
|
|
|
540
541
|
context = { ...context, ...extension };
|
|
541
542
|
},
|
|
542
543
|
args: args,
|
|
544
|
+
setResultAndStopExecution: stopResult => {
|
|
545
|
+
result = stopResult;
|
|
546
|
+
},
|
|
543
547
|
});
|
|
544
548
|
if (after) {
|
|
545
549
|
if (after.onSubscribeResult) {
|
|
@@ -549,16 +553,21 @@ function createEnvelopOrchestrator(plugins) {
|
|
|
549
553
|
subscribeErrorHandlers.push(after.onSubscribeError);
|
|
550
554
|
}
|
|
551
555
|
}
|
|
556
|
+
if (result !== undefined) {
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
552
559
|
}
|
|
553
560
|
if (onResolversHandlers.length) {
|
|
554
561
|
context[resolversHooksSymbol] = onResolversHandlers;
|
|
555
562
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
563
|
+
if (result === undefined) {
|
|
564
|
+
result = await subscribeFn({
|
|
565
|
+
...args,
|
|
566
|
+
contextValue: context,
|
|
567
|
+
// Casted for GraphQL.js 15 compatibility
|
|
568
|
+
// Can be removed once we drop support for GraphQL.js 15
|
|
569
|
+
});
|
|
570
|
+
}
|
|
562
571
|
const onNextHandler = [];
|
|
563
572
|
const onEndHandler = [];
|
|
564
573
|
for (const afterCb of afterCalls) {
|