Querying Categories
Inside this guide:
Introduction
Query for a Category
Next steps
Introduction
The coreProductCategory query allows you to query a Category.
Query for a product
Constructing the mutation and input
We'll be using the API Console to save time having to authenticate. Copy and paste this into your API console query section to get started. Reminder that fields can be removed from the query if you don't want the API to return them.
POST /graphql
Query
query ($id: String!) {
coreProductCategory(id: $id) {
id
name
}
}
Defining the variables
Copy and paste the block below into the query variables section of the API console and substitute the CATEGORY_ID with the id of the category you want to retrieve.
Variables
{
"id": CATEGORY_ID,
}
Now press Execute Query (the play button) to send the request.
You should get back this response containing the requested category.
JSON Response
{
"data": {
"coreProductCategory": {
"name": "Electronics",
"id": "73c513ce-c584-46e4-9c51-ddb7aba22575"
}
}
}
Next Steps
- Create Category - Learn how to create a category
- Query Category - Learn how to query a category
- Update Category - Learn how to update a category
- Delete Category - Learn how to delete a category
- Making your first call - If you're not sure how GraphQL works, start here.