The categories query returns a list of CategoryView objects. Each CategoryView describes a category in the catalog tree, including identifiers, hierarchy, URL segments, display sort options, and storefront roles. It implements CategoryViewInterface for the shared field set documented below.
CategoryView type
Field
Data type
Description
availableSortBy[String]
List of available sort by options. For example,
name, position, or size. Maps to the category configuration Display Settings > Available Product List Sort By in the Commerce Admin.children[String!]
List of subcategories by category ID. For example,
123, 456, or 789.defaultSortByString
Default sort by option. For example,
name, position, or size. Maps to the category configuration Display Settings > Available Product List Sort By in the Commerce Admin.idID!
The category ID. For example,
123, 456, or 789. Maps to Display Settings > Default Product List Sort By in the Admin.levelInt
Indicates the depth of the category within the tree. The root category is a level 1 category. For example,
men is level 1, men/clothing is level 2, and men/clothing/shorts is level 3.nameString
The category display name. For example,
Electronics, Clothing, or Books.parentIdString!
ID of the parent. For example,
123, 456, or 789.pathString
The path to the category as a string of category IDs separated by slashes (
/). For example, 1/2/20.positionInt
The position of the category relative to other categories at the same level in the tree. Merchants set this value in the Admin to control display order in storefront navigation. A lower value means the category appears first. For example,
1, 2, 3, or 10.roles[String!]!
Storefront labels assigned during category ingestion that describe visibility and placement. Use them in your storefront logic (for example, show only
active categories in navigation) or pass matching values in the query roles argument to filter results. For example, active, show_in_menu, show_on_plp, or show_in_search.urlKeyString
The part of the URL that identifies the category. For example,
electronics, clothing, or books.urlPathString
The URL path for the category URL path. For example,
men/bottoms-men or men/tops-men/jackets-men.CategoryViewInterface attributes
CategoryViewInterface defines the shared category metadata that CategoryView implements: identity and hierarchy (id, name, level, path, position), URL segments (urlKey, urlPath), product listing sort options (availableSortBy, defaultSortBy), and storefront roles (roles). The CategoryView type adds tree-navigation fields (children, parentId) that are not on the interface.
Field
Data Type
Description
availableSortBy[String]
List of available sort by options. For example,
name, position, or size.defaultSortByString
Default sort by option. For example,
name, position, or size.idID!
Category ID. For example,
123, 456, or 789.levelInt
The level of the category. The root category is a level 1 category. For example,
men is level 1, men/clothing is level 2, and men/clothing/shorts is level 3.nameString
Category name. For example,
Electronics, Clothing, or Books.pathString
Category path. For example,
1/2/20 or /electronics/laptops.positionInt
The position of the category relative to other categories at the same level in the tree. For example,
1, 2, 3, or 10.roles[String]
Storefront labels assigned during category ingestion that describe visibility and placement. Use them in your storefront logic (for example, show only
active categories in navigation) or pass matching values in the query roles argument to filter results. For example, active, show_in_menu, show_on_plp, or show_in_search.urlKeyString
Category URL key. For example,
electronics, clothing, or books.urlPathString
Category URL path. For example,
/electronics/laptops, /clothing/shirts, or /books/fiction.