Automattic\WooCommerce\Vendor\GraphQL\Validator
QueryValidationContext::getFragmentSpreads
Method of the class: QueryValidationContext{}
No Hooks.
Returns
Array
Usage
$QueryValidationContext = new QueryValidationContext(); $QueryValidationContext->getFragmentSpreads( $node ): array;
- $node(OperationDefinitionNode|FragmentDefinitionNode) (required)
- .
QueryValidationContext::getFragmentSpreads() QueryValidationContext::getFragmentSpreads code WC 10.9.1
public function getFragmentSpreads(HasSelectionSet $node): array
{
$spreads = $this->fragmentSpreads[$node] ?? null;
if ($spreads === null) {
$spreads = [];
$setsToVisit = [$node->getSelectionSet()];
while ($setsToVisit !== []) {
$set = array_pop($setsToVisit);
foreach ($set->selections as $selection) {
if ($selection instanceof FragmentSpreadNode) {
$spreads[] = $selection;
} else {
assert($selection instanceof FieldNode || $selection instanceof InlineFragmentNode);
$selectionSet = $selection->selectionSet;
if ($selectionSet !== null) {
$setsToVisit[] = $selectionSet;
}
}
}
}
$this->fragmentSpreads[$node] = $spreads;
}
return $spreads;
}