Skip to content

GraphQL: Add hierarchyWidget to work item update mutation

Eugenia Grieff requested to merge 362213-update-hierarchy-widget into master

What does this MR do and why?

This MR corresponds to the second task of #362213 (closed) and adds the ability to update the parent or children of a work item using the GraphQL mutation workItemUpdate.

For this functionality we need to add the following services:

  • WorkItems::Widgets::HierarchyService::UpdateService

    Called from WorkItems::UpdateService#execute_widgets, handles the widget-specific params and calls WorkItems::ParentLinks::CreateService to update the links.

  • WorkItems::ParentLinks::CreateService

    Inherits from IssuableLinks::CreateService and creates WorkItems::ParentLink objects.


We are adding extra functionality in the following MRs to keep this MR as small as possible:

How to set up and validate locally

  1. Enable :work_items and work_items_hierarchy feature flags

    Feature.enable(:work_items)
    Feature.enable(:work_items_hierarchy)
  2. Run GraphQL query with http://local-url/-/graphql-explorer

updateParent
mutation updateParent {
  workItemUpdate(input: { id: "gid://gitlab/Issue/{TASK_ID}", hierarchyWidget: { parentId: "gid://gitlab/Issue/{ISSUE_ID}"}}) {
    workItem {
      id
      description
      widgets {
        ... on WorkItemWidgetHierarchy {
            parent {
              id
            }
          }
        }
      }
    }
  }
}
updateChildren
mutation updateChildren {
  workItemUpdate(input: { id: "gid://gitlab/Issue/{ISSUE_ID}", hierarchyWidget: { childrenIds: ["gid://gitlab/Issue/{TASK_ID}"]}}) {
    workItem {
      id
      description
      widgets {
        ... on WorkItemWidgetHierarchy {
            children {
              edges {
                node {
                  id
                }
              }
            }
          }
        }
      }
    }
  }
}

MR acceptance checklist

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

Related to #362213 (closed)

Edited by Eugenia Grieff

Merge request reports

Loading