You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Query validation can also be used for SDL validation. ...
Regarding documentation, I expected the following validation to fail, but it is passing:
// test can be added to sangria.validation.rules.ValuesOfCorrectTypeSpec"Type field arguments default values" should {
"fail when wrong field name" in {
valSuccess(doc) =QueryParser.parse(
""" |input A { | f1: Int | f2: Float |} |""".stripMargin
)
valstubSchema=Schema.buildStubFromAst(doc)
valSuccess(docUnderTest) =QueryParser.parse(
""" |type Test { | f(a: A = {wrong: 50}): String |} |""".stripMargin
)
valviolations= validator(defaultRule.toList).validateQuery(stubSchema, docUnderTest)
violations shouldNot be(empty) // but it is empty
violations.head shouldBe a[UnknownFieldViolation]
}
}
I have spent some time recently in the library code, and I think the issue is in TypeInfo.scala as it does not push in the inputTypeStack the input type, which leads ctx.typeInfo.inputType to be None and ignore the checking altogether.
The following change in TypeInfo.scala fixes this issue, and I did not get any other failing tests. It does check the InputValueDefinition with defaultValue and adds the type into the stack, which later can be found by the rule.
It is very hard to get around this issue (or at least I could not find one) since all the stacks in this class are private; extending this class does not help. Adding public methods for pop and push to the stacks could be helpful if one wants to add specific validation rules if the default implementation does not handle specific AstNodes.
I am new to the library, but if you think this would be enough, I can PR this fix and add public methods for pop and push.
The text was updated successfully, but these errors were encountered:
From the documentation https://sangria-graphql.github.io/learn/#query-validation
Regarding documentation, I expected the following validation to fail, but it is passing:
I have spent some time recently in the library code, and I think the issue is in TypeInfo.scala as it does not push in the
inputTypeStack
the input type, which leadsctx.typeInfo.inputType
to beNone
and ignore the checking altogether.The following change in
TypeInfo.scala
fixes this issue, and I did not get any other failing tests. It does check the InputValueDefinition with defaultValue and adds the type into the stack, which later can be found by the rule.It is very hard to get around this issue (or at least I could not find one) since all the stacks in this class are private; extending this class does not help. Adding public methods for pop and push to the stacks could be helpful if one wants to add specific validation rules if the default implementation does not handle specific AstNodes.
I am new to the library, but if you think this would be enough, I can PR this fix and add public methods for pop and push.
The text was updated successfully, but these errors were encountered: