# unused-directive-definition

Source: https://apigenie.pl/docs/linter/graphql/rules/unused-directive-definition

This rule checks that the directives defined for schemas are applied in the document.

## Rule Details

An unused directive definition is dead code. Directives with executable locations (e.g. `FIELD`) are meant for operations and are not reported.

## Configuration

This rule has no options.

```yaml
version: "1.0"
commands:
  lint:
    graphql:
      rules:
        unused-directive-definition: warning
```

The rule can be disabled for a node and everything nested in it with an `# apigenie-lint-disable unused-directive-definition` 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**.

```graphql
directive @auth on FIELD_DEFINITION
type Query { me: User @auth }
```

**Bad**. The linter reports `Directive '@auth' is defined but never applied`.

```graphql
directive @auth on FIELD_DEFINITION
type Query { me: User }
```

## When Not to Use It

Disable this rule when the directives are defined in a file and applied in others.
