Skip to content

Categories and Collections

Learn how to work with LCBO's category hierarchy and collections. Categories organize products by type (Wine, Beer, Spirits), while collections group products by theme (Holiday Gifts, Staff Picks).

Category Features

The categories query supports flexible filtering and exploration:

  • search - Find categories by name (e.g., "red wine", "craft beer")
  • rootType - Separate PRODUCTS (Wine, Beer, Spirits) from COLLECTIONS (Holiday Gifts, New Arrivals)
  • parentId - Get children of a specific category (explore the tree)

Browse All Categories

Use case: Explore the complete category structure or build a category browser.

graphql
query AllCategories {
  categories(
    pagination: { first: 50 }
    sortBy: NAME
    sortDirection: ASC
  ) {
    edges {
      node {
        id
        name
        slug
        path
        depth
        rootType
        productsCount
        childrenCount
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
    totalCount
  }
}

Returns all categories with their hierarchy information.

Get Root Categories

Use case: Get the main product categories to understand catalog organization.

graphql
query RootCategories {
  categories(
    filters: { rootType: PRODUCTS }
    pagination: { first: 20 }
    sortBy: SORT_ORDER
    sortDirection: ASC
  ) {
    edges {
      node {
        id
        name
        slug
        path
        rootType
        productsCount
        childrenCount
        depth
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
    totalCount
  }
}

This returns categories like "Wine", "Beer", "Spirits" at the top level of the hierarchy. Filter by rootType: PRODUCTS to get product categories, or use parentId to get children of a specific category.

Understanding Category Depth

The depth field shows hierarchy level: 0 = root, 1 = child, 2 = grandchild, etc.

Search Categories by Name

Use case: Find categories matching a search term for filtering or discovery.

graphql
query SearchCategories($userInput: String!) {
  categories(
    filters: { search: $userInput }
    pagination: { first: 10 }
    sortBy: NAME
    sortDirection: ASC
  ) {
    edges {
      node {
        id
        name
        slug
        path
        productsCount
      }
    }
  }
}

Variables:

json
{
  "userInput": "red"
}

This matches categories like "Red Wine", "Amber & Dark Rum", etc. Use the id or slug to filter products by category.

Filter by Root Type

Use case: Separate product categories from curated collections.

graphql
query RootProductCategories {
  categories(
    filters: { 
      rootType: PRODUCTS
    }
    pagination: { first: 20 }
    sortBy: NAME
    sortDirection: ASC
  ) {
    edges {
      node {
        id
        name
        slug
        rootType
        productsCount
        childrenCount
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
    totalCount
  }
}

RootCategoryType Enum

The API provides two root category types:

  • PRODUCTS - Product-based categories (Wine, Beer, Spirits, Coolers, etc.)
  • COLLECTIONS - Curated collections (Holiday Gifts, Local Favorites, Value Buys, etc.)

Filter by Parent Category

Use case: Get child categories of a specific parent (e.g., get all wine types under "Wine").

graphql
query ChildCategories($parentId: String!) {
  categories(
    filters: { parentId: $parentId }
    pagination: { first: 50 }
    sortBy: SORT_ORDER
    sortDirection: ASC
  ) {
    edges {
      node {
        id
        name
        slug
        productsCount
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
    totalCount
  }
}

Variables:

json
{
  "parentId": "123"
}

Use cases:

  • Expandable tree views (click to expand)
  • Breadcrumb navigation (show siblings)
  • Category detail pages (show subcategories)

Category with Products

Use case: Get a category with its child categories and products together.

graphql
query CategoryProducts($categoryId: String!) {
  category(id: $categoryId) {
    id
    name
    slug
    path
    productsCount
    products(
      pagination: { first: 20 }
      sortBy: NAME
      sortDirection: ASC
    ) {
      edges {
        node {
          sku
          name
          priceInCents
          producerName
        }
      }
      pageInfo {
        hasNextPage
        endCursor
      }
      totalCount
    }
    children(
      pagination: { first: 20 }
      sortBy: NAME
      sortDirection: ASC
    ) {
      edges {
        node {
          id
          name
          slug
          productsCount
        }
      }
      pageInfo {
        hasNextPage
        endCursor
      }
      totalCount
    }
  }
}

Variables:

json
{
  "categoryId": "123"
}

Two Ways to Get Products by Category

Option 1: category.products

  • Get category metadata + products in one query
  • Best for category landing pages like /wine

Option 2: products(filters: { categoryId })

  • Combine with other filters (price, origin, etc.)
  • Best for search/filter pages

Both return the same products - choose based on whether you need category metadata.

Get Multi-Level Category Tree

Use case: Build a hierarchical tree structure showing categories and their children.

graphql
query NavigationMenu {
  categories(
    filters: { 
      rootType: PRODUCTS
    }
    pagination: { first: 20 }
    sortBy: SORT_ORDER
  ) {
    edges {
      node {
        id
        name
        slug
        path
        childrenCount
        productsCount
        children(
          pagination: { first: 10 }
          sortBy: SORT_ORDER
        ) {
          edges {
            node {
              id
              name
              slug
              productsCount
            }
          }
        }
      }
    }
  }
}

This returns a structure like:

Wine (120 products)
  ├─ Red Wine (45)
  ├─ White Wine (38)
  └─ Sparkling Wine (22)
Beer (85 products)
  ├─ IPA (30)
  ├─ Lager (25)
  └─ Stout (15)

Useful for navigation menus, sidebars, and mobile category pickers.

Sorting Categories

Available sort fields:

  • NAME - Alphabetical by category name
  • SORT_ORDER - Custom order (recommended for navigation)
  • PRODUCTS_COUNT - By number of products (popular first)

Use SORT_ORDER for main navigation to respect editorial ordering.

Use case: Understand a category's position in the hierarchy and its ancestors.

The path field provides the full hierarchical path:

graphql
query CategoryBreadcrumbs($categoryId: String!) {
  category(id: $categoryId) {
    id
    name
    slug
    path
    depth
  }
}

For a category like "Cabernet Sauvignon", the path might be:

"Products/Wine/Red Wine/Cabernet Sauvignon"

Parse the path to build breadcrumbs: Home > Products > Wine > Red Wine > Cabernet Sauvignon

Performance Considerations

Category data changes infrequently - cache for 24 hours. For very deep hierarchies, lazy-load children on demand using the parentId filter rather than fetching everything at once.

Next Steps