QuestionQ41

VerifiedCatalog and Products

An external system integrates product-catalog search functionality by using the Adobe Commerce GraphQL API. The Architect creates a new my_attribute attribute in the Admin panel with the select frontend type.

Later, the Architect finds that ProductInterface already includes the my_attribute field, but it returns an Int value. The Architect wants this field to use a new type containing both the option ID and label.

To meet this requirement, an Adobe Commerce Architect creates a new module and an etc/schema.graphqls file that declares the following:

Question Image

After running the setup:upgrade command, introspection still shows the ProductInterface field my_attribute as Int.

What prevented the value type of the my_attribute field from changing?

Explanation

Magento_CatalogGraphQl’s dynamic attribute reader adds product EAV attributes to the GraphQL configuration and derives each field’s GraphQL type from the attribute’s backend type. A select product attribute stores its selected option as an integer, so the dynamically generated my_attribute: Int field overrides the custom field type during the later configuration merge.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!