cacheableQuery = $cacheableQuery; $this->request = $request; $this->identityPool = $identityPool; } /** * Set HTTP full page cache validity on $cacheableQuery after resolving any resolver in a query * * @param array $resolvedValue * @param array $cacheAnnotation Eg: ['cacheable' => true, 'cacheTag' => 'someTag', cacheIdentity=>'\Mage\Class'] * @return void */ public function handleCacheFromResolverResponse(array $resolvedValue, array $cacheAnnotation) : void { $cacheable = $cacheAnnotation['cacheable'] ?? true; $cacheIdentityClass = $cacheAnnotation['cacheIdentity'] ?? ''; if ($this->request instanceof Http && $this->request->isGet() && !empty($cacheIdentityClass)) { $cacheIdentity = $this->identityPool->get($cacheIdentityClass); $cacheTags = $cacheIdentity->getIdentities($resolvedValue); $this->cacheableQuery->addCacheTags($cacheTags); } else { $cacheable = false; } $this->setCacheValidity($cacheable); } /** * Set HTTP full page cache validity for the graphql request * * @param bool $isValid * @return void */ private function setCacheValidity(bool $isValid): void { $cacheValidity = $this->cacheableQuery->isCacheable() && $isValid; $this->cacheableQuery->setCacheValidity($cacheValidity); } }