Resolvers
Descriptions
On this page
GraphQL supports descriptions on types, fields, arguments and more. Tools like GraphiQL and editor integrations show them to developers.
Gratos keeps these descriptions in sync with the implementation: the leading free text of a docblock is that construct's description.
Tip
Both TypeScript and GraphQL expect descriptions to be written in Markdown.
See Comment syntax for more details.
Example
/**
* A registered user of the system.
* @gqlType
*/
class User {
/**
* A friendly greeting for the user, intended for
* their first visit.
* @gqlField
*/
hello(
/** The salutation to use */
greeting: string,
): string {
return `${greeting} World`;
}
}"""A registered user of the system."""
type User {
"""
A friendly greeting for the user, intended for
their first visit.
"""
hello(
"""The salutation to use"""
greeting: String!
): String
}Tip
Depending upon your version of TypeScript, a description with an @ in its text, a GitHub handle for example, may get truncated. To avoid this, wrap the handle in quotes or backticks: /** This comment was added by `@captbaritone`. */.
Limitations
Caution
In some cases, TypeScript does not "attach" docblock comments to a construct. In these cases, Gratos cannot extract descriptions.
For example, Gratos cannot attach descriptions to the values of an enum defined as a union of string literals. This union:
/** @gqlEnum */
type GreetingStyle =
/** For a business greeting */
| "formal"
/** For a friendly greeting */
| "casual";enum GreetingStyle {
casual
formal
}has lost both descriptions. To describe enum values, define the enum with a TypeScript enum (see Enums).