# root-fields-nullable

Source: https://apigenie.pl/docs/linter/graphql/rules/root-fields-nullable

A rule of the GraphQL linter, which reads GraphQL schemas and operations. Since 0.9.0. In the rulesets: Strict at error, All at error.

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.

The rule applies to definitions. An `# apigenie-lint-disable root-fields-nullable` comment on a node
turns it off for the node and everything nested in it; at the top of the file, separated from the
first definition by a blank line, the comment turns it off for the whole file.

## Examples

**Good**.

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

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

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