no-deprecated
â
The "extends": "plugin:@graphql-eslint/operations-recommended"
property in a configuration file
enables this rule.
đĄ This rule provides suggestions (opens in a new tab)
- 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
}
}