-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put comments behind an option in formatter (#271)
* Put comments behind an option in formatter In #263, we introduced parsing of comments, as well as support for them in the formatter. In some cases this is surely useful, but in others it's just bloat. (And as I describe in Khan/genqlient#282, it may even be a problem in some cases which depended on the fact that formatting the query didn't include comments.) In this commit I introduce an option to control whether comments are formatted. I set the default to false (i.e. restoring the previous behavior if no options are set), because adding this felt to me like a breaking change, and because it seems to me like the more common usage. `WithComments()` restores the behavior added in #263. If others disagree I'm happy to keep the changed default, and instead provide `WithoutComments()`. I also added tests both ways (and for the existing `WithIndent()` option), and checked that the `comments` tests match the existing ones, and the `default` tests match those from `v2.6.3` (except for the addition of a few descriptions whose omission seem to have been a bug). Comments are still parsed in any case, as adding new struct fields is no problem; and they are still included in `Dump` since that seems obviously parallel to struct fields and is more of a debugging thing. * docs
- Loading branch information
1 parent
9fb1c32
commit 8d1bedc
Showing
68 changed files
with
1,018 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
formatter/testdata/baseline/FormatQueryDocument/default/basic.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
query FooBarQuery ($after: String!) { | ||
fizzList(first: 100, after: $after) { | ||
nodes { | ||
id | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
formatter/testdata/baseline/FormatQueryDocument/default/field.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
query { | ||
bar: foo | ||
} |
18 changes: 18 additions & 0 deletions
18
formatter/testdata/baseline/FormatQueryDocument/default/fragment.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
query FooBarQuery ($after: String!) { | ||
fizzList(first: 100, after: $after) { | ||
nodes { | ||
id | ||
... FooFragment | ||
... on Foo { | ||
id | ||
} | ||
... { | ||
id | ||
} | ||
name | ||
} | ||
} | ||
} | ||
fragment FooFragment on Foo { | ||
id | ||
} |
8 changes: 8 additions & 0 deletions
8
formatter/testdata/baseline/FormatQueryDocument/default/variable.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
query ($first: Int = 30, $after: String!) { | ||
searchCats(first: $first, after: $after) { | ||
nodes { | ||
id | ||
name | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
formatter/testdata/baseline/FormatQueryDocument/spaceIndent/basic.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
query FooBarQuery ($after: String!) { | ||
fizzList(first: 100, after: $after) { | ||
nodes { | ||
id | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
formatter/testdata/baseline/FormatQueryDocument/spaceIndent/field.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
query { | ||
bar: foo | ||
} |
18 changes: 18 additions & 0 deletions
18
formatter/testdata/baseline/FormatQueryDocument/spaceIndent/fragment.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
query FooBarQuery ($after: String!) { | ||
fizzList(first: 100, after: $after) { | ||
nodes { | ||
id | ||
... FooFragment | ||
... on Foo { | ||
id | ||
} | ||
... { | ||
id | ||
} | ||
name | ||
} | ||
} | ||
} | ||
fragment FooFragment on Foo { | ||
id | ||
} |
8 changes: 8 additions & 0 deletions
8
formatter/testdata/baseline/FormatQueryDocument/spaceIndent/variable.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
query ($first: Int = 30, $after: String!) { | ||
searchCats(first: $first, after: $after) { | ||
nodes { | ||
id | ||
name | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Oops, something went wrong.