Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field translator removed from \Magento\CatalogGraphQl\Model\Resolver\Product\ProductFieldsSelector #39277

Open
1 of 5 tasks
pmzandbergen opened this issue Oct 17, 2024 · 10 comments · May be fixed by #39323
Open
1 of 5 tasks
Assignees
Labels
Area: Catalog Component: GraphQL GraphQL Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: PR in progress Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@pmzandbergen
Copy link
Contributor

Preconditions and environment

912743c#diff-fecea45cc156bda365fb84d0ac56ecf5689d01847ccb6651d4ae53d2a12e7576R58

This commit removes the field translation, used by the Product (not Products!) resolver (\Magento\CatalogGraphQl\Model\Resolver\Product). This breaks fields depending on other attributes, while they work correctly when using the Products (\Magento\CatalogGraphQl\Model\Resolver\Products) resolver.

Steps to reproduce

  1. Create an attribute depending on another attribute:
    <type name="Magento\Framework\GraphQl\Query\FieldTranslator">
        <arguments>
            <argument name="translationMap" xsi:type="array">
                <item name="aliasField" xsi:type="string">regularField</item>
            </argument>
        </arguments>
    </type>
  1. Create a product with a value for regularField.
  2. Test a query using both the Product and Products resolver for the aliasField

Expected result

Both resolvers should return the same result.

Actual result

Only the Products resolver works as expected.

Additional information

There are more GraphQL bugs regarding product resolving, for example the data could be incomplete if the product is queried as part of the CartItemInterface.

I'm trying to bundle these bugs in a MR (when I've got some spare time).

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Copy link

m2-assistant bot commented Oct 17, 2024

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.


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

@github-project-automation github-project-automation bot moved this to Ready for Confirmation in Issue Confirmation and Triage Board Oct 17, 2024
@engcom-Bravo engcom-Bravo added Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it Reported on 2.4.x Indicates original Magento version for the Issue report. labels Oct 18, 2024
@engcom-November
Copy link
Contributor

Hello @pmzandbergen,

Thank you for the report and collaboration!

We tried to verify this on 2.4-develop, but the issue is not reproducible.
Added regularField and aliasField and made it dependent, but we are getting the same response with product and products query.
Here is the module used to reproduce this issue.
I39277V.zip

Please let us know if we are missing anything.

Thank you.

@engcom-November engcom-November added Issue: needs update Additional information is require, waiting for response and removed Issue: ready for confirmation labels Oct 24, 2024
@engcom-November engcom-November moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Oct 24, 2024
@pmzandbergen
Copy link
Contributor Author

Hello @pmzandbergen,

Thank you for the report and collaboration!

We tried to verify this on 2.4-develop, but the issue is not reproducible. Added regularField and aliasField and made it dependent, but we are getting the same response with product and products query. Here is the module used to reproduce this issue. I39277V.zip

Please let us know if we are missing anything.

Thank you.

Did you include the created aliasField in the GraphQL query? If so, it will be available since the underlying collection will include this field. You could update the included test by:

  • Only query aliasField, do not query both fields
  • Do not use custom_attributesV2, as it is using a separate resolver

PS Regarding custom_attributesV2, I don't fully understand the decision for this setup. It does not support GraphQL types and it is impossible to exactly specify the required fields.

@pmzandbergen
Copy link
Contributor Author

A patch for this issue:

--- Model/Resolver/Product/ProductFieldsSelector.php.org	2024-10-21 09:28:29
+++ Model/Resolver/Product/ProductFieldsSelector.php	2024-10-21 09:30:10
@@ -52,8 +52,10 @@
             if ($node->name->value !== $productNodeName) {
                 continue;
             }
-                $queryFields = $this->attributesJoiner->getQueryFields($node, $info);
-                $fieldNames[] = $queryFields;
+            $queryFields = array_map(function (string $fieldName): string {
+                return $this->fieldTranslator->translate($fieldName);
+            }, $this->attributesJoiner->getQueryFields($node, $info));
+            $fieldNames[] = $queryFields;
         }
 
         return array_merge(...$fieldNames);

@engcom-November
Copy link
Contributor

@pmzandbergen,

When querying using both product and products, I am getting null for aliasField using di.xml provided above.
Please take a look at the screenshot:
Product query:

{
  products(filter: { sku: { eq:"test-prd-1" } } pageSize:100 ) {
    items {
      sku
      name
      alias_field
    }
  }
}
image

Products query:

{
  products(filter: {  } pageSize:100 ) {
    items {
      sku
      name
      alias_field
    }
  }
}
image

Can you give more insight on this.

Thank you.

@engcom-Hotel engcom-Hotel self-assigned this Nov 4, 2024
Copy link

m2-assistant bot commented Nov 4, 2024

Hi @engcom-Hotel. 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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@pmzandbergen
Copy link
Contributor Author

@engcom-November both queries in your example are using \Magento\CatalogGraphQl\Model\Resolver\Products. Usage of the affected resolver \Magento\CatalogGraphQl\Model\Resolver\Product can be found in the following interfaces / types:

  • ConfigurableCartItem (field configured_variant)
  • OrderItemInterface (field product)
  • WishlistItemInterface (field product)

pmzandbergen added a commit to pmzandbergen/magento2 that referenced this issue Nov 4, 2024
@pmzandbergen pmzandbergen linked a pull request Nov 4, 2024 that will close this issue
5 tasks
@engcom-Hotel
Copy link
Contributor

Hello @pmzandbergen,

Thanks for the further inputs!

We have tried to reproduce the issue with ConfigurableCartItem (field configured_variant) and the issue is reproducible for us.

Hence confirming the issue.

Thanks

@engcom-Hotel engcom-Hotel added Component: GraphQL GraphQL Area: Catalog and removed Issue: needs update Additional information is require, waiting for response labels Nov 5, 2024
@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: ready for confirmation labels Nov 5, 2024
@engcom-Hotel engcom-Hotel added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Priority: P3 May be fixed according to the position in the backlog. labels Nov 5, 2024
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-13308 is successfully created for this GitHub issue.

Copy link

m2-assistant bot commented Nov 5, 2024

✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Catalog Component: GraphQL GraphQL Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: PR in progress Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants