ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
4.96k stars 722 forks source link

Improve schema documentation formatting #7089

Open cmeeren opened 2 weeks ago

cmeeren commented 2 weeks ago

Product

Hot Chocolate

Is your feature request related to a problem?

The schema file is currently rendered in a way that is not particularly readable. See for example the long searchOrders line with the inline documentation for each parameter, and how the second to last line ends with """ and then continues with more non-documentation stuff.

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]!
  me: User
  searchOrders(filters: SearchOrdersFiltersInput! sort: [SearchOrdersSortTermInput!] "Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String): SearchOrdersConnection
  """
  Capacity data for the specified factory. This requires the requesting user's `access.capacity.hasAccess` to be
  true.
  """
  factoryCapacity("""
  The ID of the factory to get capacity data for. Only values present in the requesting user's
  `access.capacity.factories` are allowed.
  """ factory: ID!): FactoryCapacityResult!
}

The solution you'd like

Something like the following would be much better, taken from https://jsonformatter.org/graphql-formatter:

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]!
  me: User
  searchOrders(
    filters: SearchOrdersFiltersInput!
    sort: [SearchOrdersSortTermInput!]
    "Returns the first _n_ elements from the list."
    first: Int
    "Returns the elements in the list that come after the specified cursor."
    after: String
  ): SearchOrdersConnection
  """
  Capacity data for the specified factory. This requires the requesting user's `access.capacity.hasAccess` to be
  true.
  """
  factoryCapacity(
    """
    The ID of the factory to get capacity data for. Only values present in the requesting user's
    `access.capacity.factories` are allowed.
    """
    factory: ID!
  ): FactoryCapacityResult!
}
cmeeren commented 2 weeks ago

To be clear, I experience this as a problem due to the schema snapshot test I have. Reading the diff when updating the snapshot is much more difficult than it needs to be due to how HotChocolate formats the schema.