This repository was archived by the owner on Nov 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add breadcrumb info to GraphQL categories topic #2767
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2bb5798
Add breadcrumb info
keharper 2a8fba7
Merge branch 'master' of github.com:magento/devdocs into kh_graphql-1…
keharper e179f2d
editorial comments
keharper 2ae5f53
editorial comments
keharper d827569
Update categories.md
keharper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
editorial comments
- Loading branch information
commit e179f2d6d2de7693ee82f7d3960869478a888cbb
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ The `category` endpoint allows you to search for a single category definition or | |
|
|
||
| ## Query structure | ||
|
|
||
| ``` | ||
| ``` | ||
| category ( | ||
| id: int | ||
| ): CategoryTree | ||
|
|
@@ -39,7 +39,7 @@ Attribute | Data type | Description | |
| `product_count`| Int | The number of products in the category | ||
| `default_sort_by`| String | The attribute to use for sorting | ||
| `products(<attributes>)` | `CategoryProducts` | The list of products assigned to the category | ||
| `breadcrumbs` | `Breadcrumb` | | ||
| `breadcrumbs` | `Breadcrumb` | A `Breadcrumb` object contains information about each category that | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing the end of the Breadcrumb description..... |
||
| `children` | `CategoryTree` | A `CategoryTree` object that contains information about a child category. You can specify up to 10 levels of child categories. | ||
|
|
||
|
|
||
|
|
@@ -51,7 +51,7 @@ Attribute | Data type | Description | |
| --- | --- | --- | ||
| `pageSize` | Int | Specifies the maximum number of results to return at once. This attribute is optional. The default value is 20. | ||
| `currentPage` | Int | Specifies which page of results to return. The default value is 1. | ||
| `sort` | `ProductSortInput` | Specifies which attribute to sort on, and whether to return the results in ascending or descending order. See [Searches and pagination in GraphQL]({{ page.baseurl }}/graphql/search-pagination.html) for more information. | ||
| `sort` | `ProductSortInput` | Specifies which attribute to sort on, and whether to return the results in ascending or descending order. [Searches and pagination in GraphQL]({{ page.baseurl }}/graphql/search-pagination.html) describes sort orders. | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the way you changed the "See" reference 🥇 |
||
| The `CategoryProducts` object contains the following attributes: | ||
|
|
||
|
|
@@ -74,11 +74,16 @@ Attribute | Data type | Description | |
| `category_level` | Int | Indicates the depth of the category within the tree | ||
| `category_url_key` | String | The url key assigned to the category | ||
|
|
||
| #### CategoryTree object | ||
|
|
||
| This `CategoryTree` object contains information about the next level of subcategories of the category specified in the original query. | ||
|
|
||
| ## Sample Queries | ||
|
|
||
| The following query returns information about category ID `20` and four levels of subcategories. In the sample data, category ID `20` is assigned to the "Women" category. | ||
|
|
||
| **Request** | ||
|
|
||
| ``` | ||
| { | ||
| category(id: 20) { | ||
|
|
@@ -117,9 +122,88 @@ The following query returns information about category ID `20` and four levels o | |
| } | ||
| } | ||
| ``` | ||
| **Response** | ||
|
|
||
| ``` json | ||
| { | ||
| "data": { | ||
| "category": { | ||
| "products": { | ||
| "total_count": 0, | ||
| "page_info": { | ||
| "current_page": 1, | ||
| "page_size": 20 | ||
| } | ||
| }, | ||
| "children_count": "8", | ||
| "children": [ | ||
| { | ||
| "id": 21, | ||
| "level": 3, | ||
| "name": "Tops", | ||
| "path": "1/2/20/21", | ||
| "children": [] | ||
| }, | ||
| { | ||
| "id": 22, | ||
| "level": 3, | ||
| "name": "Bottoms", | ||
| "path": "1/2/20/22", | ||
| "children": [ | ||
| { | ||
| "id": 23, | ||
| "level": 4, | ||
| "name": "Jackets", | ||
| "path": "1/2/20/21/23", | ||
| "children": [] | ||
| }, | ||
| { | ||
| "id": 24, | ||
| "level": 4, | ||
| "name": "Hoodies & Sweatshirts", | ||
| "path": "1/2/20/21/24", | ||
| "children": [] | ||
| }, | ||
| { | ||
| "id": 25, | ||
| "level": 4, | ||
| "name": "Tees", | ||
| "path": "1/2/20/21/25", | ||
| "children": [] | ||
| }, | ||
| { | ||
| "id": 26, | ||
| "level": 4, | ||
| "name": "Bras & Tanks", | ||
| "path": "1/2/20/21/26", | ||
| "children": [] | ||
| }, | ||
| { | ||
| "id": 27, | ||
| "level": 4, | ||
| "name": "Pants", | ||
| "path": "1/2/20/22/27", | ||
| "children": [] | ||
| }, | ||
| { | ||
| "id": 28, | ||
| "level": 4, | ||
| "name": "Shorts", | ||
| "path": "1/2/20/22/28", | ||
| "children": [] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| The following query returns breadcrumb information about the women's tops category (`id` = 25). | ||
|
|
||
| **Request** | ||
|
|
||
| ``` | ||
| { | ||
| category ( | ||
|
|
@@ -137,3 +221,31 @@ The following query returns breadcrumb information about the women's tops catego | |
| } | ||
| } | ||
| ``` | ||
|
|
||
| **Response** | ||
|
|
||
| ``` json | ||
| { | ||
| "data": { | ||
| "category": { | ||
| "id": 25, | ||
| "level": 4, | ||
| "name": "Tees", | ||
| "breadcrumbs": [ | ||
| { | ||
| "category_id": 20, | ||
| "category_name": "Women", | ||
| "category_level": 2, | ||
| "category_url_key": "women" | ||
| }, | ||
| { | ||
| "category_id": 21, | ||
| "category_name": "Tops", | ||
| "category_level": 3, | ||
| "category_url_key": "tops-women" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it helps, but consider adding a "for example"
define a response so that it contains up to ten nested
childrenoptions, for example the query can return a CategoryTree object with up to ten levels of categories, and each of those categories can contain up to ten CategoryTree objects with up to ten subcategories.Also, in the Sample Queries section -- It might be good to show a real response for the CategoryTree query since it's kind of complicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left the description as is, but added sample output.