Skip to content

Magento Graph QL : route query product and cms-page caching issue #34908

Open
@mandarzope

Description

@mandarzope

Preconditions (*)

  1. Magento 2.4.3-p1
  2. Sample Data is imported

Steps to reproduce (*)

  1. Query using route(url:"<>")

Expected result (*)

  1. Response header should contain X-Magento-Tags and Cache-Control to be public

Actual result (*)

  1. 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']

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions