Skip to content

Commit 712bd73

Browse files
committed
fix(dataproducer): Fix entity label handling
1 parent 3aaa111 commit 712bd73

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

modules/graphql_core/src/Plugin/GraphQL/Fields/Entity/EntityLabel.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ class EntityLabel extends FieldPluginBase {
2323
*/
2424
public function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
2525
if ($value instanceof EntityInterface) {
26-
yield $value->label();
26+
/** @var \Drupal\Core\Access\AccessResultInterface $accessResult */
27+
$accessResult = $value->access('view label', NULL, TRUE);
28+
$context->addCacheableDependency($accessResult);
29+
if ($accessResult->isAllowed()) {
30+
yield $value->label();
31+
}
32+
yield NULL;
2733
}
2834
}
2935

0 commit comments

Comments
 (0)