@graphitation/supermassive 3.8.0-alpha.2 → 3.8.0-alpha.4
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 +4 -4
- package/hooks.md +64 -0
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +159 -113
- package/lib/executeWithoutSchema.js.map +2 -2
- package/lib/executeWithoutSchema.mjs +159 -113
- 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 Wed, 25 Dec 2024 21:18:54 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## 3.8.0-alpha.
|
|
7
|
+
## 3.8.0-alpha.4
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Wed, 25 Dec 2024 21:18:54 GMT
|
|
10
10
|
|
|
11
11
|
### Changes
|
|
12
12
|
|
|
13
|
-
-
|
|
13
|
+
- Supermassive PR comment fixes (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,MAA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AC1C,MAAM,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
|
}
|
|
@@ -295,10 +303,16 @@ function buildResponse(exeContext, data) {
|
|
|
295
303
|
};
|
|
296
304
|
} else {
|
|
297
305
|
if (hooks == null ? void 0 : hooks.afterBuildResponse) {
|
|
298
|
-
invokeAfterBuildResponseHook(
|
|
306
|
+
const hookResult = invokeAfterBuildResponseHook(
|
|
307
|
+
exeContext,
|
|
308
|
+
initialResult
|
|
309
|
+
);
|
|
299
310
|
if (exeContext.errors.length > ((_b = (_a = initialResult.errors) == null ? void 0 : _a.length) != null ? _b : 0)) {
|
|
300
311
|
initialResult.errors = exeContext.errors;
|
|
301
312
|
}
|
|
313
|
+
if (hookResult instanceof import_graphql.GraphQLError) {
|
|
314
|
+
return { errors: initialResult.errors };
|
|
315
|
+
}
|
|
302
316
|
}
|
|
303
317
|
return initialResult;
|
|
304
318
|
}
|
|
@@ -446,6 +460,17 @@ function createSourceEventStream(exeContext) {
|
|
|
446
460
|
return { errors: [error] };
|
|
447
461
|
}
|
|
448
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
|
+
}
|
|
449
474
|
function executeSubscriptionImpl(exeContext) {
|
|
450
475
|
var _a;
|
|
451
476
|
const { operation, rootValue, schemaFragment } = exeContext;
|
|
@@ -487,73 +512,60 @@ function executeSubscriptionImpl(exeContext) {
|
|
|
487
512
|
const hooks = exeContext.fieldExecutionHooks;
|
|
488
513
|
let hookContext = void 0;
|
|
489
514
|
try {
|
|
490
|
-
|
|
491
|
-
const contextValue = exeContext.contextValue;
|
|
515
|
+
let result;
|
|
492
516
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.beforeFieldSubscribe)) {
|
|
493
517
|
hookContext = invokeBeforeFieldSubscribeHook(info, exeContext);
|
|
494
518
|
}
|
|
495
|
-
|
|
519
|
+
const args = (0, import_values.getArgumentValues)(exeContext, fieldDef, fieldGroup[0]);
|
|
520
|
+
const contextValue = exeContext.contextValue;
|
|
496
521
|
if (hookContext) {
|
|
497
522
|
if ((0, import_isPromise.isPromise)(hookContext)) {
|
|
498
523
|
result = hookContext.then((context) => {
|
|
499
524
|
hookContext = context;
|
|
500
|
-
if (hookContext instanceof import_graphql.GraphQLError) {
|
|
501
|
-
return null;
|
|
502
|
-
}
|
|
503
525
|
return resolveFn(rootValue, args, contextValue, info);
|
|
504
526
|
});
|
|
505
|
-
} else if (hookContext instanceof import_graphql.GraphQLError) {
|
|
506
|
-
result = null;
|
|
507
527
|
}
|
|
508
528
|
}
|
|
509
529
|
if (result === void 0) {
|
|
510
530
|
result = resolveFn(rootValue, args, contextValue, info);
|
|
511
531
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
532
|
+
if ((0, import_isPromise.isPromise)(result)) {
|
|
533
|
+
return result.then(assertEventStream, (error) => {
|
|
534
|
+
afterFieldSubscribeHandle(
|
|
535
|
+
void 0,
|
|
536
|
+
isDefaultResolverUsed,
|
|
516
537
|
exeContext,
|
|
538
|
+
info,
|
|
517
539
|
hookContext,
|
|
518
|
-
|
|
540
|
+
!!(hooks == null ? void 0 : hooks.afterFieldSubscribe),
|
|
519
541
|
error
|
|
520
542
|
);
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
hookContext = invokeAfterFieldSubscribeHook(
|
|
534
|
-
info,
|
|
535
|
-
exeContext,
|
|
536
|
-
hookContext,
|
|
537
|
-
resolved
|
|
538
|
-
);
|
|
539
|
-
if (hookContext instanceof import_graphql.GraphQLError) {
|
|
540
|
-
throw hookContext;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
return resolved;
|
|
544
|
-
},
|
|
545
|
-
(error) => {
|
|
546
|
-
afterFieldSubscribeHandle(void 0, error);
|
|
547
|
-
throw (0, import_graphql.locatedError)(error, fieldGroup, (0, import_Path.pathToArray)(path));
|
|
548
|
-
}
|
|
549
|
-
);
|
|
543
|
+
throw (0, import_graphql.locatedError)(error, fieldGroup, (0, import_Path.pathToArray)(path));
|
|
544
|
+
}).then((resolved) => {
|
|
545
|
+
afterFieldSubscribeHandle(
|
|
546
|
+
resolved,
|
|
547
|
+
isDefaultResolverUsed,
|
|
548
|
+
exeContext,
|
|
549
|
+
info,
|
|
550
|
+
hookContext,
|
|
551
|
+
!!(hooks == null ? void 0 : hooks.afterFieldSubscribe)
|
|
552
|
+
);
|
|
553
|
+
return resolved;
|
|
554
|
+
});
|
|
550
555
|
}
|
|
551
556
|
const stream = assertEventStream(result);
|
|
552
|
-
afterFieldSubscribeHandle(
|
|
557
|
+
afterFieldSubscribeHandle(
|
|
558
|
+
stream,
|
|
559
|
+
isDefaultResolverUsed,
|
|
560
|
+
exeContext,
|
|
561
|
+
info,
|
|
562
|
+
hookContext,
|
|
563
|
+
!!(hooks == null ? void 0 : hooks.afterFieldSubscribe)
|
|
564
|
+
);
|
|
553
565
|
return stream;
|
|
554
566
|
} catch (error) {
|
|
555
567
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldSubscribe)) {
|
|
556
|
-
|
|
568
|
+
invokeAfterFieldSubscribeHook(
|
|
557
569
|
info,
|
|
558
570
|
exeContext,
|
|
559
571
|
hookContext,
|
|
@@ -561,9 +573,6 @@ function executeSubscriptionImpl(exeContext) {
|
|
|
561
573
|
error
|
|
562
574
|
);
|
|
563
575
|
}
|
|
564
|
-
if (hookContext instanceof import_graphql.GraphQLError) {
|
|
565
|
-
throw hookContext;
|
|
566
|
-
}
|
|
567
576
|
throw (0, import_graphql.locatedError)(error, fieldGroup, (0, import_Path.pathToArray)(path));
|
|
568
577
|
}
|
|
569
578
|
}
|
|
@@ -701,20 +710,19 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
701
710
|
result = resolveFn(source, args, contextValue, info);
|
|
702
711
|
}
|
|
703
712
|
let completed;
|
|
704
|
-
const handleAfterFieldHooks = (hook, useHook) => (resolved, error) => {
|
|
705
|
-
if (!isDefaultResolverUsed && useHook) {
|
|
706
|
-
hookContext = hook(info, exeContext, hookContext, resolved, error);
|
|
707
|
-
return hookContext instanceof import_graphql.GraphQLError ? null : resolved;
|
|
708
|
-
}
|
|
709
|
-
return resolved;
|
|
710
|
-
};
|
|
711
713
|
if ((0, import_isPromise.isPromise)(result)) {
|
|
712
|
-
completed = result.then(
|
|
713
|
-
|
|
714
|
-
invokeAfterFieldResolveHook
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
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(
|
|
718
726
|
(resolved) => {
|
|
719
727
|
return completeValue(
|
|
720
728
|
exeContext,
|
|
@@ -727,18 +735,28 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
727
735
|
);
|
|
728
736
|
},
|
|
729
737
|
(rawError) => {
|
|
730
|
-
|
|
731
|
-
invokeAfterFieldResolveHook
|
|
732
|
-
|
|
733
|
-
|
|
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
|
+
}
|
|
734
747
|
throw rawError;
|
|
735
748
|
}
|
|
736
749
|
);
|
|
737
750
|
} else {
|
|
738
|
-
|
|
739
|
-
invokeAfterFieldResolveHook
|
|
740
|
-
|
|
741
|
-
|
|
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
|
+
}
|
|
742
760
|
completed = completeValue(
|
|
743
761
|
exeContext,
|
|
744
762
|
returnTypeRef,
|
|
@@ -751,18 +769,28 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
751
769
|
}
|
|
752
770
|
if ((0, import_isPromise.isPromise)(completed)) {
|
|
753
771
|
return completed.then(
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
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
|
+
},
|
|
758
784
|
(rawError) => {
|
|
759
785
|
const error = (0, import_graphql.locatedError)(rawError, fieldGroup, (0, import_Path.pathToArray)(path));
|
|
760
|
-
|
|
761
|
-
invokeAfterFieldCompleteHook
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
786
|
+
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
787
|
+
hookContext = invokeAfterFieldCompleteHook(
|
|
788
|
+
info,
|
|
789
|
+
exeContext,
|
|
790
|
+
hookContext,
|
|
791
|
+
void 0,
|
|
792
|
+
error
|
|
793
|
+
);
|
|
766
794
|
}
|
|
767
795
|
handleFieldError(
|
|
768
796
|
rawError,
|
|
@@ -776,10 +804,16 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
776
804
|
}
|
|
777
805
|
);
|
|
778
806
|
}
|
|
779
|
-
|
|
780
|
-
invokeAfterFieldCompleteHook
|
|
781
|
-
|
|
782
|
-
|
|
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;
|
|
783
817
|
} catch (rawError) {
|
|
784
818
|
const pathArray = (0, import_Path.pathToArray)(path);
|
|
785
819
|
const error = (0, import_graphql.locatedError)(rawError, fieldGroup, pathArray);
|
|
@@ -793,16 +827,13 @@ function resolveAndCompleteField(exeContext, parentTypeName, fieldDefinition, fi
|
|
|
793
827
|
);
|
|
794
828
|
}
|
|
795
829
|
if (!isDefaultResolverUsed && (hooks == null ? void 0 : hooks.afterFieldComplete)) {
|
|
796
|
-
|
|
830
|
+
invokeAfterFieldCompleteHook(
|
|
797
831
|
info,
|
|
798
832
|
exeContext,
|
|
799
833
|
hookContext,
|
|
800
834
|
void 0,
|
|
801
835
|
error
|
|
802
836
|
);
|
|
803
|
-
if (invokeAfterFieldCompleteHookResult instanceof import_graphql.GraphQLError) {
|
|
804
|
-
return null;
|
|
805
|
-
}
|
|
806
837
|
}
|
|
807
838
|
handleFieldError(
|
|
808
839
|
rawError,
|
|
@@ -1291,18 +1322,18 @@ function invokeBeforeFieldSubscribeHook(resolveInfo, exeContext) {
|
|
|
1291
1322
|
const error = toGraphQLError(
|
|
1292
1323
|
rawError,
|
|
1293
1324
|
resolveInfo.path,
|
|
1294
|
-
"Unexpected error
|
|
1325
|
+
"Unexpected error thrown by beforeFieldSubscribe hook"
|
|
1295
1326
|
);
|
|
1296
1327
|
exeContext.errors.push(error);
|
|
1297
|
-
|
|
1328
|
+
throw error;
|
|
1298
1329
|
} else if (result instanceof Error) {
|
|
1299
1330
|
const error = toGraphQLError(
|
|
1300
1331
|
result,
|
|
1301
1332
|
resolveInfo.path,
|
|
1302
|
-
"Unexpected error
|
|
1333
|
+
"Unexpected error returned from beforeFieldSubscribe hook"
|
|
1303
1334
|
);
|
|
1304
1335
|
exeContext.errors.push(error);
|
|
1305
|
-
|
|
1336
|
+
throw error;
|
|
1306
1337
|
}
|
|
1307
1338
|
return result;
|
|
1308
1339
|
}
|
|
@@ -1324,7 +1355,7 @@ function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
|
1324
1355
|
const error = toGraphQLError(
|
|
1325
1356
|
rawError,
|
|
1326
1357
|
resolveInfo.path,
|
|
1327
|
-
"Unexpected error
|
|
1358
|
+
"Unexpected error thrown by beforeFieldResolve hook"
|
|
1328
1359
|
);
|
|
1329
1360
|
exeContext.errors.push(error);
|
|
1330
1361
|
return error;
|
|
@@ -1332,7 +1363,7 @@ function invokeBeforeFieldResolveHook(resolveInfo, exeContext) {
|
|
|
1332
1363
|
const error = toGraphQLError(
|
|
1333
1364
|
result,
|
|
1334
1365
|
resolveInfo.path,
|
|
1335
|
-
"Unexpected error
|
|
1366
|
+
"Unexpected error returned from beforeFieldResolve hook"
|
|
1336
1367
|
);
|
|
1337
1368
|
exeContext.errors.push(error);
|
|
1338
1369
|
}
|
|
@@ -1359,7 +1390,7 @@ function invokeAfterFieldResolveHook(resolveInfo, exeContext, hookContext, resul
|
|
|
1359
1390
|
const error2 = toGraphQLError(
|
|
1360
1391
|
rawError,
|
|
1361
1392
|
resolveInfo.path,
|
|
1362
|
-
"Unexpected error
|
|
1393
|
+
"Unexpected error thrown by afterFieldResolve hook"
|
|
1363
1394
|
);
|
|
1364
1395
|
exeContext.errors.push(error2);
|
|
1365
1396
|
return error2;
|
|
@@ -1367,7 +1398,7 @@ function invokeAfterFieldResolveHook(resolveInfo, exeContext, hookContext, resul
|
|
|
1367
1398
|
const error2 = toGraphQLError(
|
|
1368
1399
|
result2,
|
|
1369
1400
|
resolveInfo.path,
|
|
1370
|
-
"Unexpected error
|
|
1401
|
+
"Unexpected error returned from afterFieldResolve hook"
|
|
1371
1402
|
);
|
|
1372
1403
|
exeContext.errors.push(error2);
|
|
1373
1404
|
}
|
|
@@ -1394,18 +1425,18 @@ function invokeAfterFieldSubscribeHook(resolveInfo, exeContext, hookContext, res
|
|
|
1394
1425
|
const error2 = toGraphQLError(
|
|
1395
1426
|
rawError,
|
|
1396
1427
|
resolveInfo.path,
|
|
1397
|
-
"Unexpected error
|
|
1428
|
+
"Unexpected error thrown by afterFieldSubscribe hook"
|
|
1398
1429
|
);
|
|
1399
1430
|
exeContext.errors.push(error2);
|
|
1400
|
-
|
|
1431
|
+
throw error2;
|
|
1401
1432
|
} else if (result2 instanceof Error) {
|
|
1402
1433
|
const error2 = toGraphQLError(
|
|
1403
1434
|
result2,
|
|
1404
1435
|
resolveInfo.path,
|
|
1405
|
-
"Unexpected error
|
|
1436
|
+
"Unexpected error returned from afterFieldSubscribe hook"
|
|
1406
1437
|
);
|
|
1407
1438
|
exeContext.errors.push(error2);
|
|
1408
|
-
|
|
1439
|
+
throw error2;
|
|
1409
1440
|
}
|
|
1410
1441
|
return result2;
|
|
1411
1442
|
}
|
|
@@ -1430,7 +1461,7 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, hookContext, resu
|
|
|
1430
1461
|
const error2 = toGraphQLError(
|
|
1431
1462
|
rawError,
|
|
1432
1463
|
resolveInfo.path,
|
|
1433
|
-
"Unexpected error
|
|
1464
|
+
"Unexpected error thrown by afterFieldComplete hook"
|
|
1434
1465
|
);
|
|
1435
1466
|
exeContext.errors.push(error2);
|
|
1436
1467
|
return error2;
|
|
@@ -1438,7 +1469,7 @@ function invokeAfterFieldCompleteHook(resolveInfo, exeContext, hookContext, resu
|
|
|
1438
1469
|
const error2 = toGraphQLError(
|
|
1439
1470
|
result2,
|
|
1440
1471
|
resolveInfo.path,
|
|
1441
|
-
"Unexpected error
|
|
1472
|
+
"Unexpected error returned from afterFieldComplete hook"
|
|
1442
1473
|
);
|
|
1443
1474
|
exeContext.errors.push(error2);
|
|
1444
1475
|
}
|
|
@@ -1458,19 +1489,22 @@ function invokeBeforeOperationExecuteHook(exeContext) {
|
|
|
1458
1489
|
operation: exeContext.operation
|
|
1459
1490
|
}),
|
|
1460
1491
|
(result, rawError) => {
|
|
1492
|
+
var _a2, _b;
|
|
1493
|
+
const operationName = (_b = (_a2 = exeContext.operation.name) == null ? void 0 : _a2.value) != null ? _b : "unknown";
|
|
1461
1494
|
if (rawError) {
|
|
1462
1495
|
const error = toGraphQLError(
|
|
1463
1496
|
rawError,
|
|
1464
1497
|
void 0,
|
|
1465
|
-
|
|
1498
|
+
`Unexpected error thrown by beforeOperationExecute hook (operation: ${operationName})`
|
|
1466
1499
|
);
|
|
1467
|
-
|
|
1500
|
+
exeContext.errors.push(error);
|
|
1501
|
+
return error;
|
|
1468
1502
|
}
|
|
1469
1503
|
if (result instanceof Error) {
|
|
1470
1504
|
const error = toGraphQLError(
|
|
1471
|
-
|
|
1505
|
+
result,
|
|
1472
1506
|
void 0,
|
|
1473
|
-
|
|
1507
|
+
`Unexpected error returned from beforeOperationExecute hook (operation: ${operationName})`
|
|
1474
1508
|
);
|
|
1475
1509
|
exeContext.errors.push(error);
|
|
1476
1510
|
}
|
|
@@ -1491,11 +1525,13 @@ function invokeBeforeSubscriptionEventEmitHook(exeContext, eventPayload) {
|
|
|
1491
1525
|
eventPayload
|
|
1492
1526
|
}),
|
|
1493
1527
|
(result, rawError) => {
|
|
1528
|
+
var _a2, _b;
|
|
1529
|
+
const operationName = (_b = (_a2 = exeContext.operation.name) == null ? void 0 : _a2.value) != null ? _b : "unknown";
|
|
1494
1530
|
if (rawError) {
|
|
1495
1531
|
const error = toGraphQLError(
|
|
1496
1532
|
rawError,
|
|
1497
1533
|
void 0,
|
|
1498
|
-
|
|
1534
|
+
`Unexpected error thrown by beforeSubscriptionEventEmit hook (operation: ${operationName})`
|
|
1499
1535
|
);
|
|
1500
1536
|
exeContext.errors.push(error);
|
|
1501
1537
|
return error;
|
|
@@ -1503,7 +1539,7 @@ function invokeBeforeSubscriptionEventEmitHook(exeContext, eventPayload) {
|
|
|
1503
1539
|
const error = toGraphQLError(
|
|
1504
1540
|
result,
|
|
1505
1541
|
void 0,
|
|
1506
|
-
|
|
1542
|
+
`Unexpected error returned from beforeSubscriptionEventEmit hook (operation: ${operationName})`
|
|
1507
1543
|
);
|
|
1508
1544
|
exeContext.errors.push(error);
|
|
1509
1545
|
}
|
|
@@ -1523,12 +1559,22 @@ function invokeAfterBuildResponseHook(exeContext, result) {
|
|
|
1523
1559
|
operation: exeContext.operation,
|
|
1524
1560
|
result
|
|
1525
1561
|
}),
|
|
1526
|
-
(
|
|
1562
|
+
(result2, rawError) => {
|
|
1563
|
+
var _a2, _b;
|
|
1564
|
+
const operationName = (_b = (_a2 = exeContext.operation.name) == null ? void 0 : _a2.value) != null ? _b : "unknown";
|
|
1527
1565
|
if (rawError) {
|
|
1528
1566
|
const error = toGraphQLError(
|
|
1529
1567
|
rawError,
|
|
1530
1568
|
void 0,
|
|
1531
|
-
|
|
1569
|
+
`Unexpected error thrown by afterBuildResponse hook (operation: ${operationName})`
|
|
1570
|
+
);
|
|
1571
|
+
exeContext.errors.push(error);
|
|
1572
|
+
return error;
|
|
1573
|
+
} else if (result2 instanceof Error) {
|
|
1574
|
+
const error = toGraphQLError(
|
|
1575
|
+
result2,
|
|
1576
|
+
void 0,
|
|
1577
|
+
`Unexpected error returned from afterBuildResponse hook (operation: ${operationName})`
|
|
1532
1578
|
);
|
|
1533
1579
|
exeContext.errors.push(error);
|
|
1534
1580
|
}
|