6 declare(strict_types=1);
10 use GraphQL\Language\AST\FieldNode;
23 public function calculate(FieldNode $fieldNode) : int
25 $selections = $fieldNode->selectionSet->selections ?? [];
26 $depth = count($selections) ? 1 : 0;
28 foreach ($selections as $node) {
29 if ($node->kind ===
'InlineFragment') {
33 $childrenDepth[] = $this->
calculate($node);
36 return $depth + max($childrenDepth);
calculate(FieldNode $fieldNode)