public function EntityField::resolveValues in GraphQL 8.3
Retrieve the list of field values.
Always returns a list of field values. Even for single value fields. Single/multi field handling is responsibility of the base class.
Parameters
mixed $value: The current object value.
array $args: Field arguments.
$context: The resolve context.
\GraphQL\Type\Definition\ResolveInfo $info: The resolve info object.
Return value
\Generator The value generator.
Overrides FieldPluginBase::resolveValues
File
- modules/
graphql_core/ src/ Plugin/ GraphQL/ Fields/ Entity/ EntityField.php, line 24
Class
- EntityField
- Plugin annotation @GraphQLField( id = "entity_field", secure = true, weight = -2, deriver = "Drupal\graphql_core\Plugin\Deriver\Fields\EntityFieldDeriver", )
Namespace
Drupal\graphql_core\Plugin\GraphQL\Fields\EntityCode
public function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
if ($value instanceof FieldableEntityInterface) {
$definition = $this
->getPluginDefinition();
$name = $definition['field'];
if ($value
->hasField($name)) {
/** @var \Drupal\Core\Field\FieldItemListInterface $items */
$items = $value
->get($name);
$access = $items
->access('view', NULL, TRUE);
if ($access
->isAllowed()) {
foreach ($items as $item) {
$output = !empty($definition['property']) ? $this
->resolveItem($item, $args, $context, $info) : $item;
(yield new CacheableValue($output, [
$access,
]));
}
}
}
}
}