Creating categories
Introduction
This guide describes how to create and update categories from the Traide GraphQL API.
Create a category
Use the categoryCreate mutation.
mutation {
categoryCreate(
input: {
name: "Books"
description: "Those things with pages in them"
allowProductAssignment: true
}
) {
category {
id
name
description
allowProductAssignment
}
productErrors {
field
message
code
}
}
}
Show more ↓
Response:
{
"data": {
"categoryCreate": {
"category": {
"id": "Q2F0ZWdvcnk6MjM=",
"name": "Books",
"description": "Those things with pages in them",
"allowProductAssignment": true
},
"productErrors": []
}
}
}
Update a category
In order to update a given category, you'll need its ID. In the example above, the category ID is "Q2F0ZWdvcnk6MjM=".
Here's an example of the categoryUpdate mutation:
mutation {
categoryUpdate(
id: "Q2F0ZWdvcnk6MjM="
input: {
name: "Books & Magazines"
seo: { title: "Books", description: "Has pages" }
}
) {
category {
id
name
description
allowProductAssignment
seoTitle
seoDescription
}
productErrors {
field
message
code
}
}
}
Show more ↓
Response:
{
"data": {
"categoryUpdate": {
"category": {
"id": "Q2F0ZWdvcnk6MjM=",
"name": "Books & Magazines",
"description": "Those things with pages in them",
"allowProductAssignment": true,
"seoTitle": "Books",
"seoDescription": "Has pages"
},
"productErrors": []
}
}
}