Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules
OverlappingFieldsCanBeMerged::findConflictsWithinSelectionSet
Find all conflicts found "within" a selection set, including those found via spreading in fragments. Called when visiting each SelectionSet in the Automattic\WooCommerce\Vendor\GraphQL Document.
Method of the class: OverlappingFieldsCanBeMerged{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->findConflictsWithinSelectionSet( $context, ?Type $parentType, $selectionSet ): array;
- $context(QueryValidationContext) (required)
- .
- ?Type $parentType(required)
- .
- $selectionSet(SelectionSetNode) (required)
- .
OverlappingFieldsCanBeMerged::findConflictsWithinSelectionSet() OverlappingFieldsCanBeMerged::findConflictsWithinSelectionSet code WC 10.9.1
protected function findConflictsWithinSelectionSet(
QueryValidationContext $context,
?Type $parentType,
SelectionSetNode $selectionSet
): array {
[$fieldMap, $fragmentNames] = $this->getFieldsAndFragmentNames(
$context,
$parentType,
$selectionSet
);
$conflicts = [];
// (A) Find all conflicts "within" the fields of this selection set.
// Note: this is the *only place* `collectConflictsWithin` is called.
$this->collectConflictsWithin(
$context,
$conflicts,
$fieldMap
);
$fragmentNamesLength = count($fragmentNames);
if ($fragmentNamesLength !== 0) {
// (B) Then collect conflicts between these fields and those represented by
// each spread fragment name found.
$comparedFragments = [];
for ($i = 0; $i < $fragmentNamesLength; ++$i) {
$this->collectConflictsBetweenFieldsAndFragment(
$context,
$conflicts,
$comparedFragments,
false,
$fieldMap,
$fragmentNames[$i]
);
// (C) Then compare this fragment with all other fragments found in this
// selection set to collect conflicts between fragments spread together.
// This compares each item in the list of fragment names to every other item
// in that same list (except for itself).
for ($j = $i + 1; $j < $fragmentNamesLength; ++$j) {
$this->collectConflictsBetweenFragments(
$context,
$conflicts,
false,
$fragmentNames[$i],
$fragmentNames[$j]
);
}
}
}
return $conflicts;
}