Skip to content

Commit 6299e4a

Browse files
authored
Disable caching through service parameters entirely. (#515)
1 parent 2ce30d6 commit 6299e4a

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/GraphQL/Execution/QueryProcessor.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ class QueryProcessor {
3333
/**
3434
* QueryProcessor constructor.
3535
*
36-
* @param \Drupal\Core\Session\AccountProxyInterface $currentUser
37-
* The current user.
3836
* @param \Drupal\graphql\GraphQL\Schema\SchemaLoader $schemaLoader
3937
* The schema loader service.
38+
* @param \Drupal\Core\Session\AccountProxyInterface $currentUser
39+
* The current user.
4040
* @param array $parameters
4141
* The graphql container parameters.
4242
*/
@@ -46,8 +46,8 @@ public function __construct(
4646
array $parameters
4747
) {
4848
$this->currentUser = $currentUser;
49-
$this->parameters = $parameters;
5049
$this->schemaLoader = $schemaLoader;
50+
$this->parameters = $parameters;
5151
}
5252

5353
/**
@@ -95,6 +95,12 @@ public function processQuery($schemaId, $query, array $variables = [], $bypassSe
9595
$responseCacheMetadata->setCacheMaxAge(0);
9696
}
9797

98+
// Do not cache this response anywhere (even page cache) if the graphql
99+
// cache is disabled through the service parameters.
100+
if (empty($this->parameters['result_cache'])) {
101+
$responseCacheMetadata->setCacheMaxAge(0);
102+
}
103+
98104
// Load the schema's cache metadata.
99105
$schemaCacheMetadata = $this->schemaLoader->getResponseCacheMetadata($schemaId);
100106
return new QueryResult($result, $responseCacheMetadata, $schemaCacheMetadata);

0 commit comments

Comments
 (0)