@graphitation/supermassive 3.8.0-alpha.3 → 3.8.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/.eslintcache +1 -1
- package/CHANGELOG.md +5 -5
- package/hooks.md +64 -0
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +132 -70
- package/lib/executeWithoutSchema.js.map +2 -2
- package/lib/executeWithoutSchema.mjs +132 -70
- package/lib/executeWithoutSchema.mjs.map +2 -2
- package/lib/hooks/types.d.ts +69 -9
- package/lib/hooks/types.d.ts.map +1 -1
- package/lib/hooks/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -178,12 +178,20 @@ function buildPerEventExecutionContext(exeContext, payload) {
|
|
|
178
178
|
}
|
|
179
179
|
function executeOperationWithBeforeHook(exeContext) {
|
|
180
180
|
const hooks = exeContext.fieldExecutionHooks;
|
|
181
|
-
let
|
|
181
|
+
let hookResultPromise;
|
|
182
182
|
if (hooks == null ? void 0 : hooks.beforeOperationExecute) {
|
|
183
|
-
|
|
183
|
+
hookResultPromise = invokeBeforeOperationExecuteHook(exeContext);
|
|
184
184
|
}
|
|
185
|
-
if (
|
|
186
|
-
return
|
|
185
|
+
if (hookResultPromise instanceof GraphQLError) {
|
|
186
|
+
return buildResponse(exeContext, null);
|
|
187
|
+
}
|
|
188
|
+
if (isPromise(hookResultPromise)) {
|
|
189
|
+
return hookResultPromise.then((hookResult) => {
|
|
190
|
+
if (hookResult instanceof GraphQLError) {
|
|
191
|
+
return buildResponse(exeContext, null);
|
|
192
|
+
}
|
|
193
|
+
return executeOperation(exeContext);
|
|
194
|
+
});
|
|
187
195
|
}
|
|
188
196
|
return executeOperation(exeContext);
|
|
189
197
|
}
|
|
@@ -433,6 +441,17 @@ function createSourceEventStream(exeContext) {
|
|
|
433
441
|
return { errors: [error] };
|
|
434
442
|
}
|
|
435
443
|
}
|
|
444
|
+
function afterFieldSubscribeHandle(resolved, isDefaultResolverUsed, exeContext, info, hookContext, afterFieldSubscribe, error) {
|
|
445
|
+
if (!isDefaultResolverUsed && afterFieldSubscribe) {
|
|
446
|
+
hookContext = invokeAfterFieldSubscribeHook(
|
|
447
|
+
info,
|
|
448
|
+
exeContext,
|
|
449
|
+
hookContext,
|
|
450
|
+
resolved,
|
|
451
|
+
error
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
436
455
|
function executeSubscriptionImpl(exeContext) {
|
|
437
456
|
var _a;
|
|
438
457
|
const { operation, rootValue, schemaFragment } = exeContext;
|
|
@@ -491,28 +510,39 @@ function executeSubscriptionImpl(exeContext) {
|
|
|
491
510
|
if (result === void 0) {
|
|
492
511
|
result = resolveFn(rootValue, args, contextValue, info);
|
|
493
512
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
513
|
+
if (isPromise(result)) {
|
|
514
|
+
return result.then(assertEventStream, (error) => {
|
|
515
|
+
afterFieldSubscribeHandle(
|
|
516
|
+
void 0,
|
|
517
|
+
isDefaultResolverUsed,
|
|
498
518
|
exeContext,
|
|
519
|
+
info,
|
|
499
520
|
hookContext,
|
|
500
|
-
|
|
521
|
+
!!(hooks == null ? void 0 : hooks.afterFieldSubscribe),
|
|
501
522
|
error
|
|
502
523
|
);
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
if (isPromise(result)) {
|
|
506
|
-
return result.then(assertEventStream, (error) => {
|
|
507
|
-
afterFieldSubscribeHandle(void 0, error);
|
|
508
524
|
throw locatedError(error, fieldGroup, pathToArray(path));
|
|
509
525
|
}).then((resolved) => {
|
|
510
|
-
afterFieldSubscribeHandle(
|
|
526
|
+
afterFieldSubscribeHandle(
|
|
527
|
+
resolved,
|
|
528
|
+
isDefaultResolverUsed,
|
|
529
|
+
exeContext,
|
|
530
|
+
info,
|
|
531
|
+
hookContext,
|
|
532
|
+
!!(hooks == null ? void 0 : hooks.afterFieldSubscribe)
|
|
533
|
+
);
|
|
511
534
|
return resolved;
|
|
512
535
|
});
|
|
513
536
|
}
|
|
514
537
|
const stream = assertEventStream(result);
|
|
515
|
-
afterFieldSubscribeHandle(
|
|
538
|
+
afterFieldSubscribeHandle(
|
|
539
|
+
stream,
|
|
540
|
+
isDefaultResolverUsed,
|
|
541
|
+
exeContext,
|
|
542
|
+
info,
|
|
543
|
+
hookContext,
|
|
544
|
+
!!(hooks == null ? void 0 : hooks.afterFieldSubscribe)
|
|
545
|
+
);
|
|
516
546
|
return stream;
|
|
517
547
|
} catch (error) {
|
|
518
548
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldSubscribe)) {
|
|
@@ -661,20 +691,19 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
661
691
|
result = resolveFn(source, args, contextValue, info);
|
|
662
692
|
}
|
|
663
693
|
let completed;
|
|
664
|
-
const handleAfterFieldHooks = (hook, useHook) => (resolved, error) => {
|
|
665
|
-
if (!isDefaultResolverUsed && useHook) {
|
|
666
|
-
hookContext = hook(info, exeContext, hookContext, resolved, error);
|
|
667
|
-
return hookContext instanceof GraphQLError ? null : resolved;
|
|
668
|
-
}
|
|
669
|
-
return resolved;
|
|
670
|
-
};
|
|
671
694
|
if (isPromise(result)) {
|
|
672
|
-
completed = result.then(
|
|
673
|
-
|
|
674
|
-
invokeAfterFieldResolveHook
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
695
|
+
completed = result.then((resolved) => {
|
|
696
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
|
|
697
|
+
hookContext = invokeAfterFieldResolveHook(
|
|
698
|
+
info,
|
|
699
|
+
exeContext,
|
|
700
|
+
hookContext,
|
|
701
|
+
resolved
|
|
702
|
+
);
|
|
703
|
+
return hookContext instanceof GraphQLError ? null : resolved;
|
|
704
|
+
}
|
|
705
|
+
return resolved;
|
|
706
|
+
}).then(
|
|
678
707
|
(resolved) => {
|
|
679
708
|
return completeValue(
|
|
680
709
|
exeContext,
|
|
@@ -687,18 +716,28 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
687
716
|
);
|
|
688
717
|
},
|
|
689
718
|
(rawError) => {
|
|
690
|
-
|
|
691
|
-
invokeAfterFieldResolveHook
|
|
692
|
-
|
|
693
|
-
|
|
719
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
|
|
720
|
+
hookContext = invokeAfterFieldResolveHook(
|
|
721
|
+
info,
|
|
722
|
+
exeContext,
|
|
723
|
+
hookContext,
|
|
724
|
+
void 0,
|
|
725
|
+
rawError
|
|
726
|
+
);
|
|
727
|
+
}
|
|
694
728
|
throw rawError;
|
|
695
729
|
}
|
|
696
730
|
);
|
|
697
731
|
} else {
|
|
698
|
-
|
|
699
|
-
invokeAfterFieldResolveHook
|
|
700
|
-
|
|
701
|
-
|
|
732
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
|
|
733
|
+
hookContext = invokeAfterFieldResolveHook(
|
|
734
|
+
info,
|
|
735
|
+
exeContext,
|
|
736
|
+
hookContext,
|
|
737
|
+
result
|
|
738
|
+
);
|
|
739
|
+
result = hookContext instanceof GraphQLError ? null : result;
|
|
740
|
+
}
|
|
702
741
|
completed = completeValue(
|
|
703
742
|
exeContext,
|
|
704
743
|
returnTypeRef,
|
|
@@ -711,16 +750,29 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
711
750
|
}
|
|
712
751
|
if (isPromise(completed)) {
|
|
713
752
|
return completed.then(
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
753
|
+
(resolved) => {
|
|
754
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
755
|
+
hookContext = invokeAfterFieldCompleteHook(
|
|
756
|
+
info,
|
|
757
|
+
exeContext,
|
|
758
|
+
hookContext,
|
|
759
|
+
resolved
|
|
760
|
+
);
|
|
761
|
+
return hookContext instanceof GraphQLError ? null : resolved;
|
|
762
|
+
}
|
|
763
|
+
return resolved;
|
|
764
|
+
},
|
|
718
765
|
(rawError) => {
|
|
719
766
|
const error = locatedError(rawError, fieldGroup, pathToArray(path));
|
|
720
|
-
|
|
721
|
-
invokeAfterFieldCompleteHook
|
|
722
|
-
|
|
723
|
-
|
|
767
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
768
|
+
hookContext = invokeAfterFieldCompleteHook(
|
|
769
|
+
info,
|
|
770
|
+
exeContext,
|
|
771
|
+
hookContext,
|
|
772
|
+
void 0,
|
|
773
|
+
error
|
|
774
|
+
);
|
|
775
|
+
}
|
|
724
776
|
handleFieldError(
|
|
725
777
|
rawError,
|
|
726
778
|
exeContext,
|
|
@@ -733,10 +785,16 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
733
785
|
}
|
|
734
786
|
);
|
|
735
787
|
}
|
|
736
|
-
|
|
737
|
-
invokeAfterFieldCompleteHook
|
|
738
|
-
|
|
739
|
-
|
|
788
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
789
|
+
hookContext = invokeAfterFieldCompleteHook(
|
|
790
|
+
info,
|
|
791
|
+
exeContext,
|
|
792
|
+
hookContext,
|
|
793
|
+
completed
|
|
794
|
+
);
|
|
795
|
+
return hookContext instanceof GraphQLError ? null : completed;
|
|
796
|
+
}
|
|
797
|
+
return completed;
|
|
740
798
|
} catch (rawError) {
|
|
741
799
|
const pathArray = pathToArray(path);
|
|
742
800
|
const error = locatedError(rawError, fieldGroup, pathArray);
|
|
@@ -750,16 +808,13 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
750
808
|
);
|
|
751
809
|
}
|
|
752
810
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
753
|
-
|
|
811
|
+
invokeAfterFieldCompleteHook(
|
|
754
812
|
info,
|
|
755
813
|
exeContext,
|
|
756
814
|
hookContext,
|
|
757
815
|
void 0,
|
|
758
816
|
error
|
|
759
817
|
);
|
|
760
|
-
if (invokeAfterFieldCompleteHookResult instanceof GraphQLError) {
|
|
761
|
-
return null;
|
|
762
|
-
}
|
|
763
818
|
}
|
|
764
819
|
handleFieldError(
|
|
765
820
|
rawError,
|
|
@@ -1248,7 +1303,7 @@ function invokeBeforeFieldSubscribeHook(resolveInfo, exeContext) {
|
|
|
1248
1303
|
const error = toGraphQLError(
|
|
1249
1304
|
rawError,
|
|
1250
1305
|
resolveInfo.path,
|
|
1251
|
-
"Unexpected error
|
|
1306
|
+
"Unexpected error thrown by beforeFieldSubscribe hook"
|
|
1252
1307
|
);
|
|
1253
1308
|
exeContext.errors.push(error);
|
|
1254
1309
|
throw error;
|
|
@@ -1256,7 +1311,7 @@ function invokeBeforeFieldSubscribeHook(resolveInfo, exeContext) {
|
|
|
1256
1311
|
const error = toGraphQLError(
|
|
1257
1312
|
result,
|
|
1258
1313
|
resolveInfo.path,
|
|
1259
|
-
"Unexpected error
|
|
1314
|
+
"Unexpected error returned from beforeFieldSubscribe hook"
|
|
1260
1315
|
);
|
|
1261
1316
|
exeContext.errors.push(error);
|
|
1262
1317
|
throw error;
|
|
@@ -1281,7 +1336,7 @@ function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
|
1281
1336
|
const error = toGraphQLError(
|
|
1282
1337
|
rawError,
|
|
1283
1338
|
resolveInfo.path,
|
|
1284
|
-
"Unexpected error
|
|
1339
|
+
"Unexpected error thrown by beforeFieldResolve hook"
|
|
1285
1340
|
);
|
|
1286
1341
|
exeContext.errors.push(error);
|
|
1287
1342
|
return error;
|
|
@@ -1289,7 +1344,7 @@ function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
|
1289
1344
|
const error = toGraphQLError(
|
|
1290
1345
|
result,
|
|
1291
1346
|
resolveInfo.path,
|
|
1292
|
-
"Unexpected error
|
|
1347
|
+
"Unexpected error returned from beforeFieldResolve hook"
|
|
1293
1348
|
);
|
|
1294
1349
|
exeContext.errors.push(error);
|
|
1295
1350
|
}
|
|
@@ -1316,7 +1371,7 @@ function invokeAfterFieldResolveHook(resolveInfo, exeContext, hookContext, resul
|
|
|
1316
1371
|
const error2 = toGraphQLError(
|
|
1317
1372
|
rawError,
|
|
1318
1373
|
resolveInfo.path,
|
|
1319
|
-
"Unexpected error
|
|
1374
|
+
"Unexpected error thrown by afterFieldResolve hook"
|
|
1320
1375
|
);
|
|
1321
1376
|
exeContext.errors.push(error2);
|
|
1322
1377
|
return error2;
|
|
@@ -1324,7 +1379,7 @@ function invokeAfterFieldResolveHook(resolveInfo, exeContext, hookContext, resul
|
|
|
1324
1379
|
const error2 = toGraphQLError(
|
|
1325
1380
|
result2,
|
|
1326
1381
|
resolveInfo.path,
|
|
1327
|
-
"Unexpected error
|
|
1382
|
+
"Unexpected error returned from afterFieldResolve hook"
|
|
1328
1383
|
);
|
|
1329
1384
|
exeContext.errors.push(error2);
|
|
1330
1385
|
}
|
|
@@ -1351,7 +1406,7 @@ function invokeAfterFieldSubscribeHook(resolveInfo, exeContext, hookContext, res
|
|
|
1351
1406
|
const error2 = toGraphQLError(
|
|
1352
1407
|
rawError,
|
|
1353
1408
|
resolveInfo.path,
|
|
1354
|
-
"Unexpected error
|
|
1409
|
+
"Unexpected error thrown by afterFieldSubscribe hook"
|
|
1355
1410
|
);
|
|
1356
1411
|
exeContext.errors.push(error2);
|
|
1357
1412
|
throw error2;
|
|
@@ -1359,7 +1414,7 @@ function invokeAfterFieldSubscribeHook(resolveInfo, exeContext, hookContext, res
|
|
|
1359
1414
|
const error2 = toGraphQLError(
|
|
1360
1415
|
result2,
|
|
1361
1416
|
resolveInfo.path,
|
|
1362
|
-
"Unexpected error
|
|
1417
|
+
"Unexpected error returned from afterFieldSubscribe hook"
|
|
1363
1418
|
);
|
|
1364
1419
|
exeContext.errors.push(error2);
|
|
1365
1420
|
throw error2;
|
|
@@ -1387,7 +1442,7 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, hookContext, resu
|
|
|
1387
1442
|
const error2 = toGraphQLError(
|
|
1388
1443
|
rawError,
|
|
1389
1444
|
resolveInfo.path,
|
|
1390
|
-
"Unexpected error
|
|
1445
|
+
"Unexpected error thrown by afterFieldComplete hook"
|
|
1391
1446
|
);
|
|
1392
1447
|
exeContext.errors.push(error2);
|
|
1393
1448
|
return error2;
|
|
@@ -1395,7 +1450,7 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, hookContext, resu
|
|
|
1395
1450
|
const error2 = toGraphQLError(
|
|
1396
1451
|
result2,
|
|
1397
1452
|
resolveInfo.path,
|
|
1398
|
-
"Unexpected error
|
|
1453
|
+
"Unexpected error returned from afterFieldComplete hook"
|
|
1399
1454
|
);
|
|
1400
1455
|
exeContext.errors.push(error2);
|
|
1401
1456
|
}
|
|
@@ -1415,19 +1470,22 @@ function invokeBeforeOperationExecuteHook(exeContext) {
|
|
|
1415
1470
|
operation: exeContext.operation
|
|
1416
1471
|
}),
|
|
1417
1472
|
(result, rawError) => {
|
|
1473
|
+
var _a2, _b;
|
|
1474
|
+
const operationName = (_b = (_a2 = exeContext.operation.name) == null ? void 0 : _a2.value) != null ? _b : "unknown";
|
|
1418
1475
|
if (rawError) {
|
|
1419
1476
|
const error = toGraphQLError(
|
|
1420
1477
|
rawError,
|
|
1421
1478
|
void 0,
|
|
1422
|
-
|
|
1479
|
+
`Unexpected error thrown by beforeOperationExecute hook (operation: ${operationName})`
|
|
1423
1480
|
);
|
|
1424
|
-
|
|
1481
|
+
exeContext.errors.push(error);
|
|
1482
|
+
return error;
|
|
1425
1483
|
}
|
|
1426
1484
|
if (result instanceof Error) {
|
|
1427
1485
|
const error = toGraphQLError(
|
|
1428
1486
|
result,
|
|
1429
1487
|
void 0,
|
|
1430
|
-
|
|
1488
|
+
`Unexpected error returned from beforeOperationExecute hook (operation: ${operationName})`
|
|
1431
1489
|
);
|
|
1432
1490
|
exeContext.errors.push(error);
|
|
1433
1491
|
}
|
|
@@ -1448,11 +1506,13 @@ function invokeBeforeSubscriptionEventEmitHook(exeContext, eventPayload) {
|
|
|
1448
1506
|
eventPayload
|
|
1449
1507
|
}),
|
|
1450
1508
|
(result, rawError) => {
|
|
1509
|
+
var _a2, _b;
|
|
1510
|
+
const operationName = (_b = (_a2 = exeContext.operation.name) == null ? void 0 : _a2.value) != null ? _b : "unknown";
|
|
1451
1511
|
if (rawError) {
|
|
1452
1512
|
const error = toGraphQLError(
|
|
1453
1513
|
rawError,
|
|
1454
1514
|
void 0,
|
|
1455
|
-
|
|
1515
|
+
`Unexpected error thrown by beforeSubscriptionEventEmit hook (operation: ${operationName})`
|
|
1456
1516
|
);
|
|
1457
1517
|
exeContext.errors.push(error);
|
|
1458
1518
|
return error;
|
|
@@ -1460,7 +1520,7 @@ function invokeBeforeSubscriptionEventEmitHook(exeContext, eventPayload) {
|
|
|
1460
1520
|
const error = toGraphQLError(
|
|
1461
1521
|
result,
|
|
1462
1522
|
void 0,
|
|
1463
|
-
|
|
1523
|
+
`Unexpected error returned from beforeSubscriptionEventEmit hook (operation: ${operationName})`
|
|
1464
1524
|
);
|
|
1465
1525
|
exeContext.errors.push(error);
|
|
1466
1526
|
}
|
|
@@ -1481,11 +1541,13 @@ function invokeAfterBuildResponseHook(exeContext, result) {
|
|
|
1481
1541
|
result
|
|
1482
1542
|
}),
|
|
1483
1543
|
(result2, rawError) => {
|
|
1544
|
+
var _a2, _b;
|
|
1545
|
+
const operationName = (_b = (_a2 = exeContext.operation.name) == null ? void 0 : _a2.value) != null ? _b : "unknown";
|
|
1484
1546
|
if (rawError) {
|
|
1485
1547
|
const error = toGraphQLError(
|
|
1486
1548
|
rawError,
|
|
1487
1549
|
void 0,
|
|
1488
|
-
|
|
1550
|
+
`Unexpected error thrown by afterBuildResponse hook (operation: ${operationName})`
|
|
1489
1551
|
);
|
|
1490
1552
|
exeContext.errors.push(error);
|
|
1491
1553
|
return error;
|
|
@@ -1493,7 +1555,7 @@ function invokeAfterBuildResponseHook(exeContext, result) {
|
|
|
1493
1555
|
const error = toGraphQLError(
|
|
1494
1556
|
result2,
|
|
1495
1557
|
void 0,
|
|
1496
|
-
|
|
1558
|
+
`Unexpected error returned from afterBuildResponse hook (operation: ${operationName})`
|
|
1497
1559
|
);
|
|
1498
1560
|
exeContext.errors.push(error);
|
|
1499
1561
|
}
|