Linter rulesGraphQLdeprecation-reason-defined

deprecation-reason-defined

Since 0.9.0

This rule checks that @deprecated directives have a reason.

Rule Details

The reason is the only place where a schema tells its clients what to use instead of a deprecated field, argument or enum value. A missing or blank reason is reported.

Configuration

This rule has no options.

version: "1.0"
commands:
  lint:
    graphql:
      rules:
        deprecation-reason-defined: warning

The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable deprecation-reason-defined 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 {
  login: String @deprecated(reason: "Use `name`.")
}

Bad. The linter reports The deprecation of field 'User.login' should have a reason.

type User {
  login: String @deprecated
}

Related rules