We are using Spring boot grphql sqpr library.
We have to generate graphql API documentation which can be viewed in graphiql.
For e.g.
If i have field like below
# comma separated location IDs. (eg: '5,12,27')
locationIds: String
then this string comma separated location IDs. (eg: '5,12,27')
should be visible in graphiql.
1 Answer
You can attach a description to any schema element that permits it via its corresponding annotation:
-
@GraphQLQuery(description="...")
for output fields at any level -
@GraphQLMutation(description="...")
for mutations -
@GraphQLSubscription(description="...")
for subscriptions -
@GraphQLInputField(description="...")
for input fields at any level, falls back to@GraphQLQuery
-
@GraphQLArgument(description="...")
for arguments -
@GraphQLType/GraphQLInterface/GraphQLUnion(description="...")
– for descriptions on various kinds of types -
@GraphQLDirective(description="...")
– for descriptions on directives
In short, the rule is: if it permits a descriptions in the schema, there’s a corresponding annotation for it with a description
parameter.
These are only the defaults, of course, you can always customize how descriptions are added, and how anything is mapped in general.