| 
9 | 9 | use Drupal\Core\Language\LanguageInterface;  | 
10 | 10 | use Drupal\Core\Plugin\ContainerFactoryPluginInterface;  | 
11 | 11 | use Drupal\Core\Session\AccountInterface;  | 
 | 12 | +use Drupal\graphql\GraphQL\Execution\FieldContext;  | 
12 | 13 | use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;  | 
13 | 14 | use Symfony\Component\DependencyInjection\ContainerInterface;  | 
14 | 15 | 
 
  | 
@@ -96,20 +97,22 @@ public function __construct(array $configuration, $pluginId, $pluginDefinition,  | 
96 | 97 |    * @param bool|null $access  | 
97 | 98 |    * @param \Drupal\Core\Session\AccountInterface|null $accessUser  | 
98 | 99 |    * @param string|null $accessOperation  | 
 | 100 | +   * @param \Drupal\graphql\GraphQL\Execution\FieldContext $context  | 
99 | 101 |    *  | 
100 | 102 |    * @return array|null  | 
101 | 103 |    */  | 
102 |  | -  public function resolve(EntityInterface $entity, ?bool $access, ?AccountInterface $accessUser, ?string $accessOperation) {  | 
 | 104 | +  public function resolve(EntityInterface $entity, ?bool $access, ?AccountInterface $accessUser, ?string $accessOperation, FieldContext $context) {  | 
103 | 105 |     if ($entity instanceof TranslatableInterface && $entity->isTranslatable()) {  | 
104 | 106 |       $languages = $entity->getTranslationLanguages();  | 
105 | 107 | 
 
  | 
106 |  | -      return array_map(function (LanguageInterface $language) use ($entity, $access, $accessOperation, $accessUser) {  | 
 | 108 | +      return array_map(function (LanguageInterface $language) use ($entity, $access, $accessOperation, $accessUser, $context) {  | 
107 | 109 |         $langcode = $language->getId();  | 
108 | 110 |         $entity = $entity->getTranslation($langcode);  | 
109 | 111 |         $entity->addCacheContexts(["static:language:{$langcode}"]);  | 
110 | 112 |         if ($access) {  | 
111 | 113 |           /** @var \Drupal\Core\Access\AccessResultInterface $accessResult */  | 
112 | 114 |           $accessResult = $entity->access($accessOperation, $accessUser, TRUE);  | 
 | 115 | +          $context->addCacheableDependency($accessResult);  | 
113 | 116 |           if (!$accessResult->isAllowed()) {  | 
114 | 117 |             return NULL;  | 
115 | 118 |           }  | 
 | 
0 commit comments