Skip to content

Commit 088d511

Browse files
committed
Cache query per user.
1 parent 06bdf5f commit 088d511

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Plugin/GraphQL/DataProducer/Entity/EntityQuery.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,11 @@ public function resolve(string $type, int $limit = 10, ?int $offset, ?bool $owne
159159
// Query only those entities which are owned by current user, if desired.
160160
if ($ownedOnly) {
161161
$query->condition('uid', $this->currentUser->id());
162-
// Add caching dependencies to make sure entity query is cached per user.
162+
// Add user cacheable dependencies.
163163
$account = $this->currentUser->getAccount();
164164
$context->addCacheableDependency($account);
165+
// Cache response per user to make sure the user related result is shown.
166+
$context->addCacheContexts(['user']);
165167
}
166168

167169
// Ensure that access checking is performed on the query.

0 commit comments

Comments
 (0)