@graphql-eslint/eslint-plugin
Version:
GraphQL plugin for ESLint
81 lines (51 loc) • 1.91 kB
Markdown
# `input-name`
💡 This rule provides
[suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions)
- Category: `Schema`
- Rule name: `@graphql-eslint/input-name`
- Requires GraphQL Schema: `false` [ℹ️](../../README.md#extended-linting-rules-with-graphql-schema)
- Requires GraphQL Operations: `false`
[ℹ️](../../README.md#extended-linting-rules-with-siblings-operations)
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
```graphql
# eslint @graphql-eslint/input-name: ['error', { checkInputType: true }]
type Mutation {
SetMessage(message: InputMessage): String
}
```
### Correct (with checkInputType)
```graphql
# eslint @graphql-eslint/input-name: ['error', { checkInputType: true }]
type Mutation {
SetMessage(input: SetMessageInput): String
}
```
### Correct (without checkInputType)
```graphql
# 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
- [Rule source](../../packages/plugin/src/rules/input-name.ts)
- [Test source](../../packages/plugin/tests/input-name.spec.ts)