requireNullableResultInRoot
| Property | Value |
|---|---|
| Config name | requireNullableResultInRoot |
| Default severity | — |
| Context | Schema |
| In recommended | No |
What it checks
Section titled “What it checks”Requires fields on root types (Query, Mutation, Subscription) to return nullable types. When a root field returns a non-null named type and an error occurs at runtime, GraphQL’s null-bubbling behavior propagates the null up to the nearest nullable parent — potentially nulling out the entire data response. Making root fields nullable isolates errors to the individual field that failed, keeping the rest of the response intact.
Non-null list types like [User!]! are intentionally allowed: an empty list is a valid non-null payload, so the null-bubbling concern doesn’t apply at the list level. This matches @graphql-eslint/eslint-plugin.
The rule also works with custom root type names defined via a schema definition.
Examples
Section titled “Examples”# ❌ Bad — root field returns a non-null named typetype Query { user(id: ID!): User!}# ✅ Good — root fields are nullable, or non-null liststype Query { user(id: ID!): User users: [User!]!}Configuration
Section titled “Configuration”extensions: graphql-analyzer: lint: rules: requireNullableResultInRoot: warn