# deprecation-reason-defined

Source: https://api-genie.dev/docs/linter/graphql/rules/deprecation-reason-defined

A rule of the GraphQL linter, which reads GraphQL schemas and operations. Since 0.9.0. In the rulesets: Recommended at warning, Strict at error, All at error.

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.

The rule applies to definitions. An `# apigenie-lint-disable deprecation-reason-defined` 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**.

```graphql
type User {
  login: String @deprecated(reason: "Use `name`.")
}
```

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

```graphql
type User {
  login: String @deprecated
}
```
