Edit in GitHubLog an issue

category query

The category query allows you to search for a single category definition or the entire category tree.

Syntax

Copied to your clipboard
category (
id: int
): CategoryTree

Reference

The category reference provides detailed information about the types and fields defined in this query.

Example usage

Return the category tree of a top-level category

The following query returns information about category ID 20 and four levels of subcategories. In the sample data, category ID 20 is assigned to the Women category.

Request:

Copied to your clipboard
{
category(id: 20) {
products {
total_count
page_info {
current_page
page_size
}
}
children_count
children {
id
level
name
path
children {
id
level
name
path
children {
id
level
name
path
children {
id
level
name
path
}
}
}
}
}
}

Response:

Copied to your clipboard
{
"data": {
"category": {
"products": {
"total_count": 0,
"page_info": {
"current_page": 1,
"page_size": 20
}
},
"children_count": "8",
"children": [
{
"id": 22,
"level": 3,
"name": "Bottoms",
"path": "1/2/20/22",
"children": [
{
"id": 27,
"level": 4,
"name": "Pants",
"path": "1/2/20/22/27",
"children": []
},
{
"id": 28,
"level": 4,
"name": "Shorts",
"path": "1/2/20/22/28",
"children": []
}
]
},
{
"id": 21,
"level": 3,
"name": "Tops",
"path": "1/2/20/21",
"children": [
{
"id": 23,
"level": 4,
"name": "Jackets",
"path": "1/2/20/21/23",
"children": []
},
{
"id": 24,
"level": 4,
"name": "Hoodies & Sweatshirts",
"path": "1/2/20/21/24",
"children": []
},
{
"id": 25,
"level": 4,
"name": "Tees",
"path": "1/2/20/21/25",
"children": []
},
{
"id": 26,
"level": 4,
"name": "Bras & Tanks",
"path": "1/2/20/21/26",
"children": []
}
]
}
]
}
}
}

Return breadcrumb information

The following query returns breadcrumb information about the women's Tops category (id = 25).

Request:

Copied to your clipboard
{
category (
id: 25
) {
id
level
name
breadcrumbs {
category_id
category_name
category_level
category_url_key
category_url_path
}
}
}

Response:

Copied to your clipboard
{
"data": {
"category": {
"id": 25,
"level": 4,
"name": "Tees",
"breadcrumbs": [
{
"category_id": 20,
"category_name": "Women",
"category_level": 2,
"category_url_key": "women",
"category_url_path": "women"
},
{
"category_id": 21,
"category_name": "Tops",
"category_level": 3,
"category_url_key": "tops-women",
"category_url_path": "women/tops-women"
}
]
}
}
}

Errors

ErrorDescription
Category doesn't exist
The specified category ID value does not exist.
Field "category" argument "id" requires type Int, found "XXX"
The specified id argument value has the wrong type.
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.