Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit b732e17

Browse files
authored
Merge pull request #2870 from magento/kh_graphql-pr108
Add attribute_options object
2 parents 1628284 + de6388b commit b732e17

File tree

1 file changed

+100
-65
lines changed

1 file changed

+100
-65
lines changed

guides/v2.3/graphql/reference/custom-attribute-metadata.md

Lines changed: 100 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,25 @@ group: graphql
33
title: CustomAttributeMetadata endpoint
44
---
55

6-
The `customAttributeMetadata` endpoint returns the attribute type, given an attribute code and entity type. All entity attributes can be added to an equivalent GraphQL type, including custom, extension, and EAV (which have precedence set in that order for collisions). The ability to know the type of attribute a given field is obscured from the GraphQL query consumer.
6+
The `customAttributeMetadata` endpoint returns the attribute type, given an attribute code and entity type. All entity attributes can be added to an equivalent GraphQL type, including custom, extension, and EAV (which have precedence set in that order for collisions). The GraphQL query consumer does not have the ability to know a field's attribute type.
7+
8+
## Supported attributes
9+
10+
Attribute | Data Type | Description
11+
--- | --- | ---
12+
`attribute_code` | String | The unique identifier for an attribute code. This value should be in lowercase letters without spaces.
13+
`entity_type` | String | The type of entity that defines the attribute
14+
`attribute_type` | String | The data type of the attribute (Response only)
15+
`attribute_options` | `AttributeOption` | A list of attribute options
16+
{:style="table-layout:auto;"}
17+
18+
### AttributeOption object
19+
20+
Attribute | Data Type | Description
21+
--- | --- | ---
22+
`label` | String | The name of an attribute option
23+
`value` | String | The value assigned to an attribute option
24+
{:style="table-layout:auto;"}
725

826
## Example usage
927

@@ -13,42 +31,25 @@ The following query returns the attribute type for various custom and EAV attrib
1331

1432
{% highlight json %}
1533
{
16-
customAttributeMetadata(attributes:
17-
[
18-
{
19-
attribute_code: "available_sort_by",
20-
entity_type: "catalog_category"
21-
},
22-
{
23-
attribute_code: "quantity_and_stock_status",
24-
entity_type: "catalog_product"
25-
},
26-
{
27-
attribute_code: "default_billing",
28-
entity_type: "customer"
29-
},
30-
{
31-
attribute_code: "region"
32-
entity_type: "customer_address"
33-
},
34-
{
35-
attribute_code: "media_gallery",
36-
entity_type: "catalog_product"
37-
}
38-
]
39-
)
40-
{
41-
items
42-
{
43-
attribute_code
44-
entity_type
45-
attribute_type
46-
}
47-
}
34+
customAttributeMetadata(
35+
attributes: {
36+
attribute_code: "color"
37+
entity_type: "4"
38+
}
39+
) {
40+
items {
41+
attribute_code
42+
entity_type
43+
attribute_type
44+
attribute_options {
45+
value
46+
label
47+
}
48+
}
4849
}
50+
}
4951
{% endhighlight %}
5052

51-
The key you're storing EAV attributes under
5253
**Response**
5354

5455
{% highlight json %}
@@ -57,40 +58,74 @@ The key you're storing EAV attributes under
5758
"customAttributeMetadata": {
5859
"items": [
5960
{
60-
"attribute_code": "available_sort_by",
61-
"entity_type": "catalog_category",
62-
"attribute_type": "EavDataAttributeOptionInterface"
63-
},
64-
{
65-
"attribute_code": "quantity_and_stock_status",
66-
"entity_type": "catalog_product",
67-
"attribute_type": "CatalogInventoryDataStockItemInterface[]"
68-
},
69-
{
70-
"attribute_code": "default_billing",
71-
"entity_type": "customer",
72-
"attribute_type": "CustomerDataAddressInterface"
73-
},
74-
{
75-
"attribute_code": "region",
76-
"entity_type": "customer_address",
77-
"attribute_type": "CustomerDataRegionInterface"
78-
},
79-
{
80-
"attribute_code": "media_gallery",
81-
"entity_type": "catalog_product",
82-
"attribute_type": "ProductMediaGallery"
61+
"attribute_code": "color",
62+
"entity_type": "4",
63+
"attribute_type": "Int",
64+
"attribute_options": [
65+
{
66+
"value": "49",
67+
"label": "Black"
68+
},
69+
{
70+
"value": "214",
71+
"label": "blue"
72+
},
73+
{
74+
"value": "215",
75+
"label": "green"
76+
},
77+
{
78+
"value": "213",
79+
"label": "red"
80+
},
81+
{
82+
"value": "50",
83+
"label": "Blue"
84+
},
85+
{
86+
"value": "51",
87+
"label": "Brown"
88+
},
89+
{
90+
"value": "52",
91+
"label": "Gray"
92+
},
93+
{
94+
"value": "53",
95+
"label": "Green"
96+
},
97+
{
98+
"value": "54",
99+
"label": "Lavender"
100+
},
101+
{
102+
"value": "55",
103+
"label": "Multi"
104+
},
105+
{
106+
"value": "56",
107+
"label": "Orange"
108+
},
109+
{
110+
"value": "57",
111+
"label": "Purple"
112+
},
113+
{
114+
"value": "58",
115+
"label": "Red"
116+
},
117+
{
118+
"value": "59",
119+
"label": "White"
120+
},
121+
{
122+
"value": "60",
123+
"label": "Yellow"
124+
}
125+
]
83126
}
84127
]
85128
}
86129
}
87130
}
88131
{% endhighlight %}
89-
90-
## Supported attributes
91-
92-
Attribute | Data Type | Description
93-
--- | --- | ---
94-
`attribute_code` | String | The unique identifier for an attribute code. This value should be in lowercase letters without spaces.
95-
`attribute_type` | String | The data type of the attribute (Response only)
96-
`entity_type` | String | The type of entity that defines the attribute

0 commit comments

Comments
 (0)