Magento 2 How to get Breadcrumb Information about Categories in GraphQL

If you want to use breadcrumb information, we will teach you how to get breadcrumb information about categories in this blog. Use the breadcrumbs attribute to return information about the parent categories of the queried category.

The following query returns breadcrumb information about categories.

Request

Copy
{
  categoryList(filters: {name: {match: "Tops"}}) {
    id
    level
    name
    breadcrumbs {
      category_id
      category_name
      category_level
      category_url_key
    }
  }
}

Response

Copy
{
  "data": {
    "categoryList": [
      {
        "id": 12,
        "level": 3,
        "name": "Tops",
        "breadcrumbs": [
          {
            "category_id": 11,
            "category_name": "Men",
            "category_level": 2,
            "category_url_key": "men"
          }
        ]
      },
      {
        "id": 21,
        "level": 3,
        "name": "Tops",
        "breadcrumbs": [
          {
            "category_id": 20,
            "category_name": "Women",
            "category_level": 2,
            "category_url_key": "women"
          }
        ]
      }
    ]
  }
}

That's it!!

If you are looking for more GraphQL solutions then check out our another article which is List of GraphQL Queries and Mutations for Magento 2.

I hope this article helps you to find what you were looking for.

Bookmark it for your future reference. Do comment below if you have any other questions on that.

P.S. Do share this article with your team.




Search
Recent Posts
    Tags
    Newsletter
    SocialFollow on Twitter
    Visit now!