Skip to content

selection-set-depth

GraphQLsuspiciousno fixdefault: off

Reports an operation or fragment that nests selection sets deeper than the max option allows. Fragments that are spread are not followed.

The cost of a query grows with its depth: each level can multiply the number of objects the server has to load. A depth limit is a cheap protection against queries that are expensive by accident or on purpose.

To fix, flatten the query, or split it into several requests.

With this configuration:

selection-set-depth:
level: warn
options:
max: 2
Reported
query Q { a { b { c } } }
fragment F on T { a { b } }
graphql:
lint:
rules:
selection-set-depth:
level: warn # off (default), warn, error
options:
max: 7
Option Type Default Description
max int 7 The deepest allowed nesting; the operation’s own selection set is level 1.

Suppress one line with sudsy-disable-next-line selection-set-depth in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
graphql-eslint selection-set-depth partial Fragment spreads are not followed (upstream adds the depth of the spread fragments); no ignore option.