How To Get Category By Using GraphQL in Magento 2.x

The following below Magento Open Source / Adobe Commerce 2.x GraphQL Query to get Category

category (
  id: int
): CategoryTree

The category query has been deprecated. Use the below categories query instead.

How To Get List of Categories By Using GraphQL in Magento 2.x

To Get Category Tree of a Top-Level Category

{
  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
          }
        }
      }
    }
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *