devdocs icon indicating copy to clipboard operation
devdocs copied to clipboard

docs(graphql): ConfigurableProductOptions.use_default is documented incorrectly

Open engcom-November opened this issue 3 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Which topic?

https://devdocs.magento.com/guides/v2.4/graphql/interfaces/configurable-product.html

What's wrong with the content?

use_default: Boolean @doc(description: "Indicates whether the option is the default.") This doc is incorrect and unclear

What changes do you propose?

Change the doc to read more similarly to ConfigurableProductOptionsValues.use_default_value (the real purpose of the node).

use_default_value: Boolean @doc(description: "Indicates whether to use the default_label.") As that's the actual purpose of the flag.

Anything else that can help to cover this?

No response

engcom-November avatar Oct 07 '22 15:10 engcom-November

Hi @engcom-November. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this


m2-assistant[bot] avatar Oct 07 '22 15:10 m2-assistant[bot]

@damienwebdev If you have any idea what this field really does, leave a message here. It's going to be difficult to find an internal developer who knows.

keharper avatar Oct 13 '22 18:10 keharper

type ConfigurableProductOptions @doc(description: "Defines configurable attributes for the specified product.") {
    use_default: Boolean @doc(description: "Indicates whether the option is the default.")
}

type ConfigurableProductOptionsValues @doc(description: "Contains the index number assigned to a configurable product option.") {
    use_default_value: Boolean @doc(description: "Indicates whether to use the default_label.")
}

I'm pretty sure (not 100%) that these two values are similar in intent, but at different levels (attribute vs. attribute value). I think they refer to the fallback mechanism for configurable attribute labels across:

  1. Product Specific Scope
  2. Store Scope
  3. Root Scope

Consider the following attribute structure:

{
  "code": "test_attribute",
  "label": "Test Attribute",
  "use_default": false
  "values": [
    {
      "uid": "1",
      "label": "Green"
      "store_label": "Green", 
      "default_label": "Some better name but specific to this product",
      "use_default_value": false
    }
  ]
}

In reality, the behind the scenes data structure looks like:

{
  code: "test_attribute",
  label: "Test Attribute",
  store_label: "Test Store Attribute", 
  default_label: "Test Product Attribute Name at Store Level",
  use_default: false
  values: [
    {
      uid: "1",
      label: "Green"
      store_label: "Green", 
      default_label: "Some better name but specific to this product",
      use_default_value: false
    }
  ]
}

I believe (unfortunately) that GraphQl is over-exposing the values: on ConfigurableProductOptionsValues

ConfigurableProductOptionsValues {
   store_label: "Green", <-- Not relevant
   default_label: "Some better name but specific to this product" <-- Not relevant
   use_default_value: false <-- Not relevant
}

ConfigurableProductOptions { 
  label: "Test Attribute",
  store_label: "Some other language",  <-- Not relevant
  default_label: "Some better name but specific to this product", <-- Not relevant
  use_default: false <-- Not relevant
}

damienwebdev avatar Oct 13 '22 19:10 damienwebdev