magento2: Graphql products query returns only ids for dropdows or multiselect fields

Preconditions (*)

  1. 2.3.5-p1 with sample data

Steps to reproduce (*)

  1. u can use this magento instance (https://magento2.kask.at/graphql) or your own testing instance with sample data. query /graphql for a product that has the gender attribute (multiselect) e.g. “dual-handle-cardio-ball”
query productDetail($url_key: String) {
  productDetail: products(filter: {url_key: {eq: $url_key}}) {
    items {
      name
      url_key
      gender
    }
  }
}

variables:

{
  "url_key": "dual-handle-cardio-ball"
}

Expected result (*)

I would expext the result to contain the labels

{
  "data": {
    "productDetail": {
      "items": [
        {
          "name": "Dual Handle Cardio Ball",
          "url_key": "dual-handle-cardio-ball",
          "gender": ["Men","Women","Unisex"]
        }
      ]
    }
  }
}

Actual result (*)

the response only returns the value ids.

{
  "data": {
    "productDetail": {
      "items": [
        {
          "name": "Dual Handle Cardio Ball",
          "url_key": "dual-handle-cardio-ball",
          "gender": "5507,5508,5511"
        }
      ]
    }
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 31 (8 by maintainers)

Commits related to this issue

Most upvoted comments

For anyone stuck here, try this quickfix till its resolved in the core.

It’s really a good improvement however, unfortunately, it will bring breaking changes, so we cannot accept it for 2.4. (unless it will be approved)

Maybe we can do the following: mark all dynamic product attributes as deprecated and introduce an object that will hold all dynamic product attributes, something like

dynamic_attributes: [
    {
       code
       value
       type // is it useful for rendering UI?
    }
]

Only one drawback that we need to support different types like texts, lists, float… (we can see them in Admin => Store => Attributes => Product) and we can agree to have “value” as an array of strings which will cover all cases, however on the client-side we need to have something like value[0] each time for one-value attributes.

@DrewML what do you think about it?

Magento instance deployment temporary unavailable due to service maintenance.