Linter rulesGraphQLquery-root-defined

query-root-defined

Since 0.9.0

This rule checks that the schema has a query root operation type.

Rule Details

A schema must have a query root type. Without a schema definition, the type named Query is the query root type. Documents that hold only a part of a schema should not use this rule.

Configuration

This rule has no options.

version: "1.0"
commands:
  lint:
    graphql:
      rules:
        query-root-defined: warning

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

Bad. The linter reports The schema should have a query root operation type (type Query).

type User { id: ID! }

When Not to Use It

Disable this rule when the schema is split across files, and the query root type is in another file.

Further reading