@graphitation/supermassive 3.7.2 → 3.8.0-alpha.2
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/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";
|
|
@@ -469,53 +470,71 @@ function executeSubscriptionImpl(exeContext) {
|
|
|
469
470
|
try {
|
|
470
471
|
const args = getArgumentValues(exeContext, fieldDef, fieldGroup[0]);
|
|
471
472
|
const contextValue = exeContext.contextValue;
|
|
472
|
-
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.
|
|
473
|
-
hookContext =
|
|
473
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.beforeFieldSubscribe)) {
|
|
474
|
+
hookContext = invokeBeforeFieldSubscribeHook(info, exeContext);
|
|
474
475
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
476
|
+
let result;
|
|
477
|
+
if (hookContext) {
|
|
478
|
+
if (isPromise(hookContext)) {
|
|
479
|
+
result = hookContext.then((context) => {
|
|
480
|
+
hookContext = context;
|
|
481
|
+
if (hookContext instanceof GraphQLError) {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
return resolveFn(rootValue, args, contextValue, info);
|
|
485
|
+
});
|
|
486
|
+
} else if (hookContext instanceof GraphQLError) {
|
|
487
|
+
result = null;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if (result === void 0) {
|
|
491
|
+
result = resolveFn(rootValue, args, contextValue, info);
|
|
492
|
+
}
|
|
493
|
+
const afterFieldSubscribeHandle = (resolved, error) => {
|
|
494
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldSubscribe)) {
|
|
495
|
+
hookContext = invokeAfterFieldSubscribeHook(
|
|
496
|
+
info,
|
|
497
|
+
exeContext,
|
|
498
|
+
hookContext,
|
|
499
|
+
resolved,
|
|
500
|
+
error
|
|
501
|
+
);
|
|
502
|
+
if (hookContext instanceof GraphQLError) {
|
|
503
|
+
throw hookContext;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
};
|
|
479
507
|
if (isPromise(result)) {
|
|
480
508
|
return result.then(assertEventStream).then(
|
|
481
509
|
(resolved) => {
|
|
482
|
-
if (
|
|
483
|
-
|
|
510
|
+
if (resolved instanceof GraphQLError) {
|
|
511
|
+
throw resolved;
|
|
512
|
+
}
|
|
513
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldSubscribe)) {
|
|
514
|
+
hookContext = invokeAfterFieldSubscribeHook(
|
|
484
515
|
info,
|
|
485
516
|
exeContext,
|
|
486
517
|
hookContext,
|
|
487
518
|
resolved
|
|
488
519
|
);
|
|
520
|
+
if (hookContext instanceof GraphQLError) {
|
|
521
|
+
throw hookContext;
|
|
522
|
+
}
|
|
489
523
|
}
|
|
490
524
|
return resolved;
|
|
491
525
|
},
|
|
492
526
|
(error) => {
|
|
493
|
-
|
|
494
|
-
hookContext = invokeAfterFieldResolveHook(
|
|
495
|
-
info,
|
|
496
|
-
exeContext,
|
|
497
|
-
hookContext,
|
|
498
|
-
void 0,
|
|
499
|
-
error
|
|
500
|
-
);
|
|
501
|
-
}
|
|
527
|
+
afterFieldSubscribeHandle(void 0, error);
|
|
502
528
|
throw locatedError(error, fieldGroup, pathToArray(path));
|
|
503
529
|
}
|
|
504
530
|
);
|
|
505
531
|
}
|
|
506
532
|
const stream = assertEventStream(result);
|
|
507
|
-
|
|
508
|
-
hookContext = invokeAfterFieldResolveHook(
|
|
509
|
-
info,
|
|
510
|
-
exeContext,
|
|
511
|
-
hookContext,
|
|
512
|
-
stream
|
|
513
|
-
);
|
|
514
|
-
}
|
|
533
|
+
afterFieldSubscribeHandle(stream);
|
|
515
534
|
return stream;
|
|
516
535
|
} catch (error) {
|
|
517
|
-
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.
|
|
518
|
-
hookContext =
|
|
536
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldSubscribe)) {
|
|
537
|
+
hookContext = invokeAfterFieldSubscribeHook(
|
|
519
538
|
info,
|
|
520
539
|
exeContext,
|
|
521
540
|
hookContext,
|
|
@@ -523,6 +542,9 @@ function executeSubscriptionImpl(exeContext) {
|
|
|
523
542
|
error
|
|
524
543
|
);
|
|
525
544
|
}
|
|
545
|
+
if (hookContext instanceof GraphQLError) {
|
|
546
|
+
throw hookContext;
|
|
547
|
+
}
|
|
526
548
|
throw locatedError(error, fieldGroup, pathToArray(path));
|
|
527
549
|
}
|
|
528
550
|
}
|
|
@@ -559,25 +581,28 @@ function mapResultOrEventStreamOrPromise(resultOrStreamOrPromise, exeContext, pa
|
|
|
559
581
|
payload
|
|
560
582
|
);
|
|
561
583
|
const hooks = exeContext == null ? void 0 : exeContext.fieldExecutionHooks;
|
|
562
|
-
let
|
|
584
|
+
let beforeExecuteSubscriptionEvenEmitHook;
|
|
563
585
|
if (hooks == null ? void 0 : hooks.beforeSubscriptionEventEmit) {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
586
|
+
beforeExecuteSubscriptionEvenEmitHook = invokeBeforeSubscriptionEventEmitHook(perEventContext, payload);
|
|
587
|
+
if (beforeExecuteSubscriptionEvenEmitHook instanceof GraphQLError) {
|
|
588
|
+
return buildResponse(perEventContext, null);
|
|
589
|
+
}
|
|
568
590
|
}
|
|
569
591
|
try {
|
|
570
|
-
const data = isPromise(
|
|
571
|
-
()
|
|
572
|
-
|
|
592
|
+
const data = isPromise(beforeExecuteSubscriptionEvenEmitHook) ? beforeExecuteSubscriptionEvenEmitHook.then((context) => {
|
|
593
|
+
if (context instanceof GraphQLError) {
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
return executeFields(
|
|
597
|
+
perEventContext,
|
|
573
598
|
parentTypeName,
|
|
574
599
|
payload,
|
|
575
600
|
path,
|
|
576
601
|
groupedFieldSet,
|
|
577
602
|
void 0
|
|
578
|
-
)
|
|
579
|
-
) : executeFields(
|
|
580
|
-
|
|
603
|
+
);
|
|
604
|
+
}) : executeFields(
|
|
605
|
+
perEventContext,
|
|
581
606
|
parentTypeName,
|
|
582
607
|
payload,
|
|
583
608
|
path,
|
|
@@ -642,54 +667,59 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
642
667
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.beforeFieldResolve)) {
|
|
643
668
|
hookContext = invokeBeforeFieldResolveHook(info, exeContext);
|
|
644
669
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
}
|
|
670
|
+
let result;
|
|
671
|
+
if (hookContext instanceof GraphQLError) {
|
|
672
|
+
result = null;
|
|
673
|
+
} else if (isPromise(hookContext)) {
|
|
674
|
+
result = hookContext.then((context) => {
|
|
675
|
+
hookContext = context;
|
|
676
|
+
if (hookContext instanceof GraphQLError) {
|
|
677
|
+
return null;
|
|
678
|
+
}
|
|
679
|
+
return resolveFn(source, args, contextValue, info);
|
|
680
|
+
});
|
|
681
|
+
} else {
|
|
682
|
+
result = resolveFn(source, args, contextValue, info);
|
|
683
|
+
}
|
|
649
684
|
let completed;
|
|
685
|
+
const handleAfterFieldHooks = (hook, useHook) => (resolved, error) => {
|
|
686
|
+
if (!isDefaultResolverUsed && useHook) {
|
|
687
|
+
hookContext = hook(info, exeContext, hookContext, resolved, error);
|
|
688
|
+
return hookContext instanceof GraphQLError ? null : resolved;
|
|
689
|
+
}
|
|
690
|
+
return resolved;
|
|
691
|
+
};
|
|
650
692
|
if (isPromise(result)) {
|
|
651
693
|
completed = result.then(
|
|
694
|
+
handleAfterFieldHooks(
|
|
695
|
+
invokeAfterFieldResolveHook,
|
|
696
|
+
!!(hooks == null ? void 0 : hooks.afterFieldResolve)
|
|
697
|
+
)
|
|
698
|
+
).then(
|
|
652
699
|
(resolved) => {
|
|
653
|
-
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
|
|
654
|
-
hookContext = invokeAfterFieldResolveHook(
|
|
655
|
-
info,
|
|
656
|
-
exeContext,
|
|
657
|
-
hookContext,
|
|
658
|
-
resolved
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
700
|
return completeValue(
|
|
662
701
|
exeContext,
|
|
663
702
|
returnTypeRef,
|
|
664
703
|
fieldGroup,
|
|
665
704
|
info,
|
|
666
705
|
path,
|
|
667
|
-
resolved,
|
|
706
|
+
hookContext instanceof GraphQLError ? null : resolved,
|
|
668
707
|
incrementalDataRecord
|
|
669
708
|
);
|
|
670
709
|
},
|
|
671
710
|
(rawError) => {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
hookContext,
|
|
677
|
-
void 0,
|
|
678
|
-
rawError
|
|
679
|
-
);
|
|
680
|
-
}
|
|
711
|
+
handleAfterFieldHooks(
|
|
712
|
+
invokeAfterFieldResolveHook,
|
|
713
|
+
!!(hooks == null ? void 0 : hooks.afterFieldResolve)
|
|
714
|
+
)(void 0, rawError);
|
|
681
715
|
throw rawError;
|
|
682
716
|
}
|
|
683
717
|
);
|
|
684
718
|
} else {
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
hookContext,
|
|
690
|
-
result
|
|
691
|
-
);
|
|
692
|
-
}
|
|
719
|
+
result = handleAfterFieldHooks(
|
|
720
|
+
invokeAfterFieldResolveHook,
|
|
721
|
+
!!(hooks == null ? void 0 : hooks.afterFieldResolve)
|
|
722
|
+
)(result);
|
|
693
723
|
completed = completeValue(
|
|
694
724
|
exeContext,
|
|
695
725
|
returnTypeRef,
|
|
@@ -702,27 +732,18 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
702
732
|
}
|
|
703
733
|
if (isPromise(completed)) {
|
|
704
734
|
return completed.then(
|
|
705
|
-
(
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
exeContext,
|
|
710
|
-
hookContext,
|
|
711
|
-
resolved
|
|
712
|
-
);
|
|
713
|
-
}
|
|
714
|
-
return resolved;
|
|
715
|
-
},
|
|
735
|
+
handleAfterFieldHooks(
|
|
736
|
+
invokeAfterFieldCompleteHook,
|
|
737
|
+
!!(hooks == null ? void 0 : hooks.afterFieldComplete)
|
|
738
|
+
),
|
|
716
739
|
(rawError) => {
|
|
717
740
|
const error = locatedError(rawError, fieldGroup, pathToArray(path));
|
|
718
|
-
|
|
719
|
-
invokeAfterFieldCompleteHook
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
error
|
|
725
|
-
);
|
|
741
|
+
const hookResult = handleAfterFieldHooks(
|
|
742
|
+
invokeAfterFieldCompleteHook,
|
|
743
|
+
!!(hooks == null ? void 0 : hooks.afterFieldComplete)
|
|
744
|
+
)(void 0, error);
|
|
745
|
+
if (hookResult === null) {
|
|
746
|
+
return null;
|
|
726
747
|
}
|
|
727
748
|
handleFieldError(
|
|
728
749
|
rawError,
|
|
@@ -736,10 +757,10 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
736
757
|
}
|
|
737
758
|
);
|
|
738
759
|
}
|
|
739
|
-
|
|
740
|
-
invokeAfterFieldCompleteHook
|
|
741
|
-
|
|
742
|
-
|
|
760
|
+
return handleAfterFieldHooks(
|
|
761
|
+
invokeAfterFieldCompleteHook,
|
|
762
|
+
!!(hooks == null ? void 0 : hooks.afterFieldComplete)
|
|
763
|
+
)(completed);
|
|
743
764
|
} catch (rawError) {
|
|
744
765
|
const pathArray = pathToArray(path);
|
|
745
766
|
const error = locatedError(rawError, fieldGroup, pathArray);
|
|
@@ -753,13 +774,16 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
753
774
|
);
|
|
754
775
|
}
|
|
755
776
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
756
|
-
invokeAfterFieldCompleteHook(
|
|
777
|
+
const invokeAfterFieldCompleteHookResult = invokeAfterFieldCompleteHook(
|
|
757
778
|
info,
|
|
758
779
|
exeContext,
|
|
759
780
|
hookContext,
|
|
760
781
|
void 0,
|
|
761
782
|
error
|
|
762
783
|
);
|
|
784
|
+
if (invokeAfterFieldCompleteHookResult instanceof GraphQLError) {
|
|
785
|
+
return null;
|
|
786
|
+
}
|
|
763
787
|
}
|
|
764
788
|
handleFieldError(
|
|
765
789
|
rawError,
|
|
@@ -1232,6 +1256,39 @@ function collectAndExecuteSubfields(exeContext, returnTypeName, fieldGroup, path
|
|
|
1232
1256
|
}
|
|
1233
1257
|
return subFields;
|
|
1234
1258
|
}
|
|
1259
|
+
function invokeBeforeFieldSubscribeHook(resolveInfo, exeContext) {
|
|
1260
|
+
var _a;
|
|
1261
|
+
const hook = (_a = exeContext.fieldExecutionHooks) == null ? void 0 : _a.beforeFieldSubscribe;
|
|
1262
|
+
if (!hook) {
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
return executeSafe(
|
|
1266
|
+
() => hook({
|
|
1267
|
+
resolveInfo,
|
|
1268
|
+
context: exeContext.contextValue
|
|
1269
|
+
}),
|
|
1270
|
+
(result, rawError) => {
|
|
1271
|
+
if (rawError) {
|
|
1272
|
+
const error = toGraphQLError(
|
|
1273
|
+
rawError,
|
|
1274
|
+
resolveInfo.path,
|
|
1275
|
+
"Unexpected error in beforeFieldSubscribe hook"
|
|
1276
|
+
);
|
|
1277
|
+
exeContext.errors.push(error);
|
|
1278
|
+
return error;
|
|
1279
|
+
} else if (result instanceof Error) {
|
|
1280
|
+
const error = toGraphQLError(
|
|
1281
|
+
result,
|
|
1282
|
+
resolveInfo.path,
|
|
1283
|
+
"Unexpected error in beforeFieldSubscribe hook"
|
|
1284
|
+
);
|
|
1285
|
+
exeContext.errors.push(error);
|
|
1286
|
+
return error;
|
|
1287
|
+
}
|
|
1288
|
+
return result;
|
|
1289
|
+
}
|
|
1290
|
+
);
|
|
1291
|
+
}
|
|
1235
1292
|
function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
1236
1293
|
var _a;
|
|
1237
1294
|
const hook = (_a = exeContext.fieldExecutionHooks) == null ? void 0 : _a.beforeFieldResolve;
|
|
@@ -1243,7 +1300,7 @@ function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
|
1243
1300
|
resolveInfo,
|
|
1244
1301
|
context: exeContext.contextValue
|
|
1245
1302
|
}),
|
|
1246
|
-
(
|
|
1303
|
+
(result, rawError) => {
|
|
1247
1304
|
if (rawError) {
|
|
1248
1305
|
const error = toGraphQLError(
|
|
1249
1306
|
rawError,
|
|
@@ -1251,7 +1308,16 @@ function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
|
1251
1308
|
"Unexpected error in beforeFieldResolve hook"
|
|
1252
1309
|
);
|
|
1253
1310
|
exeContext.errors.push(error);
|
|
1311
|
+
return error;
|
|
1312
|
+
} else if (result instanceof Error) {
|
|
1313
|
+
const error = toGraphQLError(
|
|
1314
|
+
result,
|
|
1315
|
+
resolveInfo.path,
|
|
1316
|
+
"Unexpected error in beforeFieldResolve hook"
|
|
1317
|
+
);
|
|
1318
|
+
exeContext.errors.push(error);
|
|
1254
1319
|
}
|
|
1320
|
+
return result;
|
|
1255
1321
|
}
|
|
1256
1322
|
);
|
|
1257
1323
|
}
|
|
@@ -1269,7 +1335,7 @@ function invokeAfterFieldResolveHook(resolveInfo, exeContext, hookContext, resul
|
|
|
1269
1335
|
result,
|
|
1270
1336
|
error
|
|
1271
1337
|
}),
|
|
1272
|
-
(
|
|
1338
|
+
(result2, rawError) => {
|
|
1273
1339
|
if (rawError) {
|
|
1274
1340
|
const error2 = toGraphQLError(
|
|
1275
1341
|
rawError,
|
|
@@ -1277,7 +1343,52 @@ function invokeAfterFieldResolveHook(resolveInfo, exeContext, hookContext, resul
|
|
|
1277
1343
|
"Unexpected error in afterFieldResolve hook"
|
|
1278
1344
|
);
|
|
1279
1345
|
exeContext.errors.push(error2);
|
|
1346
|
+
return error2;
|
|
1347
|
+
} else if (result2 instanceof Error) {
|
|
1348
|
+
const error2 = toGraphQLError(
|
|
1349
|
+
result2,
|
|
1350
|
+
resolveInfo.path,
|
|
1351
|
+
"Unexpected error in afterFieldResolve hook"
|
|
1352
|
+
);
|
|
1353
|
+
exeContext.errors.push(error2);
|
|
1354
|
+
}
|
|
1355
|
+
return result2;
|
|
1356
|
+
}
|
|
1357
|
+
);
|
|
1358
|
+
}
|
|
1359
|
+
function invokeAfterFieldSubscribeHook(resolveInfo, exeContext, hookContext, result, error) {
|
|
1360
|
+
var _a;
|
|
1361
|
+
const hook = (_a = exeContext.fieldExecutionHooks) == null ? void 0 : _a.afterFieldSubscribe;
|
|
1362
|
+
if (!hook) {
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
return executeSafe(
|
|
1366
|
+
() => hook({
|
|
1367
|
+
resolveInfo,
|
|
1368
|
+
context: exeContext.contextValue,
|
|
1369
|
+
hookContext,
|
|
1370
|
+
result,
|
|
1371
|
+
error
|
|
1372
|
+
}),
|
|
1373
|
+
(result2, rawError) => {
|
|
1374
|
+
if (rawError) {
|
|
1375
|
+
const error2 = toGraphQLError(
|
|
1376
|
+
rawError,
|
|
1377
|
+
resolveInfo.path,
|
|
1378
|
+
"Unexpected error in afterFieldSubscribe hook"
|
|
1379
|
+
);
|
|
1380
|
+
exeContext.errors.push(error2);
|
|
1381
|
+
return error2;
|
|
1382
|
+
} else if (result2 instanceof Error) {
|
|
1383
|
+
const error2 = toGraphQLError(
|
|
1384
|
+
result2,
|
|
1385
|
+
resolveInfo.path,
|
|
1386
|
+
"Unexpected error in afterFieldSubscribe hook"
|
|
1387
|
+
);
|
|
1388
|
+
exeContext.errors.push(error2);
|
|
1389
|
+
return error2;
|
|
1280
1390
|
}
|
|
1391
|
+
return result2;
|
|
1281
1392
|
}
|
|
1282
1393
|
);
|
|
1283
1394
|
}
|
|
@@ -1287,7 +1398,7 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, hookContext, resu
|
|
|
1287
1398
|
if (!hook) {
|
|
1288
1399
|
return;
|
|
1289
1400
|
}
|
|
1290
|
-
executeSafe(
|
|
1401
|
+
return executeSafe(
|
|
1291
1402
|
() => hook({
|
|
1292
1403
|
resolveInfo,
|
|
1293
1404
|
context: exeContext.contextValue,
|
|
@@ -1295,7 +1406,7 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, hookContext, resu
|
|
|
1295
1406
|
result,
|
|
1296
1407
|
error
|
|
1297
1408
|
}),
|
|
1298
|
-
(
|
|
1409
|
+
(result2, rawError) => {
|
|
1299
1410
|
if (rawError) {
|
|
1300
1411
|
const error2 = toGraphQLError(
|
|
1301
1412
|
rawError,
|
|
@@ -1303,7 +1414,16 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, hookContext, resu
|
|
|
1303
1414
|
"Unexpected error in afterFieldComplete hook"
|
|
1304
1415
|
);
|
|
1305
1416
|
exeContext.errors.push(error2);
|
|
1417
|
+
return error2;
|
|
1418
|
+
} else if (result2 instanceof Error) {
|
|
1419
|
+
const error2 = toGraphQLError(
|
|
1420
|
+
result2,
|
|
1421
|
+
resolveInfo.path,
|
|
1422
|
+
"Unexpected error in afterFieldComplete hook"
|
|
1423
|
+
);
|
|
1424
|
+
exeContext.errors.push(error2);
|
|
1306
1425
|
}
|
|
1426
|
+
return result2;
|
|
1307
1427
|
}
|
|
1308
1428
|
);
|
|
1309
1429
|
}
|
|
@@ -1318,8 +1438,16 @@ function invokeBeforeOperationExecuteHook(exeContext) {
|
|
|
1318
1438
|
context: exeContext.contextValue,
|
|
1319
1439
|
operation: exeContext.operation
|
|
1320
1440
|
}),
|
|
1321
|
-
(
|
|
1441
|
+
(result, rawError) => {
|
|
1322
1442
|
if (rawError) {
|
|
1443
|
+
const error = toGraphQLError(
|
|
1444
|
+
rawError,
|
|
1445
|
+
void 0,
|
|
1446
|
+
"Unexpected error in beforeOperationExecute hook"
|
|
1447
|
+
);
|
|
1448
|
+
throw error;
|
|
1449
|
+
}
|
|
1450
|
+
if (result instanceof Error) {
|
|
1323
1451
|
const error = toGraphQLError(
|
|
1324
1452
|
rawError,
|
|
1325
1453
|
void 0,
|
|
@@ -1327,6 +1455,7 @@ function invokeBeforeOperationExecuteHook(exeContext) {
|
|
|
1327
1455
|
);
|
|
1328
1456
|
exeContext.errors.push(error);
|
|
1329
1457
|
}
|
|
1458
|
+
return result;
|
|
1330
1459
|
}
|
|
1331
1460
|
);
|
|
1332
1461
|
}
|
|
@@ -1342,7 +1471,7 @@ function invokeBeforeSubscriptionEventEmitHook(exeContext, eventPayload) {
|
|
|
1342
1471
|
operation: exeContext.operation,
|
|
1343
1472
|
eventPayload
|
|
1344
1473
|
}),
|
|
1345
|
-
(
|
|
1474
|
+
(result, rawError) => {
|
|
1346
1475
|
if (rawError) {
|
|
1347
1476
|
const error = toGraphQLError(
|
|
1348
1477
|
rawError,
|
|
@@ -1350,7 +1479,16 @@ function invokeBeforeSubscriptionEventEmitHook(exeContext, eventPayload) {
|
|
|
1350
1479
|
"Unexpected error in beforeSubscriptionEventEmit hook"
|
|
1351
1480
|
);
|
|
1352
1481
|
exeContext.errors.push(error);
|
|
1482
|
+
return error;
|
|
1483
|
+
} else if (result instanceof Error) {
|
|
1484
|
+
const error = toGraphQLError(
|
|
1485
|
+
result,
|
|
1486
|
+
void 0,
|
|
1487
|
+
"Unexpected error in beforeSubscriptionEventEmit hook"
|
|
1488
|
+
);
|
|
1489
|
+
exeContext.errors.push(error);
|
|
1353
1490
|
}
|
|
1491
|
+
return result;
|
|
1354
1492
|
}
|
|
1355
1493
|
);
|
|
1356
1494
|
}
|
|
@@ -1385,20 +1523,14 @@ function executeSafe(execute, onComplete) {
|
|
|
1385
1523
|
result = execute();
|
|
1386
1524
|
} catch (e) {
|
|
1387
1525
|
error = e;
|
|
1388
|
-
} finally {
|
|
1389
|
-
if (!isPromise(result)) {
|
|
1390
|
-
onComplete(result, error);
|
|
1391
|
-
}
|
|
1392
1526
|
}
|
|
1393
1527
|
if (!isPromise(result)) {
|
|
1394
|
-
return result;
|
|
1528
|
+
return onComplete(result, error);
|
|
1395
1529
|
}
|
|
1396
1530
|
return result.then((hookResult) => {
|
|
1397
|
-
onComplete(hookResult, error);
|
|
1398
|
-
return hookResult;
|
|
1531
|
+
return onComplete(hookResult, error);
|
|
1399
1532
|
}).catch((e) => {
|
|
1400
|
-
onComplete(void 0, e);
|
|
1401
|
-
return void 0;
|
|
1533
|
+
return onComplete(void 0, e);
|
|
1402
1534
|
});
|
|
1403
1535
|
}
|
|
1404
1536
|
function toGraphQLError(originalError, path, prependMessage) {
|