Linter rulesGraphQLtype-naming

type-naming

Since 0.9.0

This rule checks that type names follow a naming convention, PascalCase by default.

Rule Details

Consistent names make a schema predictable for its clients: generated code, documentation and queries read the same everywhere. The rule reports a name that doesn’t follow the convention, with the name converted to it as a suggestion.

Configuration

The configuration block can be a string, the convention, or an object with the properties:

  • convention: camelCase, camelCaseStrict, PascalCase, PascalCaseStrict, snake_case, CONST_CASE (or UPPER_CASE), kebab-case or Header-Case; the strict forms reject two capitals in a row (userID)
  • allowLeadingUnderscore: whether leading underscores are ignored, e.g. in _service; false by default
version: "1.0"
commands:
  lint:
    graphql:
      rules:
        type-naming: [warning, { convention: snake_case, allowLeadingUnderscore: true }]

The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable type-naming 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 UserProfile { id: ID! }

Bad. The linter reports Type name 'user_profile' should be PascalCase, e.g. 'UserProfile'.

type user_profile { id: ID! }

Related rules