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.
Using the public GraphQL API explorer, we can explore the GraphQL API and see the comments live.
In the above figure, you can see the comments added for the Note
type.
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.
- Build apps and APIs 10x faster
- Built-in authorization and caching
- 8x more performant than hand-rolled APIs