Linter rulesGraphQLunreachable-types

unreachable-types

Since 0.9.0

This rule checks that every type is reachable from the root operation types.

Rule Details

A type that no field, argument or union reaches is dead code: clients cannot use it. Types are reached through the fields, arguments, input fields, union members and interfaces of reached types, the implementations of reached interfaces, and the arguments of directive definitions. Documents without root operation types are not checked.

Configuration

This rule has no options.

version: "1.0"
commands:
  lint:
    graphql:
      rules:
        unreachable-types: warning

The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable unreachable-types 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 Query { user: User }
type User { id: ID! }

Bad. The linter reports Object type 'Orphan' is not reachable from the root operation types.

type Query { user: User }
type User { id: ID! }
type Orphan { id: ID! }

When Not to Use It

Disable this rule when the schema is split across files.