File tree 2 files changed +33
-44
lines changed
2 files changed +33
-44
lines changed Original file line number Diff line number Diff line change @@ -19,14 +19,7 @@ import {
19
19
GraphQLError ,
20
20
} from 'graphql' ;
21
21
import { RequestParams } from './common' ;
22
- import {
23
- areGraphQLErrors ,
24
- isAsyncIterable ,
25
- isExecutionResult ,
26
- isGraphQLError ,
27
- isObject ,
28
- jsonErrorReplacer ,
29
- } from './utils' ;
22
+ import { isAsyncIterable , isExecutionResult , isObject } from './utils' ;
30
23
31
24
/**
32
25
* The incoming request headers the implementing server should provide.
@@ -854,3 +847,35 @@ function getHeader(
854
847
}
855
848
return Object ( req . headers ) [ key ] ;
856
849
}
850
+
851
+ function areGraphQLErrors ( obj : unknown ) : obj is readonly GraphQLError [ ] {
852
+ return (
853
+ Array . isArray ( obj ) &&
854
+ obj . length > 0 &&
855
+ // if one item in the array is a GraphQLError, we're good
856
+ obj . some ( isGraphQLError )
857
+ ) ;
858
+ }
859
+
860
+ function isGraphQLError ( obj : unknown ) : obj is GraphQLError {
861
+ return obj instanceof GraphQLError ;
862
+ }
863
+
864
+ function jsonErrorReplacer (
865
+ _key : string ,
866
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
867
+ val : any ,
868
+ ) {
869
+ if (
870
+ val instanceof Error &&
871
+ // GraphQL errors implement their own stringer
872
+ ! isGraphQLError ( val )
873
+ ) {
874
+ return {
875
+ // name: val.name, name is included in message
876
+ message : val . message ,
877
+ // stack: val.stack, can leak sensitive details
878
+ } ;
879
+ }
880
+ return val ;
881
+ }
Original file line number Diff line number Diff line change 5
5
*/
6
6
7
7
import type { ExecutionResult } from 'graphql' ;
8
- import { GraphQLError } from 'graphql' ;
9
8
10
9
/** @private */
11
10
export function extendedTypeof (
@@ -39,21 +38,6 @@ export function isObject(val: unknown): val is Record<
39
38
return typeof val === 'object' && val !== null ;
40
39
}
41
40
42
- /** @private */
43
- export function areGraphQLErrors ( obj : unknown ) : obj is readonly GraphQLError [ ] {
44
- return (
45
- Array . isArray ( obj ) &&
46
- obj . length > 0 &&
47
- // if one item in the array is a GraphQLError, we're good
48
- obj . some ( isGraphQLError )
49
- ) ;
50
- }
51
-
52
- /** @private */
53
- export function isGraphQLError ( obj : unknown ) : obj is GraphQLError {
54
- return obj instanceof GraphQLError ;
55
- }
56
-
57
41
/** @private */
58
42
export function isExecutionResult ( val : unknown ) : val is ExecutionResult {
59
43
return (
@@ -68,23 +52,3 @@ export function isAsyncIterable<T = unknown>(
68
52
) : val is AsyncIterable < T > {
69
53
return typeof Object ( val ) [ Symbol . asyncIterator ] === 'function' ;
70
54
}
71
-
72
- /** @private */
73
- export function jsonErrorReplacer (
74
- _key : string ,
75
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
- val : any ,
77
- ) {
78
- if (
79
- val instanceof Error &&
80
- // GraphQL errors implement their own stringer
81
- ! isGraphQLError ( val )
82
- ) {
83
- return {
84
- // name: val.name, name is included in message
85
- message : val . message ,
86
- // stack: val.stack, can leak sensitive details
87
- } ;
88
- }
89
- return val ;
90
- }
You can’t perform that action at this time.
0 commit comments