@graphitation/supermassive 3.7.0 → 3.8.0-alpha.1
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/.eslintcache +1 -1
- package/CHANGELOG.md +10 -2
- package/lib/benchmarks/index.js +72 -0
- package/lib/benchmarks/index.js.map +2 -2
- package/lib/benchmarks/index.mjs +72 -0
- package/lib/benchmarks/index.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +238 -107
- package/lib/executeWithoutSchema.js.map +3 -3
- package/lib/executeWithoutSchema.mjs +239 -107
- package/lib/executeWithoutSchema.mjs.map +3 -3
- package/lib/hooks/types.d.ts +18 -6
- package/lib/hooks/types.d.ts.map +1 -1
- package/lib/hooks/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -40,6 +40,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
40
40
|
|
|
41
41
|
// src/executeWithoutSchema.ts
|
|
42
42
|
import {
|
|
43
|
+
GraphQLError,
|
|
43
44
|
Kind,
|
|
44
45
|
locatedError
|
|
45
46
|
} from "graphql";
|
|
@@ -460,53 +461,71 @@ function executeSubscriptionImpl(exeContext) {
|
|
|
460
461
|
try {
|
|
461
462
|
const args = getArgumentValues(exeContext, fieldDef, fieldGroup[0]);
|
|
462
463
|
const contextValue = exeContext.contextValue;
|
|
463
|
-
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.
|
|
464
|
-
hookContext =
|
|
464
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.beforeFieldSubscribe)) {
|
|
465
|
+
hookContext = invokeBeforeFieldSubscribeHook(info, exeContext);
|
|
465
466
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
467
|
+
let result;
|
|
468
|
+
if (hookContext) {
|
|
469
|
+
if (isPromise(hookContext)) {
|
|
470
|
+
result = hookContext.then((context) => {
|
|
471
|
+
hookContext = context;
|
|
472
|
+
if (hookContext instanceof GraphQLError) {
|
|
473
|
+
return null;
|
|
474
|
+
}
|
|
475
|
+
return resolveFn(rootValue, args, contextValue, info);
|
|
476
|
+
});
|
|
477
|
+
} else if (hookContext instanceof GraphQLError) {
|
|
478
|
+
result = null;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (result === void 0) {
|
|
482
|
+
result = resolveFn(rootValue, args, contextValue, info);
|
|
483
|
+
}
|
|
484
|
+
const afterFieldSubscribeHandle = (resolved, error) => {
|
|
485
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldSubscribe)) {
|
|
486
|
+
hookContext = invokeAfterFieldSubscribeHook(
|
|
487
|
+
info,
|
|
488
|
+
exeContext,
|
|
489
|
+
hookContext,
|
|
490
|
+
resolved,
|
|
491
|
+
error
|
|
492
|
+
);
|
|
493
|
+
if (hookContext instanceof GraphQLError) {
|
|
494
|
+
throw hookContext;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
};
|
|
470
498
|
if (isPromise(result)) {
|
|
471
499
|
return result.then(assertEventStream).then(
|
|
472
500
|
(resolved) => {
|
|
473
|
-
if (
|
|
474
|
-
|
|
501
|
+
if (resolved instanceof GraphQLError) {
|
|
502
|
+
throw resolved;
|
|
503
|
+
}
|
|
504
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldSubscribe)) {
|
|
505
|
+
hookContext = invokeAfterFieldSubscribeHook(
|
|
475
506
|
info,
|
|
476
507
|
exeContext,
|
|
477
508
|
hookContext,
|
|
478
509
|
resolved
|
|
479
510
|
);
|
|
511
|
+
if (hookContext instanceof GraphQLError) {
|
|
512
|
+
throw hookContext;
|
|
513
|
+
}
|
|
480
514
|
}
|
|
481
515
|
return resolved;
|
|
482
516
|
},
|
|
483
517
|
(error) => {
|
|
484
|
-
|
|
485
|
-
hookContext = invokeAfterFieldResolveHook(
|
|
486
|
-
info,
|
|
487
|
-
exeContext,
|
|
488
|
-
hookContext,
|
|
489
|
-
void 0,
|
|
490
|
-
error
|
|
491
|
-
);
|
|
492
|
-
}
|
|
518
|
+
afterFieldSubscribeHandle(void 0, error);
|
|
493
519
|
throw locatedError(error, fieldGroup, pathToArray(path));
|
|
494
520
|
}
|
|
495
521
|
);
|
|
496
522
|
}
|
|
497
523
|
const stream = assertEventStream(result);
|
|
498
|
-
|
|
499
|
-
hookContext = invokeAfterFieldResolveHook(
|
|
500
|
-
info,
|
|
501
|
-
exeContext,
|
|
502
|
-
hookContext,
|
|
503
|
-
stream
|
|
504
|
-
);
|
|
505
|
-
}
|
|
524
|
+
afterFieldSubscribeHandle(stream);
|
|
506
525
|
return stream;
|
|
507
526
|
} catch (error) {
|
|
508
|
-
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.
|
|
509
|
-
hookContext =
|
|
527
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldSubscribe)) {
|
|
528
|
+
hookContext = invokeAfterFieldSubscribeHook(
|
|
510
529
|
info,
|
|
511
530
|
exeContext,
|
|
512
531
|
hookContext,
|
|
@@ -514,6 +533,9 @@ function executeSubscriptionImpl(exeContext) {
|
|
|
514
533
|
error
|
|
515
534
|
);
|
|
516
535
|
}
|
|
536
|
+
if (hookContext instanceof GraphQLError) {
|
|
537
|
+
throw hookContext;
|
|
538
|
+
}
|
|
517
539
|
throw locatedError(error, fieldGroup, pathToArray(path));
|
|
518
540
|
}
|
|
519
541
|
}
|
|
@@ -550,25 +572,28 @@ function mapResultOrEventStreamOrPromise(resultOrStreamOrPromise, exeContext, pa
|
|
|
550
572
|
payload
|
|
551
573
|
);
|
|
552
574
|
const hooks = exeContext == null ? void 0 : exeContext.fieldExecutionHooks;
|
|
553
|
-
let
|
|
575
|
+
let beforeExecuteSubscriptionEvenEmitHook;
|
|
554
576
|
if (hooks == null ? void 0 : hooks.beforeSubscriptionEventEmit) {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
577
|
+
beforeExecuteSubscriptionEvenEmitHook = invokeBeforeSubscriptionEventEmitHook(perEventContext, payload);
|
|
578
|
+
if (beforeExecuteSubscriptionEvenEmitHook instanceof GraphQLError) {
|
|
579
|
+
return buildResponse(perEventContext, null);
|
|
580
|
+
}
|
|
559
581
|
}
|
|
560
582
|
try {
|
|
561
|
-
const data = isPromise(
|
|
562
|
-
()
|
|
563
|
-
|
|
583
|
+
const data = isPromise(beforeExecuteSubscriptionEvenEmitHook) ? beforeExecuteSubscriptionEvenEmitHook.then((context) => {
|
|
584
|
+
if (context instanceof GraphQLError) {
|
|
585
|
+
return null;
|
|
586
|
+
}
|
|
587
|
+
return executeFields(
|
|
588
|
+
perEventContext,
|
|
564
589
|
parentTypeName,
|
|
565
590
|
payload,
|
|
566
591
|
path,
|
|
567
592
|
groupedFieldSet,
|
|
568
593
|
void 0
|
|
569
|
-
)
|
|
570
|
-
) : executeFields(
|
|
571
|
-
|
|
594
|
+
);
|
|
595
|
+
}) : executeFields(
|
|
596
|
+
perEventContext,
|
|
572
597
|
parentTypeName,
|
|
573
598
|
payload,
|
|
574
599
|
path,
|
|
@@ -633,54 +658,59 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
633
658
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.beforeFieldResolve)) {
|
|
634
659
|
hookContext = invokeBeforeFieldResolveHook(info, exeContext);
|
|
635
660
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
}
|
|
661
|
+
let result;
|
|
662
|
+
if (hookContext instanceof GraphQLError) {
|
|
663
|
+
result = null;
|
|
664
|
+
} else if (isPromise(hookContext)) {
|
|
665
|
+
result = hookContext.then((context) => {
|
|
666
|
+
hookContext = context;
|
|
667
|
+
if (hookContext instanceof GraphQLError) {
|
|
668
|
+
return null;
|
|
669
|
+
}
|
|
670
|
+
return resolveFn(source, args, contextValue, info);
|
|
671
|
+
});
|
|
672
|
+
} else {
|
|
673
|
+
result = resolveFn(source, args, contextValue, info);
|
|
674
|
+
}
|
|
640
675
|
let completed;
|
|
676
|
+
const handleAfterFieldHooks = (hook, useHook) => (resolved, error) => {
|
|
677
|
+
if (!isDefaultResolverUsed && useHook) {
|
|
678
|
+
hookContext = hook(info, exeContext, hookContext, resolved, error);
|
|
679
|
+
return hookContext instanceof GraphQLError ? null : resolved;
|
|
680
|
+
}
|
|
681
|
+
return resolved;
|
|
682
|
+
};
|
|
641
683
|
if (isPromise(result)) {
|
|
642
684
|
completed = result.then(
|
|
685
|
+
handleAfterFieldHooks(
|
|
686
|
+
invokeAfterFieldResolveHook,
|
|
687
|
+
!!(hooks == null ? void 0 : hooks.afterFieldResolve)
|
|
688
|
+
)
|
|
689
|
+
).then(
|
|
643
690
|
(resolved) => {
|
|
644
|
-
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
|
|
645
|
-
hookContext = invokeAfterFieldResolveHook(
|
|
646
|
-
info,
|
|
647
|
-
exeContext,
|
|
648
|
-
hookContext,
|
|
649
|
-
resolved
|
|
650
|
-
);
|
|
651
|
-
}
|
|
652
691
|
return completeValue(
|
|
653
692
|
exeContext,
|
|
654
693
|
returnTypeRef,
|
|
655
694
|
fieldGroup,
|
|
656
695
|
info,
|
|
657
696
|
path,
|
|
658
|
-
resolved,
|
|
697
|
+
hookContext instanceof GraphQLError ? null : resolved,
|
|
659
698
|
incrementalDataRecord
|
|
660
699
|
);
|
|
661
700
|
},
|
|
662
701
|
(rawError) => {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
hookContext,
|
|
668
|
-
void 0,
|
|
669
|
-
rawError
|
|
670
|
-
);
|
|
671
|
-
}
|
|
702
|
+
handleAfterFieldHooks(
|
|
703
|
+
invokeAfterFieldResolveHook,
|
|
704
|
+
!!(hooks == null ? void 0 : hooks.afterFieldResolve)
|
|
705
|
+
)(void 0, rawError);
|
|
672
706
|
throw rawError;
|
|
673
707
|
}
|
|
674
708
|
);
|
|
675
709
|
} else {
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
hookContext,
|
|
681
|
-
result
|
|
682
|
-
);
|
|
683
|
-
}
|
|
710
|
+
result = handleAfterFieldHooks(
|
|
711
|
+
invokeAfterFieldResolveHook,
|
|
712
|
+
!!(hooks == null ? void 0 : hooks.afterFieldResolve)
|
|
713
|
+
)(result);
|
|
684
714
|
completed = completeValue(
|
|
685
715
|
exeContext,
|
|
686
716
|
returnTypeRef,
|
|
@@ -693,27 +723,18 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
693
723
|
}
|
|
694
724
|
if (isPromise(completed)) {
|
|
695
725
|
return completed.then(
|
|
696
|
-
(
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
exeContext,
|
|
701
|
-
hookContext,
|
|
702
|
-
resolved
|
|
703
|
-
);
|
|
704
|
-
}
|
|
705
|
-
return resolved;
|
|
706
|
-
},
|
|
726
|
+
handleAfterFieldHooks(
|
|
727
|
+
invokeAfterFieldCompleteHook,
|
|
728
|
+
!!(hooks == null ? void 0 : hooks.afterFieldComplete)
|
|
729
|
+
),
|
|
707
730
|
(rawError) => {
|
|
708
731
|
const error = locatedError(rawError, fieldGroup, pathToArray(path));
|
|
709
|
-
|
|
710
|
-
invokeAfterFieldCompleteHook
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
error
|
|
716
|
-
);
|
|
732
|
+
const hookResult = handleAfterFieldHooks(
|
|
733
|
+
invokeAfterFieldCompleteHook,
|
|
734
|
+
!!(hooks == null ? void 0 : hooks.afterFieldComplete)
|
|
735
|
+
)(void 0, error);
|
|
736
|
+
if (hookResult === null) {
|
|
737
|
+
return null;
|
|
717
738
|
}
|
|
718
739
|
handleFieldError(
|
|
719
740
|
rawError,
|
|
@@ -727,10 +748,10 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
727
748
|
}
|
|
728
749
|
);
|
|
729
750
|
}
|
|
730
|
-
|
|
731
|
-
invokeAfterFieldCompleteHook
|
|
732
|
-
|
|
733
|
-
|
|
751
|
+
return handleAfterFieldHooks(
|
|
752
|
+
invokeAfterFieldCompleteHook,
|
|
753
|
+
!!(hooks == null ? void 0 : hooks.afterFieldComplete)
|
|
754
|
+
)(completed);
|
|
734
755
|
} catch (rawError) {
|
|
735
756
|
const pathArray = pathToArray(path);
|
|
736
757
|
const error = locatedError(rawError, fieldGroup, pathArray);
|
|
@@ -744,13 +765,16 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
744
765
|
);
|
|
745
766
|
}
|
|
746
767
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
747
|
-
invokeAfterFieldCompleteHook(
|
|
768
|
+
const invokeAfterFieldCompleteHookResult = invokeAfterFieldCompleteHook(
|
|
748
769
|
info,
|
|
749
770
|
exeContext,
|
|
750
771
|
hookContext,
|
|
751
772
|
void 0,
|
|
752
773
|
error
|
|
753
774
|
);
|
|
775
|
+
if (invokeAfterFieldCompleteHookResult instanceof GraphQLError) {
|
|
776
|
+
return null;
|
|
777
|
+
}
|
|
754
778
|
}
|
|
755
779
|
handleFieldError(
|
|
756
780
|
rawError,
|
|
@@ -1223,6 +1247,39 @@ function collectAndExecuteSubfields(exeContext, returnTypeName, fieldGroup, path
|
|
|
1223
1247
|
}
|
|
1224
1248
|
return subFields;
|
|
1225
1249
|
}
|
|
1250
|
+
function invokeBeforeFieldSubscribeHook(resolveInfo, exeContext) {
|
|
1251
|
+
var _a;
|
|
1252
|
+
const hook = (_a = exeContext.fieldExecutionHooks) == null ? void 0 : _a.beforeFieldSubscribe;
|
|
1253
|
+
if (!hook) {
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
return executeSafe(
|
|
1257
|
+
() => hook({
|
|
1258
|
+
resolveInfo,
|
|
1259
|
+
context: exeContext.contextValue
|
|
1260
|
+
}),
|
|
1261
|
+
(result, rawError) => {
|
|
1262
|
+
if (rawError) {
|
|
1263
|
+
const error = toGraphQLError(
|
|
1264
|
+
rawError,
|
|
1265
|
+
resolveInfo.path,
|
|
1266
|
+
"Unexpected error in beforeFieldSubscribe hook"
|
|
1267
|
+
);
|
|
1268
|
+
exeContext.errors.push(error);
|
|
1269
|
+
return error;
|
|
1270
|
+
} else if (result instanceof Error) {
|
|
1271
|
+
const error = toGraphQLError(
|
|
1272
|
+
result,
|
|
1273
|
+
resolveInfo.path,
|
|
1274
|
+
"Unexpected error in beforeFieldSubscribe hook"
|
|
1275
|
+
);
|
|
1276
|
+
exeContext.errors.push(error);
|
|
1277
|
+
return error;
|
|
1278
|
+
}
|
|
1279
|
+
return result;
|
|
1280
|
+
}
|
|
1281
|
+
);
|
|
1282
|
+
}
|
|
1226
1283
|
function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
1227
1284
|
var _a;
|
|
1228
1285
|
const hook = (_a = exeContext.fieldExecutionHooks) == null ? void 0 : _a.beforeFieldResolve;
|
|
@@ -1234,7 +1291,7 @@ function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
|
1234
1291
|
resolveInfo,
|
|
1235
1292
|
context: exeContext.contextValue
|
|
1236
1293
|
}),
|
|
1237
|
-
(
|
|
1294
|
+
(result, rawError) => {
|
|
1238
1295
|
if (rawError) {
|
|
1239
1296
|
const error = toGraphQLError(
|
|
1240
1297
|
rawError,
|
|
@@ -1242,7 +1299,16 @@ function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
|
1242
1299
|
"Unexpected error in beforeFieldResolve hook"
|
|
1243
1300
|
);
|
|
1244
1301
|
exeContext.errors.push(error);
|
|
1302
|
+
return error;
|
|
1303
|
+
} else if (result instanceof Error) {
|
|
1304
|
+
const error = toGraphQLError(
|
|
1305
|
+
result,
|
|
1306
|
+
resolveInfo.path,
|
|
1307
|
+
"Unexpected error in beforeFieldResolve hook"
|
|
1308
|
+
);
|
|
1309
|
+
exeContext.errors.push(error);
|
|
1245
1310
|
}
|
|
1311
|
+
return result;
|
|
1246
1312
|
}
|
|
1247
1313
|
);
|
|
1248
1314
|
}
|
|
@@ -1260,7 +1326,7 @@ function invokeAfterFieldResolveHook(resolveInfo, exeContext, hookContext, resul
|
|
|
1260
1326
|
result,
|
|
1261
1327
|
error
|
|
1262
1328
|
}),
|
|
1263
|
-
(
|
|
1329
|
+
(result2, rawError) => {
|
|
1264
1330
|
if (rawError) {
|
|
1265
1331
|
const error2 = toGraphQLError(
|
|
1266
1332
|
rawError,
|
|
@@ -1268,7 +1334,52 @@ function invokeAfterFieldResolveHook(resolveInfo, exeContext, hookContext, resul
|
|
|
1268
1334
|
"Unexpected error in afterFieldResolve hook"
|
|
1269
1335
|
);
|
|
1270
1336
|
exeContext.errors.push(error2);
|
|
1337
|
+
return error2;
|
|
1338
|
+
} else if (result2 instanceof Error) {
|
|
1339
|
+
const error2 = toGraphQLError(
|
|
1340
|
+
result2,
|
|
1341
|
+
resolveInfo.path,
|
|
1342
|
+
"Unexpected error in afterFieldResolve hook"
|
|
1343
|
+
);
|
|
1344
|
+
exeContext.errors.push(error2);
|
|
1345
|
+
}
|
|
1346
|
+
return result2;
|
|
1347
|
+
}
|
|
1348
|
+
);
|
|
1349
|
+
}
|
|
1350
|
+
function invokeAfterFieldSubscribeHook(resolveInfo, exeContext, hookContext, result, error) {
|
|
1351
|
+
var _a;
|
|
1352
|
+
const hook = (_a = exeContext.fieldExecutionHooks) == null ? void 0 : _a.afterFieldSubscribe;
|
|
1353
|
+
if (!hook) {
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
return executeSafe(
|
|
1357
|
+
() => hook({
|
|
1358
|
+
resolveInfo,
|
|
1359
|
+
context: exeContext.contextValue,
|
|
1360
|
+
hookContext,
|
|
1361
|
+
result,
|
|
1362
|
+
error
|
|
1363
|
+
}),
|
|
1364
|
+
(result2, rawError) => {
|
|
1365
|
+
if (rawError) {
|
|
1366
|
+
const error2 = toGraphQLError(
|
|
1367
|
+
rawError,
|
|
1368
|
+
resolveInfo.path,
|
|
1369
|
+
"Unexpected error in afterFieldSubscribe hook"
|
|
1370
|
+
);
|
|
1371
|
+
exeContext.errors.push(error2);
|
|
1372
|
+
return error2;
|
|
1373
|
+
} else if (result2 instanceof Error) {
|
|
1374
|
+
const error2 = toGraphQLError(
|
|
1375
|
+
result2,
|
|
1376
|
+
resolveInfo.path,
|
|
1377
|
+
"Unexpected error in afterFieldSubscribe hook"
|
|
1378
|
+
);
|
|
1379
|
+
exeContext.errors.push(error2);
|
|
1380
|
+
return error2;
|
|
1271
1381
|
}
|
|
1382
|
+
return result2;
|
|
1272
1383
|
}
|
|
1273
1384
|
);
|
|
1274
1385
|
}
|
|
@@ -1278,7 +1389,7 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, hookContext, resu
|
|
|
1278
1389
|
if (!hook) {
|
|
1279
1390
|
return;
|
|
1280
1391
|
}
|
|
1281
|
-
executeSafe(
|
|
1392
|
+
return executeSafe(
|
|
1282
1393
|
() => hook({
|
|
1283
1394
|
resolveInfo,
|
|
1284
1395
|
context: exeContext.contextValue,
|
|
@@ -1286,7 +1397,7 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, hookContext, resu
|
|
|
1286
1397
|
result,
|
|
1287
1398
|
error
|
|
1288
1399
|
}),
|
|
1289
|
-
(
|
|
1400
|
+
(result2, rawError) => {
|
|
1290
1401
|
if (rawError) {
|
|
1291
1402
|
const error2 = toGraphQLError(
|
|
1292
1403
|
rawError,
|
|
@@ -1294,7 +1405,16 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, hookContext, resu
|
|
|
1294
1405
|
"Unexpected error in afterFieldComplete hook"
|
|
1295
1406
|
);
|
|
1296
1407
|
exeContext.errors.push(error2);
|
|
1408
|
+
return error2;
|
|
1409
|
+
} else if (result2 instanceof Error) {
|
|
1410
|
+
const error2 = toGraphQLError(
|
|
1411
|
+
result2,
|
|
1412
|
+
resolveInfo.path,
|
|
1413
|
+
"Unexpected error in afterFieldComplete hook"
|
|
1414
|
+
);
|
|
1415
|
+
exeContext.errors.push(error2);
|
|
1297
1416
|
}
|
|
1417
|
+
return result2;
|
|
1298
1418
|
}
|
|
1299
1419
|
);
|
|
1300
1420
|
}
|
|
@@ -1309,8 +1429,16 @@ function invokeBeforeOperationExecuteHook(exeContext) {
|
|
|
1309
1429
|
context: exeContext.contextValue,
|
|
1310
1430
|
operation: exeContext.operation
|
|
1311
1431
|
}),
|
|
1312
|
-
(
|
|
1432
|
+
(result, rawError) => {
|
|
1313
1433
|
if (rawError) {
|
|
1434
|
+
const error = toGraphQLError(
|
|
1435
|
+
rawError,
|
|
1436
|
+
void 0,
|
|
1437
|
+
"Unexpected error in beforeOperationExecute hook"
|
|
1438
|
+
);
|
|
1439
|
+
throw error;
|
|
1440
|
+
}
|
|
1441
|
+
if (result instanceof Error) {
|
|
1314
1442
|
const error = toGraphQLError(
|
|
1315
1443
|
rawError,
|
|
1316
1444
|
void 0,
|
|
@@ -1318,6 +1446,7 @@ function invokeBeforeOperationExecuteHook(exeContext) {
|
|
|
1318
1446
|
);
|
|
1319
1447
|
exeContext.errors.push(error);
|
|
1320
1448
|
}
|
|
1449
|
+
return result;
|
|
1321
1450
|
}
|
|
1322
1451
|
);
|
|
1323
1452
|
}
|
|
@@ -1333,7 +1462,7 @@ function invokeBeforeSubscriptionEventEmitHook(exeContext, eventPayload) {
|
|
|
1333
1462
|
operation: exeContext.operation,
|
|
1334
1463
|
eventPayload
|
|
1335
1464
|
}),
|
|
1336
|
-
(
|
|
1465
|
+
(result, rawError) => {
|
|
1337
1466
|
if (rawError) {
|
|
1338
1467
|
const error = toGraphQLError(
|
|
1339
1468
|
rawError,
|
|
@@ -1341,7 +1470,16 @@ function invokeBeforeSubscriptionEventEmitHook(exeContext, eventPayload) {
|
|
|
1341
1470
|
"Unexpected error in beforeSubscriptionEventEmit hook"
|
|
1342
1471
|
);
|
|
1343
1472
|
exeContext.errors.push(error);
|
|
1473
|
+
return error;
|
|
1474
|
+
} else if (result instanceof Error) {
|
|
1475
|
+
const error = toGraphQLError(
|
|
1476
|
+
result,
|
|
1477
|
+
void 0,
|
|
1478
|
+
"Unexpected error in beforeSubscriptionEventEmit hook"
|
|
1479
|
+
);
|
|
1480
|
+
exeContext.errors.push(error);
|
|
1344
1481
|
}
|
|
1482
|
+
return result;
|
|
1345
1483
|
}
|
|
1346
1484
|
);
|
|
1347
1485
|
}
|
|
@@ -1376,20 +1514,14 @@ function executeSafe(execute, onComplete) {
|
|
|
1376
1514
|
result = execute();
|
|
1377
1515
|
} catch (e) {
|
|
1378
1516
|
error = e;
|
|
1379
|
-
} finally {
|
|
1380
|
-
if (!isPromise(result)) {
|
|
1381
|
-
onComplete(result, error);
|
|
1382
|
-
}
|
|
1383
1517
|
}
|
|
1384
1518
|
if (!isPromise(result)) {
|
|
1385
|
-
return result;
|
|
1519
|
+
return onComplete(result, error);
|
|
1386
1520
|
}
|
|
1387
1521
|
return result.then((hookResult) => {
|
|
1388
|
-
onComplete(hookResult, error);
|
|
1389
|
-
return hookResult;
|
|
1522
|
+
return onComplete(hookResult, error);
|
|
1390
1523
|
}).catch((e) => {
|
|
1391
|
-
onComplete(void 0, e);
|
|
1392
|
-
return void 0;
|
|
1524
|
+
return onComplete(void 0, e);
|
|
1393
1525
|
});
|
|
1394
1526
|
}
|
|
1395
1527
|
function toGraphQLError(originalError, path, prependMessage) {
|