protected function QueryProcessor::executeCacheableOperation in GraphQL 8.3
Parameters
\GraphQL\Executor\Promise\PromiseAdapter $adapter:
\GraphQL\Server\ServerConfig $config:
\GraphQL\Server\OperationParams $params:
\GraphQL\Language\AST\DocumentNode $document:
bool $validate:
Return value
\GraphQL\Executor\Promise\Promise|mixed
1 call to QueryProcessor::executeCacheableOperation()
- QueryProcessor::executeOperation in src/
GraphQL/ Execution/ QueryProcessor.php
File
- src/
GraphQL/ Execution/ QueryProcessor.php, line 231
Class
Namespace
Drupal\graphql\GraphQL\ExecutionCode
protected function executeCacheableOperation(PromiseAdapter $adapter, ServerConfig $config, OperationParams $params, DocumentNode $document, $validate = TRUE) {
$contextCacheId = 'ccid:' . $this
->cacheIdentifier($params, $document);
if (!$config
->getDebug() && ($contextCache = $this->cacheBackend
->get($contextCacheId))) {
$contexts = $contextCache->data ?: [];
$cid = 'cid:' . $this
->cacheIdentifier($params, $document, $contexts);
if ($cache = $this->cacheBackend
->get($cid)) {
return $adapter
->createFulfilled($cache->data);
}
}
$result = $this
->doExecuteOperation($adapter, $config, $params, $document, $validate);
return $result
->then(function (QueryResult $result) use ($contextCacheId, $params, $document) {
// Write this query into the cache if it is cacheable.
if ($result
->getCacheMaxAge() !== 0) {
$contexts = $result
->getCacheContexts();
$expire = $this
->maxAgeToExpire($result
->getCacheMaxAge());
$tags = $result
->getCacheTags();
$cid = 'cid:' . $this
->cacheIdentifier($params, $document, $contexts);
$this->cacheBackend
->set($contextCacheId, $contexts, $expire, $tags);
$this->cacheBackend
->set($cid, $result, $expire, $tags);
}
return $result;
});
}