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