apollographql / apollo-rs

Spec compliant GraphQL Tools in Rust.
Apache License 2.0
566 stars 43 forks source link

fix(compiler): fix validation for undefined variables nested in values #883

Closed goto-bus-stop closed 1 month ago

goto-bus-stop commented 1 month ago

Previously, an operation like this would pass validation:

query {
  field(listArg: [$undefinedVar])
}

It turns out this is not very common as we haven't seen this cause a problem on hundreds of thousands of operations. But it does happen :)

This moves the UndefinedVariable rule to value validation: we are already recursing into the value here, and we're actually also already checking that the variable exists, so this is a simpler place to do it than in the variable.rs module.

This fixes the immediate problem. There are two things that I may be able to address here before we merge it time willing...