Fetch a category by ID
Retrieve a single category with its core data.
Query
query GetCategory($categoryId: Float!) {
category(categoryId: $categoryId) {
categoryId
names { language value }
descriptions { language value }
shortDescriptions { language value }
slugs { language value }
hidden
defaultLanguage
categoryPath { categoryId }
}
}
Variables
{
"categoryId": 1795
}
Response
{
"data": {
"category": {
"categoryId": 1795,
"names": [
{ "language": "NL", "value": "Computers / laptops" }
],
"descriptions": [
{ "language": "NL", "value": "<p>Zakelijke computers en laptops</p>" }
],
"shortDescriptions": [
{ "language": "NL", "value": "Computers en laptops" }
],
"slugs": [
{ "language": "NL", "value": "computers-laptops" }
],
"hidden": "N",
"defaultLanguage": "NL",
"categoryPath": [
{ "categoryId": 17 },
{ "categoryId": 1794 },
{ "categoryId": 1795 }
]
}
}
}
How it works
The categoryId argument is a Float on this query, so declare the variable as Float!. The categoryPath field lists the categories from the root down to this one, ending with the category itself. The hidden parameter on the query acts as a filter: hidden: N returns the category only if it is visible, hidden: Y only if hidden, omitted returns it regardless.