Skip to main content

Fetch a category breadcrumb

Get the full ancestor chain from root to the current category for breadcrumb navigation.

Query​

query GetBreadcrumb($categoryId: Float!) {
category(categoryId: $categoryId) {
categoryId
names { language value }
categoryPath {
categoryId
names { language value }
slugs { language value }
}
}
}

Variables​

{
"categoryId": 1798
}

Response​

{
"data": {
"category": {
"categoryId": 1798,
"names": [{ "language": "NL", "value": "2-in-1 Laptops" }],
"categoryPath": [
{
"categoryId": 17,
"names": [{ "language": "NL", "value": "PDM" }],
"slugs": [{ "language": "NL", "value": "pdm" }]
},
{
"categoryId": 1794,
"names": [{ "language": "NL", "value": "ICT and hardware" }],
"slugs": [{ "language": "NL", "value": "ict-and-hardware" }]
},
{
"categoryId": 1795,
"names": [{ "language": "NL", "value": "Computers / laptops" }],
"slugs": [{ "language": "NL", "value": "computers-laptops" }]
},
{
"categoryId": 1798,
"names": [{ "language": "NL", "value": "2-in-1 Laptops" }],
"slugs": [{ "language": "NL", "value": "2-in-1-laptops" }]
}
]
}
}
}

How it works​

categoryPath returns the chain from the root down to the current category. The last entry is the category itself, and a root category returns only itself. You can pass hidden: N to categoryPath to exclude hidden categories from the breadcrumb.

See also​