Skip to Content
This is documentation for v4 of the plugin. For v3 click here.
ESLGraphQL-ESLint
Rulesno-deprecated

no-deprecated

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

💡 This rule provides suggestions

  • Category: Operations
  • Rule name: @graphql-eslint/no-deprecated
  • Requires GraphQL Schema: true ℹ️
  • Requires GraphQL Operations: false ℹ️
Enforce that deprecated fields or enum values are not in use by operations.

Usage Examples

Incorrect (field)

# eslint @graphql-eslint/no-deprecated: 'error' # In your schema type User { id: ID! name: String! @deprecated(reason: "old field, please use fullName instead") fullName: String! } # Query query user { user { name # This is deprecated, so you'll get an error } }

Incorrect (enum value)

# eslint @graphql-eslint/no-deprecated: 'error' # In your schema type Mutation { changeSomething(type: SomeType): Boolean! } enum SomeType { NEW OLD @deprecated(reason: "old field, please use NEW instead") } # Mutation mutation { changeSomething( type: OLD # This is deprecated, so you'll get an error ) { ... } }

Correct

# eslint @graphql-eslint/no-deprecated: 'error' # In your schema type User { id: ID! name: String! @deprecated(reason: "old field, please use fullName instead") fullName: String! } # Query query user { user { id fullName } }

Resources

Last updated on