Automattic\WooCommerce\Api\Infrastructure
GraphQLControllerBase::walk_depth_in_depth
Walk a selection set counting every field in the deepest chain, leaves included. Produces the "shape" metric surfaced alongside the enforcement metric in debug output.
Метод класса: GraphQLControllerBase{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->walk_depth_in_depth( ?SelectionSetNode $selection_set, $depth ): int;
- ?SelectionSetNode $selection_set(обязательный)
- .
- $depth(int) (обязательный)
- The depth of the selection set's parent.
Код GraphQLControllerBase::walk_depth_in_depth() GraphQLControllerBase::walk depth in depth WC 11.0.1
private function walk_depth_in_depth( ?SelectionSetNode $selection_set, int $depth ): int {
if ( null === $selection_set ) {
return $depth;
}
$max = $depth;
foreach ( $selection_set->selections as $selection ) {
if ( $selection instanceof FieldNode ) {
$max = max( $max, $this->walk_depth_in_depth( $selection->selectionSet, $depth + 1 ) );
} elseif ( $selection instanceof InlineFragmentNode ) {
$max = max( $max, $this->walk_depth_in_depth( $selection->selectionSet, $depth ) );
}
}
return $max;
}