Linter rulesGraphQLno-typename-prefix
no-typename-prefix
Since 0.9.0
This rule checks that field names don’t start with the name of their type, as in User.userId.
Rule Details
The type already gives the context of a field: user.id reads better than user.userId. A field is reported when its name starts with the type name in camelCase followed by an upper-case letter, a digit or an underscore, so User.users is not reported.
Configuration
This rule has no options.
version: "1.0"
commands:
lint:
graphql:
rules:
no-typename-prefix: warning
The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable no-typename-prefix 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 definitions.
Examples
Good.
type User { id: ID!, name: String }
Bad. The linter reports Field 'userId' should not start with the name of its type 'User'.
type User { userId: ID! }