Skip to content

WorkItem: Add GraphQl mutation to update color

Abhilash Kotte requested to merge 394863-add-mutation-to-update-color1 into master

What does this MR do and why?

Add mutation to update color

GraphQl mutation to update color widget of a work item

Issue: #394863 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

GraphQl Query

mutation {
  workItemUpdate(
    input: {id: "gid://gitlab/WorkItem/652", colorWidget: {color: "#348333"}}
  ) {
    workItem {
      ...WorkItem
      __typename
    }
    errors
    __typename
  }
}

fragment WorkItem on WorkItem {
  id
  iid
  title
  widgets {
    ...WorkItemWidgets
    __typename
  }
  __typename
}

fragment WorkItemWidgets on WorkItemWidget {
  ... on WorkItemWidgetColor {
    type
    color
    textColor
    __typename
  }
}

GraphQl Response
{
  "data": {
    "workItemUpdate": {
      "workItem": {
        "id": "gid://gitlab/WorkItem/652",
        "iid": "1",
        "title": "TEsting",
        "widgets": [
          {
            "__typename": "WorkItemWidgetAssignees"
          },
          {
            "__typename": "WorkItemWidgetDescription"
          },
          {
            "__typename": "WorkItemWidgetHierarchy"
          },
          {
            "__typename": "WorkItemWidgetLabels"
          },
          {
            "__typename": "WorkItemWidgetNotes"
          },
          {
            "__typename": "WorkItemWidgetStartAndDueDate"
          },
          {
            "__typename": "WorkItemWidgetHealthStatus"
          },
          {
            "__typename": "WorkItemWidgetStatus"
          },
          {
            "__typename": "WorkItemWidgetNotifications"
          },
          {
            "__typename": "WorkItemWidgetAwardEmoji"
          },
          {
            "__typename": "WorkItemWidgetLinkedItems"
          },
          {
            "__typename": "WorkItemWidgetCurrentUserTodos"
          },
          {
            "type": "COLOR",
            "color": "#348333",
            "textColor": "#FFFFFF",
            "__typename": "WorkItemWidgetColor"
          }
        ],
        "__typename": "WorkItem"
      },
      "errors": [],
      "__typename": "WorkItemUpdatePayload"
    }
  }
}

How to set up and validate locally

  1. Enable namespace_level_work_items FF - Feature.enable(:namespace_level_work_items)
  2. Once done, visit any group on GDK and then navigate to its /work_items path, eg; https://gitlab.com/groups/gitlab-org/plan-stage/-/work_items. You should see a Create epic button and that will create a Work Item at group-level with type Epic. Copy the Gid of it.
  3. Got to graphql-explorer and enter the mutation mentioned above with the newly created epic Id. You should see color widget updated value.

Related to #394863 (closed)

Edited by Abhilash Kotte

Merge request reports