Automattic\WooCommerce\Vendor\GraphQL\Type\Definition
ResolveInfo::getFieldSelection
Returns names of all fields selected in query for $this->fieldName up to $depth levels.
Example: { root {
id
nested {
nested1
nested2 {
nested3
}
}
} }
Given this ResolveInfo instance is a part of root field resolution, and $depth === 1, this method will return: [
'id' => true, 'nested' => [ 'nested1' => true, 'nested2' => true, ],
]
This method does not consider conditional typed fragments. Use it with care for fields of interface and union types.
Method of the class: ResolveInfo{}
No Hooks.
Returns
Array
Usage
$ResolveInfo = new ResolveInfo(); $ResolveInfo->getFieldSelection( $depth ): array;
- $depth(int)
- How many levels to include in the output beyond the first.
ResolveInfo::getFieldSelection() ResolveInfo::getFieldSelection code WC 10.9.1
public function getFieldSelection(int $depth = 0): array
{
$fields = [];
foreach ($this->fieldNodes as $fieldNode) {
$selectionSet = $fieldNode->selectionSet;
if ($selectionSet !== null) {
$fields = array_merge_recursive(
$fields,
$this->foldSelectionSet($selectionSet, $depth)
);
}
}
return $fields;
}