Skip to content

Commit 5aadd61

Browse files
validate: remove warning about throwing literal (#3680)
1 parent ac90b52 commit 5aadd61

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/validation/validate.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,17 @@ export function validate(
4848
// If the schema used for validation is invalid, throw an error.
4949
assertValidSchema(schema);
5050

51-
const abortObj = Object.freeze({});
51+
const abortError = new GraphQLError(
52+
'Too many validation errors, error limit reached. Validation aborted.',
53+
);
5254
const errors: Array<GraphQLError> = [];
5355
const context = new ValidationContext(
5456
schema,
5557
documentAST,
5658
typeInfo,
5759
(error) => {
5860
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;
6662
}
6763
errors.push(error);
6864
},
@@ -75,8 +71,10 @@ export function validate(
7571
// Visit the whole document with each instance of all provided rules.
7672
try {
7773
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 {
8078
throw e;
8179
}
8280
}

0 commit comments

Comments
 (0)