require-description
✅ The "extends": "plugin:@graphql-eslint/schema-recommended" property in a configuration file
enables this rule.
- Category:
Schema - Rule name:
@graphql-eslint/require-description - Requires GraphQL Schema:
falseℹ️ - Requires GraphQL Operations:
falseℹ️
Usage Examples
Incorrect
# eslint @graphql-eslint/require-description: ['error', { types: true, FieldDefinition: true }]
type someTypeName {
name: String
}Correct
# eslint @graphql-eslint/require-description: ['error', { types: true, FieldDefinition: true }]
"""
Some type description
"""
type someTypeName {
"""
Name description
"""
name: String
}Correct
# eslint @graphql-eslint/require-description: ['error', { OperationDefinition: true }]
# Create a new user
mutation createUser {
# ...
}Correct
# eslint @graphql-eslint/require-description: ['error', { rootField: true }]
type Mutation {
"Create a new user"
createUser: User
}
type User {
name: String
}Correct
# eslint @graphql-eslint/require-description: ['error', { ignoredSelectors: ['[type=ObjectTypeDefinition][name.value=PageInfo]', '[type=ObjectTypeDefinition][name.value=/(Connection|Edge)$/]'] }]
type FriendConnection {
edges: [FriendEdge]
pageInfo: PageInfo!
}
type FriendEdge {
cursor: String!
node: Friend!
}
type PageInfo {
hasPreviousPage: Boolean!
hasNextPage: Boolean!
startCursor: String
endCursor: String
}Config Schema
The schema defines the following properties:
types (boolean, enum)
Includes:
ObjectTypeDefinitionInterfaceTypeDefinitionEnumTypeDefinitionScalarTypeDefinitionInputObjectTypeDefinitionUnionTypeDefinition
This element must be one of the following enum values:
true
rootField (boolean, enum)
Definitions within Query, Mutation, and Subscription root types.
This element must be one of the following enum values:
true
ignoredSelectors (array)
Ignore specific selectors
These fields are defined by ESLint
selectors. Paste or drop code into the
editor in ASTExplorer and inspect the generated AST to compose your
selector.
The object is an array with all elements of the type string.
Additional restrictions:
- Minimum items:
1 - Unique items:
true
DirectiveDefinition (boolean)
Read more about this kind on spec.graphql.org .
EnumTypeDefinition (boolean)
Read more about this kind on spec.graphql.org .
EnumValueDefinition (boolean)
Read more about this kind on spec.graphql.org .
FieldDefinition (boolean)
Read more about this kind on spec.graphql.org .
InputObjectTypeDefinition (boolean)
Read more about this kind on spec.graphql.org .
InputValueDefinition (boolean)
Read more about this kind on spec.graphql.org .
InterfaceTypeDefinition (boolean)
Read more about this kind on spec.graphql.org .
ObjectTypeDefinition (boolean)
Read more about this kind on spec.graphql.org .
OperationDefinition (boolean)
Read more about this kind on spec.graphql.org .
You must use only comment syntax # and not description syntax """ or ".
ScalarTypeDefinition (boolean)
Read more about this kind on spec.graphql.org .
UnionTypeDefinition (boolean)
Read more about this kind on spec.graphql.org .