Skip to content

Always add the list cache tags otherwise if list is not empty and you… #1101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 8.x-4.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/Plugin/GraphQL/DataProducer/Taxonomy/TaxonomyLoadTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,15 @@ public function resolve(string $vid, int $parent, ?int $max_depth, ?string $lang
return new Deferred(function () use ($language, $resolver, $context, $access, $accessUser, $accessOperation) {
/** @var \Drupal\Core\Entity\EntityInterface[] $entities */
$entities = $resolver();

// Add the list cache tags so that the cache entry is purged
// whenever a new entity of this type is saved.
$type = $this->entityTypeManager->getDefinition('taxonomy_term');
/** @var \Drupal\Core\Entity\EntityTypeInterface $type */
$tags = $type->getListCacheTags();
$context->addCacheTags($tags);

if (!$entities) {
// If there is no entity with this id, add the list cache tags so that
// the cache entry is purged whenever a new entity of this type is
// saved.
$type = $this->entityTypeManager->getDefinition('taxonomy_term');
/** @var \Drupal\Core\Entity\EntityTypeInterface $type */
$tags = $type->getListCacheTags();
$context->addCacheTags($tags);
return [];
}

Expand Down