vektah/gqlparser

FormatSchemaDocument and FormatQueryDocument support to print comments

Closed this issue · 2 comments

What happened?

FormatSchemaDocument and FormatQueryDocument doesn't print comments.

  • input GraphQL file
type query {
  # TODO: Fix
  id: ID!
}

FormatSchemaDocument remove comments from GraphQL files.

type query {
  id: ID!
}

What did you expect?

I would like to generate the following GraphQL output by parsing the given GraphQL file.

type query {
  # TODO: Fix
  id: ID!
}

Minimal graphql.schema and models to reproduce

  • schema
type query {
  # TODO: Fix
  id: ID!
}
  • query
query {
  # TODO: Fix
  id
}

versions

  • go list -m github.com/vektah/gqlparser/v2? 2.5.4
  • go version? 1.20

refs

#261

@Warashi are you interested in taking this on?

I tried this when implementing #261, but could not implement it successfully and only sent the lexer as a PR.
I will try some more with reference to Go's parser and formatter.