format broken for nameless operation with variables
timsuchanek opened this issue · 5 comments
timsuchanek commented
Formatting this query:
query ($first: Int, $second: Int) {
field1(first: $first)
field2(second: $second)
}returns this result:
query {
field1(first: $first)
field2(second: $second)
}Test code:
use graphql_parser::parse_query;
fn main() {
let ast = parse_query::<&str>(
"\
query ($first: Int, $second: Int) {
field1(first: $first)
field2(second: $second)
}",
)
.unwrap();
// Format canonical representation
println!("{}", ast);
}And I think the culprit is here: https://github.com/graphql-rust/graphql-parser/blob/master/src/query/format.rs#L156
tailhook commented
Hm, I thought this is not allowed syntax (so it's actually a parser which is broken). Is it?
timsuchanek commented
Yes could also be the parser. So graphql-js allows it and we have real world application with that use-case, which already runs fine on graphql-js.
timsuchanek commented
Where would you fix that? If you give me a hint in the code, I could also have a look.
tailhook commented
Okay, looks like I'm wrong. So initially pointed line is the place to fix (probably by just moving closing brace). But please also add a test. Thanks!
timsuchanek commented
Sounds good! PR is ready :)