Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules

QueryDepth::fieldDepthprotectedWC 1.0

Method of the class: QueryDepth{}

No Hooks.

Returns

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->fieldDepth( $node, $depth, $maxDepth ): int;
$node(OperationDefinitionNode|FieldNode|InlineFragmentNode|FragmentDefinitionNode) (required)
.
$depth(int)
.
$maxDepth(int)
.

QueryDepth::fieldDepth() code WC 10.9.4

protected function fieldDepth(Node $node, int $depth = 0, int $maxDepth = 0): int
{
    if ($node->selectionSet instanceof SelectionSetNode) {
        foreach ($node->selectionSet->selections as $childNode) {
            $maxDepth = $this->nodeDepth($childNode, $depth, $maxDepth);
        }
    }

    return $maxDepth;
}