Linter rulesGraphQLunused-directive-definition
unused-directive-definition
Since 0.9.0
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.
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.
directive @auth on FIELD_DEFINITION
type Query { me: User @auth }
Bad. The linter reports Directive '@auth' is defined but never applied.
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.