no-typename-prefix

Since 0.9.0 · In the rulesets: Recommended at warning, Strict at error, All at error

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.

The rule applies to definitions. An # apigenie-lint-disable no-typename-prefix comment on a node turns it off for the node and everything nested in it; at the top of the file, separated from the first definition by a blank line, the comment turns it off for the whole file.

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! }

Turn it off or change its severity

In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.graphql has the details.

commands:
  lint:
    graphql:
      rules:
        no-typename-prefix: off
Last updated on View as Markdown
Was this helpful?