Linter rulesGraphQLselection-set-depth
selection-set-depth
Since 0.9.0
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.
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] }]
The rule can be disabled for a node and everything nested in it with an # apigenie-lint-disable selection-set-depth comment on the node, or for a whole file with the comment at the top of the file, separated from the first definition by a blank line. It applies to operations and fragments.
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 } } } } } } } }