selection-set-depth
What it does
Section titled “What it does”Reports an operation or fragment that nests selection sets deeper than the max option allows. Fragments that are spread are not followed.
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”With this configuration:
selection-set-depth: level: warn options: max: 2query Q { a { b { c } } }fragment F on T { a { b } }Configuration
Section titled “Configuration”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.
Upstream equivalents
Section titled “Upstream equivalents”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. |