magento2
magento2 copied to clipboard
Magento Graph QL : route query product and cms-page caching issue
Preconditions (*)
- Magento 2.4.3-p1
- Sample Data is imported
Steps to reproduce (*)
- Query using route(url:"<
>")
Expected result (*)
- Response header should contain X-Magento-Tags and Cache-Control to be public
Actual result (*)
- X-Magento-Tags header is missing and Cache-Control is no-cache
- [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
After debugging I have found that vendor/magento/module-cms-url-rewrite-graph-ql/Model/Resolver/UrlRewrite/CmsUrlResolverIdentity.php:26 vendor/magento/module-catalog-url-rewrite-graph-ql/Model/Resolver/UrlRewrite/CatalogUrlResolverIdentity.php:36
expects a key 'id' to be present in $resolvedData $ids = [$selectedCacheTag, sprintf('%s_%s', $selectedCacheTag, $resolvedData['id'])];
A workaround solution is to overwrite the files vendor/magento/module-catalog-url-rewrite-graph-ql/Model/DataProvider/UrlRewrite/ProductDataProvider.php:48 $product = $this->productRepository->getById($id, false, $storeId); $result = $product->getData(); $result['id'] = $product->getId();
vendor/magento/module-cms-url-rewrite-graph-ql/Model/DataProvider/UrlRewrite/Page.php:49 $result = $this->pageDataProvider->getDataByPageId((int)$id); $result['type_id'] = $entity_type; $result['id'] = $result['page_id']