profusion/apollo-validation-directives

Stack Overflow on input that has itself as a field

Closed this issue · 0 comments

GaelS commented

Hi,
First of all, thank you for this great library, really convenient !

This issue has already been raised and closed (#21) but I have found (I think) where its origin is.

I have the following input field:

input A {
   B: [C]
   D: String!
   E: ID
   F: [A] # this line creates the error
   G: JSON
   H: [Int]
}

In ValidateDirectiveVisitor inside the checkMustValidateInput function when I add a log here:

 if (finalType instanceof graphql_1.GraphQLInputObjectType) {
        console.log({type, finalType});
        return Object.values(finalType.getFields()).some(checkMustValidateInputField);
    }

I get { type: A, finalType: A } several times until the crash.

I don't know whether the schema itself is a bit sketchy this way or if the library could handle that case itself to prevent that error from happening 🤔

What do you think ?

Thanks !