magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Nested GraphQL fragments are not processed by the Catalog Attribute Joiner #38762

Closed pmzandbergen closed 5 months ago

pmzandbergen commented 5 months ago

Preconditions and environment

Steps to reproduce

Using a GraphQL fragment inside another fragment does not work. Example query:

query {
  products(filter: { sku: { eq: "example-product" } }) {
    items {
      ... on ProductInterface {
        ...ProductInterfaceFragment
      }
    }
  }
}
fragment ProductFragment on ProductInterface {
  sku
  ...AnotherProductFragment
}
fragment AnotherProductFragment on ProductInterface {
  url_key
}

In this case the Attribute Joiner (Magento\CatalogGraphQl\Model\AttributesJoiner) will return the following fields:

The result will not return a value for url_key, since the attribute is not queried.

Expected result

The result will include the fields from all (nested) fragments (sku and url_key in this example).

Actual result

The result includes only the fields from the first (not nested) fragment, url_key is undefined.

Additional information

I'll create a PR fixing the Attribute Joiner to support nested fragments.

Release note

No response

Triage and priority

m2-assistant[bot] commented 5 months ago

Hi @pmzandbergen. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 5 months ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Bravo commented 5 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 5 months ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 5 months ago

Hi @engcom-Bravo, here is your Magento Instance: https://9aa2bfe654ae79ee312741bd73c969c9.instances-prod.magento-community.engineering Admin access: https://9aa2bfe654ae79ee312741bd73c969c9.instances-prod.magento-community.engineering/admin_1fd0 Login: fddd306a Password: 0f9f2275cbf2

engcom-Bravo commented 5 months ago

Hi @pmzandbergen,

Thanks for your reporting and collaboration.

We have verified the issue in Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Screenshot 2024-05-29 at 16 10 17

The result included the fields from all (nested) fragments (sku and url_key)

Thanks.

engcom-Bravo commented 5 months ago

Hi @pmzandbergen,

We have noticed that this issue has not been updated since long time.
Hence we assume that this issue is fixed now, so we are closing it. Please feel to raise a fresh ticket or reopen this ticket if you need more assistance on this.

Thanks.