Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formatter: skip printing insignificant commas in arguments definitions #220

Merged
merged 1 commit into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion formatter/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ func (f *formatter) FormatArgumentDefinitionList(lists ast.ArgumentDefinitionLis
for idx, arg := range lists {
f.FormatArgumentDefinition(arg)

if idx != len(lists)-1 {
// Skip emitting (insignificant) comma in case it is the
// last argument, or we printed a new line in its definition.
if idx != len(lists)-1 && arg.Description == "" {
f.NoPadding().WriteWord(",")
}
}
Expand Down
5 changes: 4 additions & 1 deletion formatter/testdata/baseline/FormatSchema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type TopSubscription {
): Boolean
noop3(
"""noop3 foo bar"""
arg: String
arg1: String

"""noop3 foo bar"""
arg2: String
): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type TopSubscription {
): Boolean
noop3(
"""noop3 foo bar"""
arg: String
arg1: String

"""noop3 foo bar"""
arg2: String
): Boolean
}
5 changes: 4 additions & 1 deletion formatter/testdata/source/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type TopSubscription {

noop3(
"noop3 foo bar"
arg: String
arg1: String

"noop3 foo bar"
arg2: String
): Boolean
}