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

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

Syntax

categories(filters: CategoryFilterInput pageSize: Int currentPage: Int): CategoryResult

[1] To Display List of Categories

{
  categories(
    filters: {
      ids: {in: ["3", "9", "12", "21", "38", "39"]}
      parent_id: {in: ["2"]}
    }
    pageSize:2
    currentPage: 1
  ) {
    total_count
    items {
      uid
      level
      name
      path
      children_count
      children {
        uid
        level
        name
        path
        children_count
        children {
          uid
          level
          name
          path
        }
      }
    }
    page_info {
      current_page
      page_size
      total_pages
    }
  }
}

Leave a Reply

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