Deleting Categories

Inside this guide:
Introduction
Delete a Category
Next steps

Introduction

The deleteCoreProductCategory mutation allows you to delete a Category.

Delete 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

mutation ($input: DeleteCoreProductCategoryInput!) {
    deleteCoreProductCategory(input: $input) {
        errors {
            path
            message
        }
    }
}

Defining the variables

Copy and paste the block below into the query variables section of the API console and substitute the CATEGORY_ID with id of the category you want to delete. Variables


{
  "input": {
    "id": CATEGORY_ID
  }
}

Now press Execute Query (the play button) to send the request.

You should get back this response that doesn't have any errors, this confirms the category has been deleted.

JSON Response

{
  "data": {
    "deleteCoreProductCategory": {
      "errors": null
    }
  }
}

Next Steps