@@ -31,6 +31,10 @@ const QueryDocumentKeysToValidate = mapValue(
3131 ( keys : ReadonlyArray < string > ) => keys . filter ( ( key ) => key !== 'description' ) ,
3232) ;
3333
34+ const tooManyValidationErrorsError = new GraphQLError (
35+ 'Too many validation errors, error limit reached. Validation aborted.' ,
36+ ) ;
37+
3438/**
3539 * Implements the "Validation" section of the spec.
3640 *
@@ -63,9 +67,6 @@ export function validate(
6367 // If the schema used for validation is invalid, throw an error.
6468 assertValidSchema ( schema ) ;
6569
66- const abortError = new GraphQLError (
67- 'Too many validation errors, error limit reached. Validation aborted.' ,
68- ) ;
6970 const errors : Array < GraphQLError > = [ ] ;
7071 const typeInfo = new TypeInfo ( schema ) ;
7172 const context = new ValidationContext (
@@ -74,7 +75,7 @@ export function validate(
7475 typeInfo ,
7576 ( error ) => {
7677 if ( errors . length >= maxErrors ) {
77- throw abortError ;
78+ throw tooManyValidationErrorsError ;
7879 }
7980 errors . push ( error ) ;
8081 } ,
@@ -93,8 +94,8 @@ export function validate(
9394 QueryDocumentKeysToValidate ,
9495 ) ;
9596 } catch ( e : unknown ) {
96- if ( e === abortError ) {
97- errors . push ( abortError ) ;
97+ if ( e === tooManyValidationErrorsError ) {
98+ errors . push ( tooManyValidationErrorsError ) ;
9899 } else {
99100 throw e ;
100101 }
0 commit comments