src/Type/Definition/ResolveInfo.php
public function getFieldSelection($depth = 0)
    {
        $fields = [];

        /** @var FieldNode $fieldNode */
        foreach ($this->fieldNodes as $fieldNode) {
            $fields = array_merge_recursive($fields, $this->foldSelectionSet($fieldNode->selectionSet, $depth));
        }

        return $fields;
    }
public function getFieldSelection($depth = 0)
    {
        $fields = [];

        /** @var FieldNode $fieldNode */
        foreach ($this->fieldNodes as $fieldNode) {
            $fields = array_merge_recursive($fields, $this->foldSelectionSet($fieldNode->selectionSet, $depth));
        }

        return $fields;
    }
public function getFieldSelection ( $ depth = 0 ) { $ fields = [ ] ; /** @var FieldNode $fieldNode */ foreach ( $ this -> fieldNodes as $ fieldNode ) { $ fields = array_merge_recursive ( $ fields , $ this -> foldSelectionSet ( $ fieldNode -> selectionSet , $ depth ) ) ; } return $ fields ; }
Helper method that returns names of all fields selected in query for
$this->fieldName up to $depth levels

Example:
query MyQuery{
{
root {
id,
nested {
nested1
nested2 {
nested3
}
}
}
}

Given this ResolveInfo instance is a part of "root" field resolution, and $depth === 1,
method will return:
[
'id' => true,
'nested' => [
nested1 => true,
nested2 => true
]
]

Warning: this method it is a naive implementation which does not take into account
conditional typed fragments. So use it with care for fields of interface and union types.

@param int $depth How many levels to include in output

@return bool[]

@api
Helper method that returns names of all fields selected in query for $this - > fieldName up to $depth levels