🎉 Welcome to the new GraphQL-ESLint website. Try new playground page →
Rules
Known Directives

known-directives

✅ The "extends": "plugin:@graphql-eslint/schema-recommended" and "plugin:@graphql-eslint/operations-recommended" property in a configuration file enables this rule.

  • Category: Schema & Operations
  • Rule name: @graphql-eslint/known-directives
  • Requires GraphQL Schema: true ℹī¸
  • Requires GraphQL Operations: false ℹī¸

A GraphQL document is only valid if all @directives are known by the schema and legally positioned.

This rule is a wrapper around a graphql-js validation function.

Usage Examples

Valid

# eslint @graphql-eslint/known-directives: ['error', { ignoreClientDirectives: ['client'] }]
 
{
  product {
    someClientField @client
  }
}

Config Schema

The schema defines the following properties:

ignoreClientDirectives (array, required)

The object is an array with all elements of the type string.

Additional restrictions:

  • Minimum items: 1
  • Unique items: true

Resources