Stack overflow when calling ValidateDirectiveVisitor.addValidationResolversToSchema()
Closed this issue · 5 comments
For some reason, I'm getting a stack overflow when calling ValidateDirectiveVisitor.addValidationResolversToSchema()
:
2020-08-27T17:32:09.449Z [error]: uncaughtException: Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
at Object.get [as GraphQLNonNull] (C:\Code\project\node_modules\graphql\type\index.js:296:20)
at Object.get [as GraphQLNonNull] (C:\Code\project\node_modules\graphql\index.js:87:18)
at checkMustValidateInput (C:\Code\project\node_modules\@profusion\apollo-validation-directives\build\lib\ValidateDirectiveVisitor.js:74:40)
at checkMustValidateInput (C:\Code\project\node_modules\@profusion\apollo-validation-directives\build\lib\ValidateDirectiveVisitor.js:78:16)
at checkMustValidateInputField (C:\Code\project\node_modules\@profusion\apollo-validation-directives\build\lib\ValidateDirectiveVisitor.js:70:12)
at Array.some (<anonymous>)
at checkMustValidateInput (C:\Code\project\node_modules\@profusion\apollo-validation-directives\build\lib\ValidateDirectiveVisitor.js:84:53)
at checkMustValidateInput (C:\Code\project\node_modules\@profusion\apollo-validation-directives\build\lib\ValidateDirectiveVisitor.js:78:16)
at checkMustValidateInputField (C:\Code\project\node_modules\@profusion\apollo-validation-directives\build\lib\ValidateDirectiveVisitor.js:70:12)
at Array.some (<anonymous>)
at checkMustValidateInput (C:\Code\project\node_modules\@profusion\apollo-validation-directives\build\lib\ValidateDirectiveVisitor.js:84:53)
at checkMustValidateInput (C:\Code\project\node_modules\@profusion\apollo-validation-directives\build\lib\ValidateDirectiveVisitor.js:78:16)
at checkMustValidateInputField (C:\Code\project\node_modules\@profusion\apollo-validation-directives\build\lib\ValidateDirectiveVisitor.js:70:12)
at Array.some (<anonymous>)
at checkMustValidateInput (C:\Code\project\node_modules\@profusion\apollo-validation-directives\build\lib\ValidateDirectiveVisitor.js:84:53)
at checkMustValidateInput (C:\Code\project\node_modules\@profusion\apollo-validation-directives\build\lib\ValidateDirectiveVisitor.js:78:16)
@robross0606 Can you provide a minimal code so we can reproduce, please?
@robross0606 any news about this one? Could you please provide more info, a reproducible example?
I don't know how to reproduce it outside our large code base yet.
I'm closing this, for now. Please feel free to reopen in case you see this bug again.
Hi, I actually have the same issue.
It occurs in the ValidateDirectiveVisitor
file between those 2 functions:
const checkMustValidateInputField = (field) => {
// istanbul ignore next (shouldn't reach as addContainerEntryValidation would mark parent, but be safe)
if (field.validation) {
return true;
}
// eslint-disable-next-line @typescript-eslint/no-use-before-define
return checkMustValidateInput(field.type);
};
const checkMustValidateInput = (type) => {
let finalType = type;
if (finalType instanceof graphql_1.GraphQLNonNull) {
finalType = finalType.ofType;
}
if (finalType instanceof graphql_1.GraphQLList) {
return checkMustValidateInput(finalType.ofType);
}
if (finalType.mustValidateInput !== undefined) {
return finalType.mustValidateInput;
}
if (finalType instanceof graphql_1.GraphQLInputObjectType) {
return Object.values(finalType.getFields()).some(checkMustValidateInputField);
}
return false;
};
checkMustValidate
calls checkMustValidateInput
which calls back checkMustValidateInputField
Not sure I get what is going on here but could it be caused by schema where one uses nesting of components using validation like so for instance ?
input FooInput {
id: ID
date: String
message: String! @stringLength(max: 10000)
foo: [FooInput]
}
Cheers