1

I want to get the attribute label value along with the id in the Products graphQL query.

like color { id: 12, label: black }, size{ id: 15, label: xl }

Currently, it returns the id only.

How can I extend the current query?

Viral Patel
1,1001 gold badge8 silver badges17 bronze badges
asked Nov 9, 2021 at 8:06

1 Answer 1

0

Try This

query($url: String!) {
 products(filter: { url_key: { eq: $url } }) {
 items {
 id
 sku
 name
 ... on ConfigurableProduct {
 configurable_options {
 id
 attribute_id_v2
 use_default
 attribute_code
 label
 position
 values {
 value_index
 label
 swatch_data {
 __typename
 value
 }
 }
 product_id
 }
 variants {
 attributes {
 label
 code
 value_index
 }
 product {
 id
 name
 sku
 stock_status
 short_description {
 html
 }
 description {
 html
 }
 image {
 url
 label
 }
 small_image {
 url
 label
 }
 media_gallery {
 url
 label
 ... on ProductVideo {
 video_content {
 media_type
 video_provider
 video_url
 video_title
 video_description
 video_metadata
 }
 }
 }
 price_range {
 minimum_price {
 regular_price {
 value
 currency
 }
 final_price {
 value
 currency
 }
 discount {
 amount_off
 percent_off
 }
 }
 }
 }
 }
 }
 }
 total_count
 }
}
answered Nov 9, 2021 at 8:30
3
  • this is for configurable products. I want this data in all simple products too Commented Nov 9, 2021 at 8:51
  • if the product is configurable then it's showing all its variants. Simple product does not have any variant Commented Nov 10, 2021 at 5:57
  • Simple products can also have various attributes with option/value combination. Commented Nov 11, 2022 at 12:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.