Add `minified` option to allow removing the newline and any extra whitespace
For more information, could refer to https://github.com/vektah/gqlparser/pull/362.
For this issue, I would like to hear suggestions from you.
In summary, the solution to resolve this issue is to:
- Set emitComments = false
- Set omitDescription = true
- Set ident = ""
- Set compacted = true
- Use white space(" ") instead of
\ninWriteNewline
Does that sound good to you? It needs to control by the compacted option if it wants to remove more white space.
cc @StevenACoffman
I think so, but would like to see what standard you are testing your modification against. Apollo? @giautm What are your thoughts?
To be honest, I don't use Apollo and don't know exactly how it normalizes the schema. However, from the workaround in issue #337, I guess it should be basically aligned with Apollo in query except for the need to remove the trailing newline.
formatter.FormatQueryDocument(doc)
normalizedQuery := buf.String()
normalizedQuery = strings.ReplaceAll(normalizedQuery, " (", "(") // Remove space before parentheses
normalizedQuery = strings.ReplaceAll(normalizedQuery, "... ", "...") // Remove space before parentheses
normalizedQuery = strings.TrimSpace(normalizedQuery) // Remove trailing newlines and whitespace
And I haven't found any places that declare how to normalize GraphQL. So, from my perspective, I preferred to hold this feature unless any users explicitly request it. What do you think? @StevenACoffman