juniper icon indicating copy to clipboard operation
juniper copied to clipboard

Suggestion: better formating of block strings

Open mrtnzlml opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe.

This one is very simple. Basically, currently, Juniper prints schemas like so (real copy-pasted example):

"""

        This type should be used together with GraphQL uploads and it should hold the file names
        being uploaded. It's used together with the actual uploaded files for validation purposes.
        Only files which are defined using this scalar will be processed.

"""
scalar ProductImageUploadable

input ProductPriceInput {
  """
    The unit amount in centavo to be charged, represented as a whole integer.
    Centavo equals ¹⁄₁₀₀ of the basic monetary unit.
  """ unitAmount: Int!
  "Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html)." unitAmountCurrency: SupportedCurrency!
}

I assume it's because this is how it's written in the source code. But it's not very nice (moreover, there is this: https://github.com/graphql-rust/juniper/issues/879). Both Prettier and reference implementation in JS would print something like this:

"""
This type should be used together with GraphQL uploads and it should hold the file names
being uploaded. It's used together with the actual uploaded files for validation purposes.
Only files which are defined using this scalar will be processed.
"""
scalar ProductImageUploadable

input ProductPriceInput {
  """
  The unit amount in centavo to be charged, represented as a whole integer.
  Centavo equals ¹⁄₁₀₀ of the basic monetary unit.
  """
  unitAmount: Int!
  "Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html)."
  unitAmountCurrency: SupportedCurrency!
}

Describe the solution you'd like

I'd like if Juniper could also remove these whitespaces similar to what's described in this PR: https://github.com/graphql/graphql-js/pull/926/files

Describe alternatives you've considered

We could be running Prettier over the generated file but that seems to be a bit cumbersome.

Additional context

Related issue: https://github.com/graphql-rust/juniper/issues/879

mrtnzlml avatar Jul 11 '21 14:07 mrtnzlml