🎉 Welcome to the new GraphQL-ESLint website. Try new playground page →
Rules
Require Description

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 ℹī¸

Enforce descriptions in type definitions and operations.

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
}

Config Schema

The schema defines the following properties:

types (boolean)

Includes:

  • ObjectTypeDefinition
  • InterfaceTypeDefinition
  • EnumTypeDefinition
  • ScalarTypeDefinition
  • InputObjectTypeDefinition
  • UnionTypeDefinition

rootField (boolean)

Definitions within Query, Mutation, and Subscription root types.

DirectiveDefinition (boolean)

Read more about this kind on spec.graphql.org (opens in a new tab).

EnumTypeDefinition (boolean)

Read more about this kind on spec.graphql.org (opens in a new tab).

EnumValueDefinition (boolean)

Read more about this kind on spec.graphql.org (opens in a new tab).

FieldDefinition (boolean)

Read more about this kind on spec.graphql.org (opens in a new tab).

InputObjectTypeDefinition (boolean)

Read more about this kind on spec.graphql.org (opens in a new tab).

InputValueDefinition (boolean)

Read more about this kind on spec.graphql.org (opens in a new tab).

InterfaceTypeDefinition (boolean)

Read more about this kind on spec.graphql.org (opens in a new tab).

ObjectTypeDefinition (boolean)

Read more about this kind on spec.graphql.org (opens in a new tab).

OperationDefinition (boolean)

Read more about this kind on spec.graphql.org (opens in a new tab).

You must use only comment syntax # and not description syntax """ or ".

ScalarTypeDefinition (boolean)

Read more about this kind on spec.graphql.org (opens in a new tab).

UnionTypeDefinition (boolean)

Read more about this kind on spec.graphql.org (opens in a new tab).

Resources