Strange formatting of input types with descriptions
nightroman opened this issue ยท 16 comments
If an input type has field descriptions then formatting produces unexpected extra new lines and extra indentation of fields.
Please find attached the project for reproducing the issue.
TryGraphQLParser.zip
Test1
No issues for type
types:
dotnet run -- x1-type.graphql
- input
x1-type.graphql
contains atype
with fields with descriptions. - output
x1-type.graphql.output.graphql
is formatted as expected.
Test2
Formatting issues with input
with descriptions:
dotnet run -- x2-input.graphql
- input
x2-input.graphql
contains aninput
with fields with descriptions. - output
x2-input.graphql.output.graphql
shows unexpected new lines and extra indentations.
Test3
No issues with input
without descriptions:
dotnet run -- x3-input.graphql
- input
x3-input.graphql
contains aninput
with no descriptions. - output
x3-input.graphql.output.graphql
is formatted as expected.
Example input:
"A component contains the parametric details of a PCB part."
input DesComponentFilterInput {
and: [DesComponentFilterInput!]
or: [DesComponentFilterInput!]
"The library label for this component."
name: StringOperationFilterInput
"The additional information for this component."
comment: StringOperationFilterInput
"The summary of function or other performance details for this component."
description: StringOperationFilterInput
"The component revision."
revision: DesRevisionFilterInput
}
Example result with unexpected new lines and indentations:
"A component contains the parametric details of a PCB part."
input DesComponentFilterInput {
and: [DesComponentFilterInput!]
or: [DesComponentFilterInput!]
"The library label for this component."
name: StringOperationFilterInput
"The additional information for this component."
comment: StringOperationFilterInput
"The summary of function or other performance details for this component."
description: StringOperationFilterInput
"The component revision."
revision: DesRevisionFilterInput
}
Indeed, I struggled with indentation (both horizontal and vertical) a lot when I rewrote the parser a long time ago. I will try to look at this problem today, but for now I am away from my home PC.
OK. I reproduced this and I have an idea how to fix this. It requires some internal redesign of AST printing.
@sungam3r Any progress? No pressure, just wondering when to expect the improvement, approximately.
Nope. I canโt say when it will be ready. I remember this task. Recently I have been littered with household chores.
I want to return to this task in the near future after I finish the adjacent changes in v8.2/v8.3.
In process. There is some progress. I need to delicately tune practically each method of parser.
@sungam3r Thank you for the good news, cannot wait to try it out!
@sungam3r Thank you! Will the nuget package be updated soon?
Today or tomorrow.
@sungam3r Thank you.
Input type formatting is fixed, great!
There is a regression though (I think).
We lost indentation of field/query parameters in object types.
Example before (normal indentation)
type Query {
"Fetches an object given its ID."
node(
"ID of the object."
id: ID!): Node
"Lookup nodes by a list of IDs."
nodes(
"The list of node IDs."
ids: [ID!]!): [Node]!
"Search for workspaces associated with this account."
desWorkspaces(where: DesWorkspaceFilterInput): [DesWorkspace!]!
"Search a specific workspace by its unique identifier."
desWorkspaceById(
"The node identifier for a workspace."
id: ID!): DesWorkspace
Example now (no indentation)
type Query {
"Fetches an object given its ID."
node(
"ID of the object."
id: ID!): Node
"Lookup nodes by a list of IDs."
nodes(
"The list of node IDs."
ids: [ID!]!): [Node]!
"Search for workspaces associated with this account."
desWorkspaces(where: DesWorkspaceFilterInput): [DesWorkspace!]!
"Search a specific workspace by its unique identifier."
desWorkspaceById(
"The node identifier for a workspace."
id: ID!): DesWorkspace
Should I submit another issue or this comment is enough for an action?
Submit, please, in parser repo.
With new design of indentation it should not take much time to fix.
Here is the new issue -- #311