Skip to main content

createCategory

Requires permission categories:category:create.

Creates a category. The code must not be used by another active category, and a parent, when given, must exist. The level and path follow from the parent. Requires permission to create categories.

Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.

Example:

mutation CreateCategory($input: CreateCategoryInput!) {
createCategory(input: $input) {
id
code
name
createdAt
childrenCount
deletedAt
children {
id
code
name
createdAt
childrenCount
deletedAt
}
}
}

Variables:

{
"input": {
"code": "string",
"isActive": true,
"name": "string",
"sortOrder": 0
}
}

Response:

{
"data": {
"createCategory": {
"id": "id",
"code": "string",
"name": "string",
"createdAt": "2025-01-15T00:00:00Z",
"childrenCount": 0,
"deletedAt": "2025-01-15T00:00:00Z",
"children": [
{
"id": "id",
"code": "string",
"name": "string",
"createdAt": "2025-01-15T00:00:00Z",
"childrenCount": 0,
"deletedAt": "2025-01-15T00:00:00Z"
}
]
}
}
}
createCategory(
input: CreateCategoryInput!
): Category!

Arguments​

createCategory.input ● CreateCategoryInput! non-null input​

The details of the category to create.

Type​

Category object​

A node in the category tree. A root category is an ordinary category.