Graphql Comments

GraphQL Comments

With GraphQL, you can add code comments that are also shown in GraphQL tools such as GraphiQL, GraphQL Playground, and others. As a result, the comments are helpful for both the developers working on your GraphQL API and the developers consuming the API.

You can add comments to your code by using quotation marks as follows:

Retrieve one or more notes from the database
type Query {
notes: [Note]
note(id: Int): Note

The figure below shows an example of GraphQL comments from an existing application.

GraphQL server comments

Using the public GraphQL API explorer, we can explore the GraphQL API and see the comments live.

GraphQL comments showing in the GraphQL Playground

In the above figure, you can see the comments added for the Note type.

GraphQL comments showing in the GraphQL Playground

You can also see the comments for the "Query" type. Code comments are a great way to add additional context and help the developers using your GraphQL API.

Did you find this page helpful?
Start with GraphQL on Hasura for Free
  • ArrowBuild apps and APIs 10x faster
  • ArrowBuilt-in authorization and caching
  • Arrow8x more performant than hand-rolled APIs
footer illustration
Brand logo
© 2024 Hasura Inc. All rights reserved