@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
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# Change Log - @graphitation/supermassive
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Thu, 02 Jan 2025 12:43:33 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## 3.8.0
|
|
7
|
+
## 3.8.0
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Thu, 02 Jan 2025 12:43:33 GMT
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Minor changes
|
|
12
12
|
|
|
13
|
-
-
|
|
13
|
+
- Hooks error handling (77059398+vejrj@users.noreply.github.com)
|
|
14
14
|
|
|
15
15
|
## 3.7.2
|
|
16
16
|
|
package/hooks.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Hooks Documentation
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document describes the behaviour of hooks when they encounter errors.
|
|
6
|
+
|
|
7
|
+
## General Rule
|
|
8
|
+
|
|
9
|
+
- **Thrown Error**: Specific behaviour is applied based on the hook.
|
|
10
|
+
- **Returned Error**: The error is registered and execution continues.
|
|
11
|
+
|
|
12
|
+
### Hooks and Their Behaviours
|
|
13
|
+
|
|
14
|
+
#### `beforeOperationExecute`
|
|
15
|
+
|
|
16
|
+
Called before every operation
|
|
17
|
+
|
|
18
|
+
- **Thrown Error**: Stops execution and sets `data` to `null` and registers the error.
|
|
19
|
+
- **Returned Error**: The error is registered and execution continues.
|
|
20
|
+
|
|
21
|
+
#### `beforeSubscriptionEventEmit`
|
|
22
|
+
|
|
23
|
+
- **Thrown ErErrorror**: Sets `data` to `null` and registers the error.
|
|
24
|
+
- **Returned Error**: The error is registered and execution continues.
|
|
25
|
+
|
|
26
|
+
#### `beforeFieldResolve`
|
|
27
|
+
|
|
28
|
+
Called before every field resolution
|
|
29
|
+
|
|
30
|
+
- **Thrown Error**: The field is not executed and is handled as if it has returned `null`.
|
|
31
|
+
- **Returned Error**: The error is registered and execution continues.
|
|
32
|
+
|
|
33
|
+
#### `afterFieldResolve`
|
|
34
|
+
|
|
35
|
+
Called after every field resolution.
|
|
36
|
+
|
|
37
|
+
- **Thrown Error**: The field is set to `null` and the error is registered.
|
|
38
|
+
- **Returned Error**: The error is registered and execution continues.
|
|
39
|
+
|
|
40
|
+
#### `afterFieldComplete`
|
|
41
|
+
|
|
42
|
+
Called when field value is completed
|
|
43
|
+
|
|
44
|
+
- **Thrown Error**: The field is set to `null` and the error is registered.
|
|
45
|
+
- **Returned Error**: The error is registered and execution continues.
|
|
46
|
+
|
|
47
|
+
#### `afterBuildResponse`
|
|
48
|
+
|
|
49
|
+
- **Thrown Error**: Returns no data property, only errors.
|
|
50
|
+
- **Returned Error**: The error is registered and execution continues.
|
|
51
|
+
|
|
52
|
+
## Additional Hooks
|
|
53
|
+
|
|
54
|
+
### `beforeFieldSubscribe`
|
|
55
|
+
|
|
56
|
+
Called before subscription event stream creation
|
|
57
|
+
|
|
58
|
+
- **Thrown or Returned Error**: Stops execution and sets `data` is `undefined` and error is returned in `errors` field.
|
|
59
|
+
|
|
60
|
+
### `afterFieldSubscribe`
|
|
61
|
+
|
|
62
|
+
Called after subscription event stream creation
|
|
63
|
+
|
|
64
|
+
- **Thrown or Returned Error**: Stops execution and sets `data` is `undefined` and error is returned in `errors` field.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeWithoutSchema.d.ts","sourceRoot":"","sources":["../src/executeWithoutSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAIZ,YAAY,EACZ,sBAAsB,EACtB,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AACjB,OAAO,EAGL,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAOzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,KAAK,EACV,0BAA0B,EAC1B,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,oBAAoB,EAKpB,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,EAErB,MAAM,SAAS,CAAC;AAMjB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAgCpD;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,cAAc,CAAC;IAC/B,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC,sBAAsB,CAAC,CAAC;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;IACxD,SAAS,EAAE,uBAAuB,CAAC;IACnC,cAAc,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,O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AM,IAAI,0BAA0B,CAAC,KAAK,EAAE,WAAW,CAAC,CAE1D;AAED,wBAAgB,sBAAsB,CACpC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,EACvB,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,EAE7B,MAAM,EAAE,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC,GAC1C,MAAM,IAAI,oBAAoB,CAAC,KAAK,EAAE,WAAW,CAAC,CAEpD"}
|
|
@@ -197,12 +197,20 @@ function buildPerEventExecutionContext(exeContext, payload) {
|
|
|
197
197
|
}
|
|
198
198
|
function executeOperationWithBeforeHook(exeContext) {
|
|
199
199
|
const hooks = exeContext.fieldExecutionHooks;
|
|
200
|
-
let
|
|
200
|
+
let hookResultPromise;
|
|
201
201
|
if (hooks == null ? void 0 : hooks.beforeOperationExecute) {
|
|
202
|
-
|
|
202
|
+
hookResultPromise = invokeBeforeOperationExecuteHook(exeContext);
|
|
203
203
|
}
|
|
204
|
-
if (
|
|
205
|
-
return
|
|
204
|
+
if (hookResultPromise instanceof import_graphql.GraphQLError) {
|
|
205
|
+
return buildResponse(exeContext, null);
|
|
206
|
+
}
|
|
207
|
+
if ((0, import_isPromise.isPromise)(hookResultPromise)) {
|
|
208
|
+
return hookResultPromise.then((hookResult) => {
|
|
209
|
+
if (hookResult instanceof import_graphql.GraphQLError) {
|
|
210
|
+
return buildResponse(exeContext, null);
|
|
211
|
+
}
|
|
212
|
+
return executeOperation(exeContext);
|
|
213
|
+
});
|
|
206
214
|
}
|
|
207
215
|
return executeOperation(exeContext);
|
|
208
216
|
}
|
|
@@ -452,6 +460,17 @@ function createSourceEventStream(exeContext) {
|
|
|
452
460
|
return { errors: [error] };
|
|
453
461
|
}
|
|
454
462
|
}
|
|
463
|
+
function afterFieldSubscribeHandle(resolved, isDefaultResolverUsed, exeContext, info, hookContext, afterFieldSubscribe, error) {
|
|
464
|
+
if (!isDefaultResolverUsed && afterFieldSubscribe) {
|
|
465
|
+
hookContext = invokeAfterFieldSubscribeHook(
|
|
466
|
+
info,
|
|
467
|
+
exeContext,
|
|
468
|
+
hookContext,
|
|
469
|
+
resolved,
|
|
470
|
+
error
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
455
474
|
function executeSubscriptionImpl(exeContext) {
|
|
456
475
|
var _a;
|
|
457
476
|
const { operation, rootValue, schemaFragment } = exeContext;
|
|
@@ -510,28 +529,39 @@ function executeSubscriptionImpl(exeContext) {
|
|
|
510
529
|
if (result === void 0) {
|
|
511
530
|
result = resolveFn(rootValue, args, contextValue, info);
|
|
512
531
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
532
|
+
if ((0, import_isPromise.isPromise)(result)) {
|
|
533
|
+
return result.then(assertEventStream, (error) => {
|
|
534
|
+
afterFieldSubscribeHandle(
|
|
535
|
+
void 0,
|
|
536
|
+
isDefaultResolverUsed,
|
|
517
537
|
exeContext,
|
|
538
|
+
info,
|
|
518
539
|
hookContext,
|
|
519
|
-
|
|
540
|
+
!!(hooks == null ? void 0 : hooks.afterFieldSubscribe),
|
|
520
541
|
error
|
|
521
542
|
);
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
if ((0, import_isPromise.isPromise)(result)) {
|
|
525
|
-
return result.then(assertEventStream, (error) => {
|
|
526
|
-
afterFieldSubscribeHandle(void 0, error);
|
|
527
543
|
throw (0, import_graphql.locatedError)(error, fieldGroup, (0, import_Path.pathToArray)(path));
|
|
528
544
|
}).then((resolved) => {
|
|
529
|
-
afterFieldSubscribeHandle(
|
|
545
|
+
afterFieldSubscribeHandle(
|
|
546
|
+
resolved,
|
|
547
|
+
isDefaultResolverUsed,
|
|
548
|
+
exeContext,
|
|
549
|
+
info,
|
|
550
|
+
hookContext,
|
|
551
|
+
!!(hooks == null ? void 0 : hooks.afterFieldSubscribe)
|
|
552
|
+
);
|
|
530
553
|
return resolved;
|
|
531
554
|
});
|
|
532
555
|
}
|
|
533
556
|
const stream = assertEventStream(result);
|
|
534
|
-
afterFieldSubscribeHandle(
|
|
557
|
+
afterFieldSubscribeHandle(
|
|
558
|
+
stream,
|
|
559
|
+
isDefaultResolverUsed,
|
|
560
|
+
exeContext,
|
|
561
|
+
info,
|
|
562
|
+
hookContext,
|
|
563
|
+
!!(hooks == null ? void 0 : hooks.afterFieldSubscribe)
|
|
564
|
+
);
|
|
535
565
|
return stream;
|
|
536
566
|
} catch (error) {
|
|
537
567
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldSubscribe)) {
|
|
@@ -680,20 +710,19 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
680
710
|
result = resolveFn(source, args, contextValue, info);
|
|
681
711
|
}
|
|
682
712
|
let completed;
|
|
683
|
-
const handleAfterFieldHooks = (hook, useHook) => (resolved, error) => {
|
|
684
|
-
if (!isDefaultResolverUsed && useHook) {
|
|
685
|
-
hookContext = hook(info, exeContext, hookContext, resolved, error);
|
|
686
|
-
return hookContext instanceof import_graphql.GraphQLError ? null : resolved;
|
|
687
|
-
}
|
|
688
|
-
return resolved;
|
|
689
|
-
};
|
|
690
713
|
if ((0, import_isPromise.isPromise)(result)) {
|
|
691
|
-
completed = result.then(
|
|
692
|
-
|
|
693
|
-
invokeAfterFieldResolveHook
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
714
|
+
completed = result.then((resolved) => {
|
|
715
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
|
|
716
|
+
hookContext = invokeAfterFieldResolveHook(
|
|
717
|
+
info,
|
|
718
|
+
exeContext,
|
|
719
|
+
hookContext,
|
|
720
|
+
resolved
|
|
721
|
+
);
|
|
722
|
+
return hookContext instanceof import_graphql.GraphQLError ? null : resolved;
|
|
723
|
+
}
|
|
724
|
+
return resolved;
|
|
725
|
+
}).then(
|
|
697
726
|
(resolved) => {
|
|
698
727
|
return completeValue(
|
|
699
728
|
exeContext,
|
|
@@ -706,18 +735,28 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
706
735
|
);
|
|
707
736
|
},
|
|
708
737
|
(rawError) => {
|
|
709
|
-
|
|
710
|
-
invokeAfterFieldResolveHook
|
|
711
|
-
|
|
712
|
-
|
|
738
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
|
|
739
|
+
hookContext = invokeAfterFieldResolveHook(
|
|
740
|
+
info,
|
|
741
|
+
exeContext,
|
|
742
|
+
hookContext,
|
|
743
|
+
void 0,
|
|
744
|
+
rawError
|
|
745
|
+
);
|
|
746
|
+
}
|
|
713
747
|
throw rawError;
|
|
714
748
|
}
|
|
715
749
|
);
|
|
716
750
|
} else {
|
|
717
|
-
|
|
718
|
-
invokeAfterFieldResolveHook
|
|
719
|
-
|
|
720
|
-
|
|
751
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldResolve)) {
|
|
752
|
+
hookContext = invokeAfterFieldResolveHook(
|
|
753
|
+
info,
|
|
754
|
+
exeContext,
|
|
755
|
+
hookContext,
|
|
756
|
+
result
|
|
757
|
+
);
|
|
758
|
+
result = hookContext instanceof import_graphql.GraphQLError ? null : result;
|
|
759
|
+
}
|
|
721
760
|
completed = completeValue(
|
|
722
761
|
exeContext,
|
|
723
762
|
returnTypeRef,
|
|
@@ -730,16 +769,29 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
730
769
|
}
|
|
731
770
|
if ((0, import_isPromise.isPromise)(completed)) {
|
|
732
771
|
return completed.then(
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
772
|
+
(resolved) => {
|
|
773
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
774
|
+
hookContext = invokeAfterFieldCompleteHook(
|
|
775
|
+
info,
|
|
776
|
+
exeContext,
|
|
777
|
+
hookContext,
|
|
778
|
+
resolved
|
|
779
|
+
);
|
|
780
|
+
return hookContext instanceof import_graphql.GraphQLError ? null : resolved;
|
|
781
|
+
}
|
|
782
|
+
return resolved;
|
|
783
|
+
},
|
|
737
784
|
(rawError) => {
|
|
738
785
|
const error = (0, import_graphql.locatedError)(rawError, fieldGroup, (0, import_Path.pathToArray)(path));
|
|
739
|
-
|
|
740
|
-
invokeAfterFieldCompleteHook
|
|
741
|
-
|
|
742
|
-
|
|
786
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
787
|
+
hookContext = invokeAfterFieldCompleteHook(
|
|
788
|
+
info,
|
|
789
|
+
exeContext,
|
|
790
|
+
hookContext,
|
|
791
|
+
void 0,
|
|
792
|
+
error
|
|
793
|
+
);
|
|
794
|
+
}
|
|
743
795
|
handleFieldError(
|
|
744
796
|
rawError,
|
|
745
797
|
exeContext,
|
|
@@ -752,10 +804,16 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
752
804
|
}
|
|
753
805
|
);
|
|
754
806
|
}
|
|
755
|
-
|
|
756
|
-
invokeAfterFieldCompleteHook
|
|
757
|
-
|
|
758
|
-
|
|
807
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
808
|
+
hookContext = invokeAfterFieldCompleteHook(
|
|
809
|
+
info,
|
|
810
|
+
exeContext,
|
|
811
|
+
hookContext,
|
|
812
|
+
completed
|
|
813
|
+
);
|
|
814
|
+
return hookContext instanceof import_graphql.GraphQLError ? null : completed;
|
|
815
|
+
}
|
|
816
|
+
return completed;
|
|
759
817
|
} catch (rawError) {
|
|
760
818
|
const pathArray = (0, import_Path.pathToArray)(path);
|
|
761
819
|
const error = (0, import_graphql.locatedError)(rawError, fieldGroup, pathArray);
|
|
@@ -769,16 +827,13 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
769
827
|
);
|
|
770
828
|
}
|
|
771
829
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
772
|
-
|
|
830
|
+
invokeAfterFieldCompleteHook(
|
|
773
831
|
info,
|
|
774
832
|
exeContext,
|
|
775
833
|
hookContext,
|
|
776
834
|
void 0,
|
|
777
835
|
error
|
|
778
836
|
);
|
|
779
|
-
if (invokeAfterFieldCompleteHookResult instanceof import_graphql.GraphQLError) {
|
|
780
|
-
return null;
|
|
781
|
-
}
|
|
782
837
|
}
|
|
783
838
|
handleFieldError(
|
|
784
839
|
rawError,
|
|
@@ -1267,7 +1322,7 @@ function invokeBeforeFieldSubscribeHook(resolveInfo, exeContext) {
|
|
|
1267
1322
|
const error = toGraphQLError(
|
|
1268
1323
|
rawError,
|
|
1269
1324
|
resolveInfo.path,
|
|
1270
|
-
"Unexpected error
|
|
1325
|
+
"Unexpected error thrown by beforeFieldSubscribe hook"
|
|
1271
1326
|
);
|
|
1272
1327
|
exeContext.errors.push(error);
|
|
1273
1328
|
throw error;
|
|
@@ -1275,7 +1330,7 @@ function invokeBeforeFieldSubscribeHook(resolveInfo, exeContext) {
|
|
|
1275
1330
|
const error = toGraphQLError(
|
|
1276
1331
|
result,
|
|
1277
1332
|
resolveInfo.path,
|
|
1278
|
-
"Unexpected error
|
|
1333
|
+
"Unexpected error returned from beforeFieldSubscribe hook"
|
|
1279
1334
|
);
|
|
1280
1335
|
exeContext.errors.push(error);
|
|
1281
1336
|
throw error;
|
|
@@ -1300,7 +1355,7 @@ function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
|
1300
1355
|
const error = toGraphQLError(
|
|
1301
1356
|
rawError,
|
|
1302
1357
|
resolveInfo.path,
|
|
1303
|
-
"Unexpected error
|
|
1358
|
+
"Unexpected error thrown by beforeFieldResolve hook"
|
|
1304
1359
|
);
|
|
1305
1360
|
exeContext.errors.push(error);
|
|
1306
1361
|
return error;
|
|
@@ -1308,7 +1363,7 @@ function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
|
1308
1363
|
const error = toGraphQLError(
|
|
1309
1364
|
result,
|
|
1310
1365
|
resolveInfo.path,
|
|
1311
|
-
"Unexpected error
|
|
1366
|
+
"Unexpected error returned from beforeFieldResolve hook"
|
|
1312
1367
|
);
|
|
1313
1368
|
exeContext.errors.push(error);
|
|
1314
1369
|
}
|
|
@@ -1335,7 +1390,7 @@ function invokeAfterFieldResolveHook(resolveInfo, exeContext, hookContext, resul
|
|
|
1335
1390
|
const error2 = toGraphQLError(
|
|
1336
1391
|
rawError,
|
|
1337
1392
|
resolveInfo.path,
|
|
1338
|
-
"Unexpected error
|
|
1393
|
+
"Unexpected error thrown by afterFieldResolve hook"
|
|
1339
1394
|
);
|
|
1340
1395
|
exeContext.errors.push(error2);
|
|
1341
1396
|
return error2;
|
|
@@ -1343,7 +1398,7 @@ function invokeAfterFieldResolveHook(resolveInfo, exeContext, hookContext, resul
|
|
|
1343
1398
|
const error2 = toGraphQLError(
|
|
1344
1399
|
result2,
|
|
1345
1400
|
resolveInfo.path,
|
|
1346
|
-
"Unexpected error
|
|
1401
|
+
"Unexpected error returned from afterFieldResolve hook"
|
|
1347
1402
|
);
|
|
1348
1403
|
exeContext.errors.push(error2);
|
|
1349
1404
|
}
|
|
@@ -1370,7 +1425,7 @@ function invokeAfterFieldSubscribeHook(resolveInfo, exeContext, hookContext, res
|
|
|
1370
1425
|
const error2 = toGraphQLError(
|
|
1371
1426
|
rawError,
|
|
1372
1427
|
resolveInfo.path,
|
|
1373
|
-
"Unexpected error
|
|
1428
|
+
"Unexpected error thrown by afterFieldSubscribe hook"
|
|
1374
1429
|
);
|
|
1375
1430
|
exeContext.errors.push(error2);
|
|
1376
1431
|
throw error2;
|
|
@@ -1378,7 +1433,7 @@ function invokeAfterFieldSubscribeHook(resolveInfo, exeContext, hookContext, res
|
|
|
1378
1433
|
const error2 = toGraphQLError(
|
|
1379
1434
|
result2,
|
|
1380
1435
|
resolveInfo.path,
|
|
1381
|
-
"Unexpected error
|
|
1436
|
+
"Unexpected error returned from afterFieldSubscribe hook"
|
|
1382
1437
|
);
|
|
1383
1438
|
exeContext.errors.push(error2);
|
|
1384
1439
|
throw error2;
|
|
@@ -1406,7 +1461,7 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, hookContext, resu
|
|
|
1406
1461
|
const error2 = toGraphQLError(
|
|
1407
1462
|
rawError,
|
|
1408
1463
|
resolveInfo.path,
|
|
1409
|
-
"Unexpected error
|
|
1464
|
+
"Unexpected error thrown by afterFieldComplete hook"
|
|
1410
1465
|
);
|
|
1411
1466
|
exeContext.errors.push(error2);
|
|
1412
1467
|
return error2;
|
|
@@ -1414,7 +1469,7 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, hookContext, resu
|
|
|
1414
1469
|
const error2 = toGraphQLError(
|
|
1415
1470
|
result2,
|
|
1416
1471
|
resolveInfo.path,
|
|
1417
|
-
"Unexpected error
|
|
1472
|
+
"Unexpected error returned from afterFieldComplete hook"
|
|
1418
1473
|
);
|
|
1419
1474
|
exeContext.errors.push(error2);
|
|
1420
1475
|
}
|
|
@@ -1434,19 +1489,22 @@ function invokeBeforeOperationExecuteHook(exeContext) {
|
|
|
1434
1489
|
operation: exeContext.operation
|
|
1435
1490
|
}),
|
|
1436
1491
|
(result, rawError) => {
|
|
1492
|
+
var _a2, _b;
|
|
1493
|
+
const operationName = (_b = (_a2 = exeContext.operation.name) == null ? void 0 : _a2.value) != null ? _b : "unknown";
|
|
1437
1494
|
if (rawError) {
|
|
1438
1495
|
const error = toGraphQLError(
|
|
1439
1496
|
rawError,
|
|
1440
1497
|
void 0,
|
|
1441
|
-
|
|
1498
|
+
`Unexpected error thrown by beforeOperationExecute hook (operation: ${operationName})`
|
|
1442
1499
|
);
|
|
1443
|
-
|
|
1500
|
+
exeContext.errors.push(error);
|
|
1501
|
+
return error;
|
|
1444
1502
|
}
|
|
1445
1503
|
if (result instanceof Error) {
|
|
1446
1504
|
const error = toGraphQLError(
|
|
1447
1505
|
result,
|
|
1448
1506
|
void 0,
|
|
1449
|
-
|
|
1507
|
+
`Unexpected error returned from beforeOperationExecute hook (operation: ${operationName})`
|
|
1450
1508
|
);
|
|
1451
1509
|
exeContext.errors.push(error);
|
|
1452
1510
|
}
|
|
@@ -1467,11 +1525,13 @@ function invokeBeforeSubscriptionEventEmitHook(exeContext, eventPayload) {
|
|
|
1467
1525
|
eventPayload
|
|
1468
1526
|
}),
|
|
1469
1527
|
(result, rawError) => {
|
|
1528
|
+
var _a2, _b;
|
|
1529
|
+
const operationName = (_b = (_a2 = exeContext.operation.name) == null ? void 0 : _a2.value) != null ? _b : "unknown";
|
|
1470
1530
|
if (rawError) {
|
|
1471
1531
|
const error = toGraphQLError(
|
|
1472
1532
|
rawError,
|
|
1473
1533
|
void 0,
|
|
1474
|
-
|
|
1534
|
+
`Unexpected error thrown by beforeSubscriptionEventEmit hook (operation: ${operationName})`
|
|
1475
1535
|
);
|
|
1476
1536
|
exeContext.errors.push(error);
|
|
1477
1537
|
return error;
|
|
@@ -1479,7 +1539,7 @@ function invokeBeforeSubscriptionEventEmitHook(exeContext, eventPayload) {
|
|
|
1479
1539
|
const error = toGraphQLError(
|
|
1480
1540
|
result,
|
|
1481
1541
|
void 0,
|
|
1482
|
-
|
|
1542
|
+
`Unexpected error returned from beforeSubscriptionEventEmit hook (operation: ${operationName})`
|
|
1483
1543
|
);
|
|
1484
1544
|
exeContext.errors.push(error);
|
|
1485
1545
|
}
|
|
@@ -1500,11 +1560,13 @@ function invokeAfterBuildResponseHook(exeContext, result) {
|
|
|
1500
1560
|
result
|
|
1501
1561
|
}),
|
|
1502
1562
|
(result2, rawError) => {
|
|
1563
|
+
var _a2, _b;
|
|
1564
|
+
const operationName = (_b = (_a2 = exeContext.operation.name) == null ? void 0 : _a2.value) != null ? _b : "unknown";
|
|
1503
1565
|
if (rawError) {
|
|
1504
1566
|
const error = toGraphQLError(
|
|
1505
1567
|
rawError,
|
|
1506
1568
|
void 0,
|
|
1507
|
-
|
|
1569
|
+
`Unexpected error thrown by afterBuildResponse hook (operation: ${operationName})`
|
|
1508
1570
|
);
|
|
1509
1571
|
exeContext.errors.push(error);
|
|
1510
1572
|
return error;
|
|
@@ -1512,7 +1574,7 @@ function invokeAfterBuildResponseHook(exeContext, result) {
|
|
|
1512
1574
|
const error = toGraphQLError(
|
|
1513
1575
|
result2,
|
|
1514
1576
|
void 0,
|
|
1515
|
-
|
|
1577
|
+
`Unexpected error returned from afterBuildResponse hook (operation: ${operationName})`
|
|
1516
1578
|
);
|
|
1517
1579
|
exeContext.errors.push(error);
|
|
1518
1580
|
}
|