apollo-rs icon indicating copy to clipboard operation
apollo-rs copied to clipboard

schema printer adds unnecessary comma for arguments with description

Open dariuszkuc opened this issue 1 year ago • 4 comments

Description

Schema printer adds unnecessary comma for arguments with description. See repro below.

Steps to reproduce

#[test]
    fn arguments() {
        let mut foo = ObjectType {
            name: Name::new("Foo"),
            description: None,
            directives: vec![],
            fields: IndexMap::new(),
            implements_interfaces: IndexMap::new(),
        };
        foo.fields.insert(
            Name::new("bar"),
            Component::new(FieldDefinition {
                name: Name::new("bar"),
                description: None,
                directives: vec![],
                arguments: vec![Node::new(InputValueDefinition {
                    name: Name::new("arg"),
                    description: Some(NodeStr::new("foobar")),
                    // description: None,
                    directives: vec![],
                    ty: Type::Named(NodeStr::new("String")),
                    default_value: None,
                })],
                ty: Type::Named(NodeStr::new("String")),
            }),
        );

        let mut schema = Schema::new();
        schema
            .types
            .insert(Name::new("Foo"), ExtendedType::Object(Node::new(foo)));
        println!("{}", schema);
    }

Expected result

No comma after single argument with description

type Foo {
  bar(
    "foobar"
    arg: String
  ): String
}

Actual result

Extra comma after single argument

type Foo {
  bar(
    "foobar"
    arg: String,
  ): String
}

Environment

  • Operating system and version: MacOS Ventura
  • Shell (bash/zsh/powershell): zsh
  • apollo-rs crate: mut branch
  • Crate version: 1.72.0

dariuszkuc avatar Sep 27 '23 15:09 dariuszkuc