To edit a taxonomy term data, editTaxonomyTerm mutation should be used. A PATCH method is used for editing. It means that only not empty properties will be updated. If a parent should be set, an appropriate term can be found with getTaxonomyTermByName query Access policy:
  • The API user context should have permission to update the given taxonomy term.
  • A term with the given ID should exist on the site.
  • If parent ID is set and is not equals to 0, a term with this ID should exist.
The following arguments should be used in the mutation, both required:
  • termId - ID of the taxonomy term that should be updated;
  • termData - the object with the following properties:
ArgumentTypeDescription
nameStringAn updated name (label) of the taxonomy term.
parentIdIDThe parent term ID. Set to 0 to reset the level. Set to null or to the current level to keep it unchanged.
Now let’s update the term that was created in the previous step (see Create a taxonomy term for more details). We will remove the parent and update the term title.
mutation editTaxonomyTerm {
  editTaxonomyTerm(
    termId: "11",
    termData: {
    name: "API domain updated",
    parentId: "0"
  }) {
    errors
    response {
      id
      name
      parent {
        id
        name
      }
      vocabulary
      weight
    }
  }
}
Here is a result of the mutation execution: After term editing