input-name
đĄ This rule provides suggestions (opens in a new tab)
- Category:
Schema
- Rule name:
@graphql-eslint/input-name
- Requires GraphQL Schema:
false
âšī¸ - Requires GraphQL Operations:
false
âšī¸
Require mutation argument to be always called "input" and input type to be called Mutation name + "Input". Using the same name for all input parameters will make your schemas easier to consume and more predictable. Using the same name as mutation for InputType will make it easier to find mutations that InputType belongs to.
Usage Examples
Incorrect
# eslint @graphql-eslint/input-name: ['error', { checkInputType: true }]
type Mutation {
SetMessage(message: InputMessage): String
}
Correct (with checkInputType
)
# eslint @graphql-eslint/input-name: ['error', { checkInputType: true }]
type Mutation {
SetMessage(input: SetMessageInput): String
}
Correct (without checkInputType
)
# eslint @graphql-eslint/input-name: ['error', { checkInputType: false }]
type Mutation {
SetMessage(input: AnyInputTypeName): String
}
Config Schema
The schema defines the following properties:
checkInputType
(boolean)
Check that the input type name follows the convention <mutationName>Input
Default: false
caseSensitiveInputType
(boolean)
Allow for case discrepancies in the input type name
Default: true
checkQueries
(boolean)
Apply the rule to Queries
Default: false
checkMutations
(boolean)
Apply the rule to Mutations
Default: true