selection-set-depth
Since 0.9.0 · In the rulesets: Recommended at warning, Strict at error, All at error
This rule checks that selection sets are nested at most 7 levels deep.
Rule details
Deep queries are expensive to execute and often a sign of over-fetching. The fields of the fragments of the document are counted where they are spread; the root fields have the depth 1.
The rule applies to operations and fragments. An # apigenie-lint-disable selection-set-depth
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.
Configuration
The configuration block is an object with the properties:
maxDepth: the maximum depth, from 1 to 1000, 7 by defaultignore: the names of fields whose selections are not counted, e.g.edges
version: "1.0"
commands:
lint:
graphql:
rules:
selection-set-depth: [warning, { maxDepth: 10, ignore: [edges, node] }]
Examples
Good.
query Me { me { friends { name } } }
Bad. The linter reports Field 'name' of operation 'Me' is nested deeper than the maximum depth of 7.
query Me { me { friends { friends { friends { friends { friends { friends { name } } } } } } } }
Turn it off or change its severity
In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.graphql has the details.
commands:
lint:
graphql:
rules:
selection-set-depth: off