Skip to content

WorkItemConvert mutation

Nicolas Dular requested to merge nd/poc-work-item-type-change into master

What does this MR do and why?

Part of #386876 (closed) and &9438 (comment 1281758135).

This MR introduces a mutation to change the work item type. It's using a separate mutation, instead of the existing update mutation, prevent cases where a new type gets set + new data for a widget that doesn't exist in the new type. As the mutation is in alpha, we could still remove it in the future if we see that there are issues with this approach.

The approach we take is that we allow to convert any work item type to any other and

  1. Validate if the hierarchy restrictions allow it (this is done in !113852 (merged))
  2. Remove the widget data that is no longer available in the new type

It's branched off from !113852 (merged) where I worked on the work item type validation on the Model layer to make this MR smaller.

Screenshots or screen recordings

key_result_to_objective

How to set up and validate locally

  1. Feature.enable(:work_item_conversion)
  2. Create a work item (e.g. OKR, Key Result, or Task)
  3. Fill in the data and change the types
  4. You can get the work item type IDs by quering: WorkItems::Type.all
query workItem {
  workItem(id: "gid://gitlab/WorkItem/713") {
    id
    workItemType {
      id
      name
    }
  }
}

mutation convertWorkItem {
  workItemConvert(input:{id: "gid://gitlab/WorkItem/713", workItemTypeId:"gid://gitlab/WorkItems::Type/3186"}) {
    clientMutationId
  }
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Nicolas Dular

Merge request reports