|
| 1 | +diff --git a/src/Plugin/GraphQL/DataProducer/Entity/EntityLoad.php b/src/Plugin/GraphQL/DataProducer/Entity/EntityLoad.php |
| 2 | +index 867a28c..386b2b3 100644 |
| 3 | +--- a/src/Plugin/GraphQL/DataProducer/Entity/EntityLoad.php |
| 4 | ++++ b/src/Plugin/GraphQL/DataProducer/Entity/EntityLoad.php |
| 5 | +@@ -172,8 +172,10 @@ class EntityLoad extends DataProducerPluginBase implements ContainerFactoryPlugi |
| 6 | + |
| 7 | + // Get the correct translation. |
| 8 | + if (isset($language) && $language !== $entity->language()->getId() && $entity instanceof TranslatableInterface) { |
| 9 | +- $entity = $entity->getTranslation($language); |
| 10 | +- $entity->addCacheContexts(["static:language:{$language}"]); |
| 11 | ++ if ($entity->hasTranslation($language)) { |
| 12 | ++ $entity = $entity->getTranslation($language); |
| 13 | ++ $entity->addCacheContexts(["static:language:{$language}"]); |
| 14 | ++ } |
| 15 | + } |
| 16 | + |
| 17 | + // Check if the passed user (or current user if none is passed) has access |
| 18 | +diff --git a/src/Plugin/GraphQL/DataProducer/Entity/EntityLoadByUuid.php b/src/Plugin/GraphQL/DataProducer/Entity/EntityLoadByUuid.php |
| 19 | +index 10e2d40..e4e6ed0 100644 |
| 20 | +--- a/src/Plugin/GraphQL/DataProducer/Entity/EntityLoadByUuid.php |
| 21 | ++++ b/src/Plugin/GraphQL/DataProducer/Entity/EntityLoadByUuid.php |
| 22 | +@@ -165,8 +165,10 @@ class EntityLoadByUuid extends DataProducerPluginBase implements ContainerFactor |
| 23 | + |
| 24 | + // Get the correct translation. |
| 25 | + if (isset($language) && $language != $entity->language()->getId() && $entity instanceof TranslatableInterface) { |
| 26 | +- $entity = $entity->getTranslation($language); |
| 27 | +- $entity->addCacheContexts(["static:language:{$language}"]); |
| 28 | ++ if ($entity->hasTranslation($language)) { |
| 29 | ++ $entity = $entity->getTranslation($language); |
| 30 | ++ $entity->addCacheContexts(["static:language:{$language}"]); |
| 31 | ++ } |
| 32 | + } |
| 33 | + |
| 34 | + // Check if the passed user (or current user if none is passed) has access |
| 35 | +diff --git a/src/Plugin/GraphQL/DataProducer/Entity/EntityLoadMultiple.php b/src/Plugin/GraphQL/DataProducer/Entity/EntityLoadMultiple.php |
| 36 | +index 2a0259c..27a19e5 100644 |
| 37 | +--- a/src/Plugin/GraphQL/DataProducer/Entity/EntityLoadMultiple.php |
| 38 | ++++ b/src/Plugin/GraphQL/DataProducer/Entity/EntityLoadMultiple.php |
| 39 | +@@ -172,8 +172,10 @@ class EntityLoadMultiple extends DataProducerPluginBase implements ContainerFact |
| 40 | + } |
| 41 | + |
| 42 | + if (isset($language) && $language !== $entities[$id]->language()->getId() && $entities[$id] instanceof TranslatableInterface) { |
| 43 | +- $entities[$id] = $entities[$id]->getTranslation($language); |
| 44 | +- $entities[$id]->addCacheContexts(["static:language:{$language}"]); |
| 45 | ++ if ($entities[$id]->hasTranslation($language)) { |
| 46 | ++ $entities[$id] = $entities[$id]->getTranslation($language); |
| 47 | ++ $entities[$id]->addCacheContexts(["static:language:{$language}"]); |
| 48 | ++ } |
| 49 | + } |
| 50 | + |
| 51 | + if ($access) { |
| 52 | +diff --git a/src/Plugin/GraphQL/DataProducer/Entity/EntityTranslation.php b/src/Plugin/GraphQL/DataProducer/Entity/EntityTranslation.php |
| 53 | +index 633bdc2..3773a9b 100644 |
| 54 | +--- a/src/Plugin/GraphQL/DataProducer/Entity/EntityTranslation.php |
| 55 | ++++ b/src/Plugin/GraphQL/DataProducer/Entity/EntityTranslation.php |
| 56 | +@@ -101,7 +101,7 @@ class EntityTranslation extends DataProducerPluginBase implements ContainerFacto |
| 57 | + * @return \Drupal\Core\Entity\EntityInterface|null |
| 58 | + */ |
| 59 | + public function resolve(EntityInterface $entity, $language, ?bool $access, ?AccountInterface $accessUser, ?string $accessOperation) { |
| 60 | +- if ($entity instanceof TranslatableInterface && $entity->isTranslatable()) { |
| 61 | ++ if ($entity instanceof TranslatableInterface && $entity->isTranslatable() && $entity->hasTranslation($language)) { |
| 62 | + $entity = $entity->getTranslation($language); |
| 63 | + $entity->addCacheContexts(["static:language:{$language}"]); |
| 64 | + // Check if the passed user (or current user if none is passed) has access |
| 65 | +diff --git a/src/Plugin/GraphQL/DataProducer/Routing/RouteEntity.php b/src/Plugin/GraphQL/DataProducer/Routing/RouteEntity.php |
| 66 | +index 10ea4e6..1eef22a 100644 |
| 67 | +--- a/src/Plugin/GraphQL/DataProducer/Routing/RouteEntity.php |
| 68 | ++++ b/src/Plugin/GraphQL/DataProducer/Routing/RouteEntity.php |
| 69 | +@@ -126,8 +126,10 @@ class RouteEntity extends DataProducerPluginBase implements ContainerFactoryPlug |
| 70 | + |
| 71 | + // Get the correct translation. |
| 72 | + if (isset($language) && $language != $entity->language()->getId() && $entity instanceof TranslatableInterface) { |
| 73 | +- $entity = $entity->getTranslation($language); |
| 74 | +- $entity->addCacheContexts(["static:language:{$language}"]); |
| 75 | ++ if ($entity->hasTranslation($language)) { |
| 76 | ++ $entity = $entity->getTranslation($language); |
| 77 | ++ $entity->addCacheContexts(["static:language:{$language}"]); |
| 78 | ++ } |
| 79 | + } |
| 80 | + |
| 81 | + $access = $entity->access('view', NULL, TRUE); |
| 82 | +diff --git a/src/Plugin/GraphQL/DataProducer/Taxonomy/TaxonomyLoadTree.php b/src/Plugin/GraphQL/DataProducer/Taxonomy/TaxonomyLoadTree.php |
| 83 | +index 1bcd624..8b2caf2 100644 |
| 84 | +--- a/src/Plugin/GraphQL/DataProducer/Taxonomy/TaxonomyLoadTree.php |
| 85 | ++++ b/src/Plugin/GraphQL/DataProducer/Taxonomy/TaxonomyLoadTree.php |
| 86 | +@@ -175,8 +175,10 @@ class TaxonomyLoadTree extends DataProducerPluginBase implements ContainerFactor |
| 87 | + $context->addCacheableDependency($entities[$id]); |
| 88 | + |
| 89 | + if (isset($language) && $language !== $entities[$id]->language()->getId() && $entities[$id] instanceof TranslatableInterface) { |
| 90 | +- $entities[$id] = $entities[$id]->getTranslation($language); |
| 91 | +- $entities[$id]->addCacheContexts(["static:language:{$language}"]); |
| 92 | ++ if ($entities[$id]->hasTranslation($language)) { |
| 93 | ++ $entities[$id] = $entities[$id]->getTranslation($language); |
| 94 | ++ $entities[$id]->addCacheContexts(["static:language:{$language}"]); |
| 95 | ++ } |
| 96 | + } |
| 97 | + |
| 98 | + if ($access) { |
0 commit comments