Linter rulesGraphQLoperation-name-suffix
operation-name-suffix
Since 0.9.0
This rule checks that operation and fragment names don’t end with a redundant suffix.
Rule Details
The keyword already gives the kind of a definition: query GetUserQuery repeats it. The default suffixes are Query, Mutation, Subscription and Fragment.
Configuration
The configuration block is an object with the suffixes property, the list of suffixes
that are reported.
version: "1.0"
commands:
lint:
graphql:
rules:
operation-name-suffix: [error, { suffixes: [Query, Mutation] }]
The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable operation-name-suffix comment on the node, or for a whole file with the comment at the top of the file, separated from the first definition by a blank line. It applies to operations and fragments.
Examples
Good.
query GetUser { me { id } }
Bad. The linter reports Operation 'GetUserQuery' should not end with 'Query'.
query GetUserQuery { me { id } }