Resolve "Associate a work item to a milestone"
What does this MR do and why?
Addresses the task Associate a work item to a milestone
in #367463 (closed) by implementing GraphQL APIs for querying and mutating a work item's milestone.
Background/Context
Work item is the new domain model that will supersede various issuables in GitLab. Currently, Work Item is practically an alias for Issue, backed by the same table with different models:
# The two point to the same row in 'issues' table.
WorkItem.first # its gid is 'gid://gitlab/WorkItem/1'
Issue.first # its gid is 'gid://gitlab/Issue/1'
- A work item has a type: it can be an issue, incident, task or epic for example.
- Each work item type can have a different set of "widgets". For example, a work item of type issue may have
description
widget andlabels
widget. So you can think of a widget as a wrapper around model attributes.
In this MR, we want to implement GraphQL APIs for querying and mutating a work item's milestone attribute following the widget interface.
How to set up and validate locally
- Enable the work items feature (it's enabled by default and this step should not be necessary.)
Feature.enable(:work_items)
- Create a milestone for a project (and a group)
Sample GraphQL mutation: Associate milestone to a new work item
mutation {
workItemCreate(input: {
projectPath: "gitlab-org/gitlab"
title: "My work item"
workItemTypeId: "gid://gitlab/WorkItems::Type/1"
milestoneWidget: {
milestoneId: "gid://gitlab/Milestone/1"
}
}) {
workItem {
id
title
widgets {
... on WorkItemWidgetMilestone {
milestone {
id
title
}
}
}
}
errors
}
}
Sample GraphQL mutation: Associate milestone to an existing work item
- Use
milestoneId: null
to unset milestone
mutation {
workItemUpdate(input: {
id: "gid://gitlab/WorkItem/1",
milestoneWidget: {
milestoneId: "gid://gitlab/Milestone/1"
}
}) {
workItem {
id
title
widgets {
... on WorkItemWidgetMilestone {
milestone {
id
title
}
}
}
}
errors
}
}
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by euko