Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules
OverlappingFieldsCanBeMerged::getFieldsAndFragmentNames
Given a selection set, return the collection of fields (a mapping of response name to field ASTs and definitions) as well as a list of fragment names referenced via fragment spreads.
Method of the class: OverlappingFieldsCanBeMerged{}
No Hooks.
Returns
Array{FieldMap,. array<int, string>}
Usage
// protected - for code of main (parent) or child class $result = $this->getFieldsAndFragmentNames( $context, ?Type $parentType, $selectionSet ): array;
- $context(QueryValidationContext) (required)
- .
- ?Type $parentType(required)
- .
- $selectionSet(SelectionSetNode) (required)
- .
OverlappingFieldsCanBeMerged::getFieldsAndFragmentNames() OverlappingFieldsCanBeMerged::getFieldsAndFragmentNames code WC 10.9.1
protected function getFieldsAndFragmentNames(
QueryValidationContext $context,
?Type $parentType,
SelectionSetNode $selectionSet
): array {
if (! isset($this->cachedFieldsAndFragmentNames[$selectionSet])) {
/** @phpstan-var FieldMap $astAndDefs */
$astAndDefs = [];
/** @var array<string, bool> $fragmentNames */
$fragmentNames = [];
$this->internalCollectFieldsAndFragmentNames(
$context,
$parentType,
$selectionSet,
$astAndDefs,
$fragmentNames
);
return $this->cachedFieldsAndFragmentNames[$selectionSet] = [$astAndDefs, array_keys($fragmentNames)];
}
return $this->cachedFieldsAndFragmentNames[$selectionSet];
}