Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve schema documentation formatting #7089

Open
cmeeren opened this issue May 2, 2024 · 1 comment
Open

Improve schema documentation formatting #7089

cmeeren opened this issue May 2, 2024 · 1 comment
Labels

Comments

@cmeeren
Copy link
Contributor

cmeeren commented May 2, 2024

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 cmeeren added the 🎉 enhancement New feature or request label May 2, 2024
@cmeeren
Copy link
Contributor Author

cmeeren commented May 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant