Linter rulesGraphQLroot-fields-nullable

root-fields-nullable

Since 0.9.0

This rule checks that the fields of the query and mutation root types are nullable.

Rule Details

An error in a non-null field nulls its parent; for a root field, the parent is the whole data of the response. Nullable root fields keep the other fields of a response when one of them fails.

Configuration

This rule has no options.

version: "1.0"
commands:
  lint:
    graphql:
      rules:
        root-fields-nullable: warning

The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable root-fields-nullable 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(id: ID!): User }

Bad. The linter reports Field 'Query.user' of the query root type should be nullable, not 'User!'.

type Query { user(id: ID!): User! }