88use Drupal \Core \Entity \TranslatableInterface ;
99use Drupal \Core \Plugin \ContainerFactoryPluginInterface ;
1010use Drupal \Core \Session \AccountInterface ;
11+ use Drupal \graphql \GraphQL \Execution \FieldContext ;
1112use Drupal \graphql \Plugin \GraphQL \DataProducer \DataProducerPluginBase ;
1213use Symfony \Component \DependencyInjection \ContainerInterface ;
1314
@@ -97,10 +98,11 @@ public function __construct(array $configuration, $pluginId, $pluginDefinition,
9798 * @param bool|null $access
9899 * @param \Drupal\Core\Session\AccountInterface|null $accessUser
99100 * @param string|null $accessOperation
101+ * @param \Drupal\graphql\GraphQL\Execution\FieldContext $context
100102 *
101103 * @return \Drupal\Core\Entity\EntityInterface|null
102104 */
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 ) {
104106 if ($ entity instanceof TranslatableInterface && $ entity ->isTranslatable ()) {
105107 $ entity = $ entity ->getTranslation ($ language );
106108 $ entity ->addCacheContexts (["static:language: {$ language }" ]);
@@ -109,6 +111,7 @@ public function resolve(EntityInterface $entity, $language, ?bool $access, ?Acco
109111 if ($ access ) {
110112 /** @var \Drupal\Core\Access\AccessResultInterface $accessResult */
111113 $ accessResult = $ entity ->access ($ accessOperation , $ accessUser , TRUE );
114+ $ context ->addCacheableDependency ($ accessResult );
112115 if (!$ accessResult ->isAllowed ()) {
113116 return NULL ;
114117 }
0 commit comments