File tree 1 file changed +8
-10
lines changed
1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -48,21 +48,17 @@ export function validate(
48
48
// If the schema used for validation is invalid, throw an error.
49
49
assertValidSchema ( schema ) ;
50
50
51
- const abortObj = Object . freeze ( { } ) ;
51
+ const abortError = new GraphQLError (
52
+ 'Too many validation errors, error limit reached. Validation aborted.' ,
53
+ ) ;
52
54
const errors : Array < GraphQLError > = [ ] ;
53
55
const context = new ValidationContext (
54
56
schema ,
55
57
documentAST ,
56
58
typeInfo ,
57
59
( error ) => {
58
60
if ( errors . length >= maxErrors ) {
59
- errors . push (
60
- new GraphQLError (
61
- 'Too many validation errors, error limit reached. Validation aborted.' ,
62
- ) ,
63
- ) ;
64
- // eslint-disable-next-line @typescript-eslint/no-throw-literal
65
- throw abortObj ;
61
+ throw abortError ;
66
62
}
67
63
errors . push ( error ) ;
68
64
} ,
@@ -75,8 +71,10 @@ export function validate(
75
71
// Visit the whole document with each instance of all provided rules.
76
72
try {
77
73
visit ( documentAST , visitWithTypeInfo ( typeInfo , visitor ) ) ;
78
- } catch ( e ) {
79
- if ( e !== abortObj ) {
74
+ } catch ( e : unknown ) {
75
+ if ( e === abortError ) {
76
+ errors . push ( abortError ) ;
77
+ } else {
80
78
throw e ;
81
79
}
82
80
}
You can’t perform that action at this time.
0 commit comments