Skip to content

Commit

Permalink
drupal-graphql#1322: Add check for tranlsation
Browse files Browse the repository at this point in the history
  • Loading branch information
artemvd authored Jan 11, 2023
1 parent 5c83c82 commit 4723831
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Plugin/GraphQL/DataProducer/Routing/RouteEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ public function resolve($url, ?string $language, FieldContext $context): ?Deferr

// Get the correct translation.
if (isset($language) && $language != $entity->language()->getId() && $entity instanceof TranslatableInterface) {
if (!$entity->hasTranslation($language)) {
return NULL;
}
$entity = $entity->getTranslation($language);
$entity->addCacheContexts(["static:language:{$language}"]);
}
Expand Down

0 comments on commit 4723831

Please sign in to comment.