Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules
OverlappingFieldsCanBeMerged::getReferencedFieldsAndFragmentNames
Given a reference to a fragment, return the represented collection of fields as well as a list of nested fragment names referenced via fragment spreads.
Method of the class: OverlappingFieldsCanBeMerged{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->getReferencedFieldsAndFragmentNames( $context, $fragment ): array;
- $context(QueryValidationContext) (required)
- .
- $fragment(FragmentDefinitionNode) (required)
- .
OverlappingFieldsCanBeMerged::getReferencedFieldsAndFragmentNames() OverlappingFieldsCanBeMerged::getReferencedFieldsAndFragmentNames code WC 11.0.1
protected function getReferencedFieldsAndFragmentNames(
QueryValidationContext $context,
FragmentDefinitionNode $fragment
): array {
// Short-circuit building a type from the AST if possible.
if (isset($this->cachedFieldsAndFragmentNames[$fragment->selectionSet])) {
return $this->cachedFieldsAndFragmentNames[$fragment->selectionSet];
}
$fragmentType = AST::typeFromAST([$context->getSchema(), 'getType'], $fragment->typeCondition);
return $this->getFieldsAndFragmentNames(
$context,
$fragmentType,
$fragment->selectionSet
);
}