Linter rulesGraphQLdeprecation-date-defined

deprecation-date-defined

Since 0.9.0

This rule checks that @deprecated directives have a deletion date that has not passed.

Rule Details

A deletion date tells clients how long a deprecated element will stay, and reminds the schema authors to remove it. The date is an argument of @deprecated, deletionDate by default, in the format YYYY-MM-DD. A missing or invalid date, or a date in the past, is reported. The argument has to be added to the definition of @deprecated that the server uses.

Configuration

The configuration block is an object with the properties:

  • argumentName: the argument with the date, deletionDate by default
  • today: the current date as YYYY-MM-DD, for reproducible runs; the date of the run by default
version: "1.0"
commands:
  lint:
    graphql:
      rules:
        deprecation-date-defined: [warning, { argumentName: removeAfter }]

The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable deprecation-date-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`.", deletionDate: "2099-01-01")
}

Bad. The linter reports The deprecation of field 'User.login' should have a deletion date ('deletionDate' argument).

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

Related rules