Add labels and assignees widgets to work items create mutation
requested to merge 456119-add-missing-arguments-for-creating-epic-work-item-via-graphql-2 into master
What does this MR do and why?
Related to #456119 (closed)
Add support for setting labels and when creating a work item. These arguments are needed for !144705 (closed) (see !144705 (comment 1861625817) for more context).
Summary of changes:
-
Assignees widget: The callback
before_create
was added toWorkItems::Callbacks::Assignees
to set assignees during the work item creation. -
Labels widget: Add a new input file
LabelsCreateInputType
because the existingLabelsUpdateInputType
uses different arguments than the one needed for the WI creation. This widget hasn't been refactored to use a callback class yet but we do have theWorkItems::Widgets::LabelsService::CreateService
which works for setting the param.
MR acceptance checklist
Screenshots or screen recordings
mutation | result |
---|---|
![]() |
![]() |
How to set up and validate locally
- Enable feature flag
namespace_level_work_items
- Visit a group and create two labels in it
- Visit
https://gdk.test:3000/-/graphql-explorer
and test the following query using the corresponding IDs
query
query getWorkItemTypeId{
workspace: group(fullPath: "group-a") {
workItemTypes(name: EPIC) {
edges {
node {
id #=> E.g. "gid://gitlab/WorkItems::Type/8" but can be different in your local environment
}
}
}
}
}
mutation createWIEpic {
workItemCreate(input: {
namespacePath: "group-a", title: "Epic WI with assignees, labels, color and health status",
workItemTypeId: "gid://gitlab/WorkItems::Type/8",
assigneesWidget: {assigneeIds: ["gid://gitlab/User/1", "gid://gitlab/User/2"]},
labelsWidget: {labelIds: ["gid://gitlab/GroupLabel/<label_1_id>", "gid://gitlab/GroupLabel/<label_2_id>"]},
}) {
errors
workItem {
id
webUrl
widgets {
... on WorkItemWidgetAssignees {
assignees {
edges {
node {
username
}
}
}
}
... on WorkItemWidgetLabels {
labels {
edges {
node {
title
}
}
}
}
}
}
}
}
response
{
"data": {
"workItemCreate": {
"errors": [],
"workItem": {
"id": "gid://gitlab/WorkItem/602",
"webUrl": "http://127.0.0.1:3000/groups/group-a/-/work_items/138",
"widgets": [
{},
{
"assignees": {
"edges": [
{
"node": {
"username": "root"
}
},
{
"node": {
"username": "stephany_grant"
}
}
]
}
},
{
"labels": {
"edges": [
{
"node": {
"title": "Green"
}
},
{
"node": {
"title": "Pink"
}
}
]
}
}
]
}
}
}
}
- Visit the work item list using
http://gdk.test:3000/groups/GROUP_PATH/-/work_items
and verify that the the work item was created with the set arguments
Related to #456119 (closed)
Edited by Eugenia Grieff