Skip to main content

Fetch a category by ID

Retrieve a single category with its core data.

Query

query GetCategory($categoryId: Float!) {
category(categoryId: $categoryId) {
categoryId
name { language value }
description { language value }
shortDescription { language value }
slug { language value }
hidden
defaultLanguage
path
}
}

Variables

{
"categoryId": 1795
}

Response

{
"data": {
"category": {
"categoryId": 1795,
"name": [
{ "language": "NL", "value": "Computers / laptops" }
],
"description": [
{ "language": "NL", "value": "<p>Zakelijke computers en laptops</p>" }
],
"shortDescription": [
{ "language": "NL", "value": "Computers en laptops" }
],
"slug": [
{ "language": "NL", "value": "computers-laptops" }
],
"hidden": "N",
"defaultLanguage": "NL",
"path": "100035/100092"
}
}
}

How it works

The categoryId argument is a Float on this query, so declare the variable as Float!. The path field contains internal IDs (not categoryIds) separated by slashes, representing the path from root to this category. 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.

See also