Skip to content

format broken for nameless operation with variables #46

Closed
@timsuchanek

Description

@timsuchanek

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions