useInputName (GraphQL)
Language GraphQL
Summary
Section titled βSummaryβ- Rule available since:
v2.3.14 - Diagnostic Category:
lint/style/useInputName - This rule isnβt recommended, so you need to enable it.
- This rule doesnβt have a fix.
- The default severity of this rule is information.
- Sources:
- Same as
@graphql-eslint/input-name
- Same as
How to configure
Section titled βHow to configureβ{ "linter": { "rules": { "style": { "useInputName": "error" } } }}Description
Section titled βDescriptionβRequire mutation arguments to be named input.
A consistent argument name makes mutations predictable for schema users and client tools.
Examples
Section titled βExamplesβInvalid
Section titled βInvalidβtype Mutation { SetMessage(message: InputMessage): String}code-block.graphql:2:14 lint/style/useInputName ββββββββββββββββββββββββββββββββββββββββββββββββββββ
βΉ Unexpected input name, expected the input name "message" to be named "input".
1 β type Mutation {
> 2 β SetMessage(message: InputMessage): String
β ^^^^^^^^^^^^^^^^^^^^^
3 β }
4 β
βΉ Using the same name for all input parameters will make your schemas easier to consume and more predictable.
type Mutation { SetMessage(input: SetMessageInput): String}Options
Section titled βOptionsβcheckInputType
Section titled βcheckInputTypeβOptionally requires the input type to be named <mutation name>Input, so schema readers can
identify its related mutation.
"off"does not check the type name;"loose"checks the name without regard to letter case;"strict"requires matching letter case.
Defaults to "off".
{ "linter": { "rules": { "style": { "useInputName": { "level": "on", "options": { "checkInputType": "loose" } } } } }}type Mutation { SetMessage(input: InputMessage): String}code-block.graphql:2:14 lint/style/useInputName ββββββββββββββββββββββββββββββββββββββββββββββββββββ
βΉ Unexpected input type name, expected the input type name "InputMessage" to be named "SetMessageInput".
1 β type Mutation {
> 2 β SetMessage(input: InputMessage): String
β ^^^^^^^^^^^^^^^^^^^
3 β }
4 β
βΉ Using the name of the operation in the input type name will make it easier to find the operation that the input type belongs to.
type Mutation { SetMessage(input: setMessageInput): String}type Mutation { SetMessage(input: SetMessageInput): String}{ "linter": { "rules": { "style": { "useInputName": { "level": "on", "options": { "checkInputType": "strict" } } } } }}type Mutation { SetMessage(input: InputMessage): String}code-block.graphql:2:14 lint/style/useInputName ββββββββββββββββββββββββββββββββββββββββββββββββββββ
βΉ Unexpected input type name, expected the input type name "InputMessage" to be named "SetMessageInput".
1 β type Mutation {
> 2 β SetMessage(input: InputMessage): String
β ^^^^^^^^^^^^^^^^^^^
3 β }
4 β
βΉ Using the name of the operation in the input type name will make it easier to find the operation that the input type belongs to.
type Mutation { SetMessage(input: setMessageInput): String}code-block.graphql:2:14 lint/style/useInputName ββββββββββββββββββββββββββββββββββββββββββββββββββββ
βΉ Unexpected input type name, expected the input type name "setMessageInput" to be named "SetMessageInput".
1 β type Mutation {
> 2 β SetMessage(input: setMessageInput): String
β ^^^^^^^^^^^^^^^^^^^^^^
3 β }
4 β
βΉ Using the name of the operation in the input type name will make it easier to find the operation that the input type belongs to.
type Mutation { SetMessage(input: SetMessageInput): String}Related links
Section titled βRelated linksβCopyright (c) 2023-present Biome Developers and Contributors.