Fetch product attributes as specifications
Retrieve a product's attributes to display as a specifications table on the product detail page.
Query
query GetProductAttributes($productId: Int!, $language: String) {
product(productId: $productId) {
productId
names(language: $language) { value }
attributes(input: { offset: 50 }) {
items {
attributeDescription {
name
descriptions { language value }
type
group
}
value {
... on AttributeTextValue { textValues { language values } }
... on AttributeEnumValue { enumValues }
... on AttributeIntValue { intValue }
... on AttributeDecimalValue { decimalValue }
... on AttributeColorValue { colorValue }
}
}
itemsFound
}
}
}
Variables
{
"productId": 25,
"language": "NL"
}
Response
{
"data": {
"product": {
"productId": 25,
"names": [{ "value": "Dovre SAGA 1001" }],
"attributes": {
"items": [
{
"attributeDescription": {
"name": "ONDERSTEL_KLEUR",
"descriptions": [{ "language": "NL", "value": "Kleur van het onderstel (frame)" }],
"type": "COLOR",
"group": "Kantoormeubilair"
},
"value": {
"colorValue": "#FFFFFF"
}
},
{
"attributeDescription": {
"name": "RUO_STATEMENT",
"descriptions": [
{ "language": "EN", "value": "Research Use Only statement" },
{ "language": "NL", "value": "Research Use Only statement" }
],
"type": "TEXT",
"group": "RPIP"
},
"value": {
"textValues": [
{ "language": "EN", "values": [] },
{ "language": "NL", "values": null }
]
}
}
],
"itemsFound": 96
}
}
}
}
How it works
The value field is a union type — use inline fragments to handle each attribute type: AttributeTextValue for text, AttributeEnumValue for dropdowns, AttributeIntValue and AttributeDecimalValue for numbers, and AttributeColorValue for colors. The attributeDescription.descriptions array contains the human-readable label per language, which you display as the specification name. Group attributes by the group field to create specification sections. Filter out attributes with empty or null values before rendering.