@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.
Files changed (3) hide show
  1. package/index.js +15 -6
  2. package/index.mjs +15 -6
  3. 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
- let result = await subscribeFn({
561
- ...args,
562
- contextValue: context,
563
- // Casted for GraphQL.js 15 compatibility
564
- // Can be removed once we drop support for GraphQL.js 15
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
- let result = await subscribeFn({
557
- ...args,
558
- contextValue: context,
559
- // Casted for GraphQL.js 15 compatibility
560
- // Can be removed once we drop support for GraphQL.js 15
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envelop/core",
3
- "version": "2.0.1-alpha-0d78849.0",
3
+ "version": "2.1.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"