✅ The "extends": "plugin:@graphql-eslint/operations-recommended"
property in a configuration file enables this rule.
- Category:
Operations
- Rule name:
@graphql-eslint/require-id-when-available
- Requires GraphQL Schema:
true
ℹ️ - Requires GraphQL Operations:
true
ℹ️
Enforce selecting specific fields when they are available on the GraphQL type.
# eslint @graphql-eslint/require-id-when-available: 'error'
# In your schema
type User {
id: ID!
name: String!
}
# Query
query {
user {
name
}
}
# eslint @graphql-eslint/require-id-when-available: 'error'
# In your schema
type User {
id: ID!
name: String!
}
# Query
query {
user {
id
name
}
}
The schema defines the following properties:
The object must be one of the following types:
asString
asArray
Default: "id"
The schema defines the following additional types: