Skip to Content
🚧 This is WIP documentation for v4 of the plugin. For v3 click here.
ESLGraphQL-ESLint
Rulesinput-name

input-name

💡 This rule provides suggestions 

  • 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

Resources

Last updated on