In the GraphQL spec, the Value grammar has a Const parameter that disallows referencing a variable in type system locations, where variables don’t exist. As of apollo-compiler 1.0.0-beta.15, we have a single Value Rust enum with a Variable variant. Since https://github.com/apollographql/apollo-rs/pull/777 apollo-parser correctly emits parse errors when a variable is used in a const context. But since apollo-compiler data structures are mutable, it is still possible construct a wrong value programatically.
In the GraphQL spec, the
Value
grammar has aConst
parameter that disallows referencing a variable in type system locations, where variables don’t exist. As of apollo-compiler 1.0.0-beta.15, we have a singleValue
Rust enum with aVariable
variant. Since https://github.com/apollographql/apollo-rs/pull/777 apollo-parser correctly emits parse errors when a variable is used in a const context. But since apollo-compiler data structures are mutable, it is still possible construct a wrong value programatically.These is discussion of encoding constness in the type system but that may or may not be the best way forward. Until that happens (if it does), validation should emit a diagnostic if
Value::Variable
is use incorrectly. This is in the same spirit as having both https://github.com/apollographql/apollo-rs/pull/847 and https://github.com/apollographql/apollo-rs/pull/845.