Skip to content

Add a work item widget for iteration

euko requested to merge support-iteration-for-work-item into master

What does this MR do and why?

Addresses the task Associate a work item to an iteration in #367456 (closed) by implementing GraphQL APIs for querying and mutating a work item's iteration.

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 and labels 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 iteration attribute following the widget interface.

Given an issue (work item), we would query and mutate its iteration like this:
mutation {
  issueSetIteration(input: {
    projectPath: "gitlab-org/gitlab"
    iid: "1"
    iterationId: "gid://gitlab/Iteration/1"
  }) {
    issue {
      iteration {
        id
      }
    }
  }
}
The APIs added in this MR achieve exactly the same using different interfaces (note the input asks for the global id rather than `project_path` + `iid`):
mutation {
  workItemUpdate(input: {
    id: "gid://gitlab/WorkItem/1"
    iterationWidget: {
      iterationId: "gid://gitlab/Iteration/1"
    }
  }) {
    workItem {
      widgets {
        ... on WorkItemWidgetIteration {
          iteration {
            id
          }
        }
      }
    }
    errors
  }
}

How to set up and validate locally

  • Create a new issue and note its projectPath (e.g., gitlab-org/gitlab), iid and its global id.

If the issue's global id is "gid://gitlab/Issue/1", its global id as work item is "gid://gitlab/Issue/1".

  • Create a new Iterations Cadence (do not use the automatic scheduling feature) and create a new iteration.

    • To create a new Iterations Cadence you must visit it at the group level.

    • Note the iteration's global id.

Demo: creating a new Iterations Cadence + iteration

Screen_Recording_2022-09-01_at_18.32.38

  • Test the following mutation with different iterationId (null or global ids for iterations):
Sample mutation
mutation {
  workItemUpdate(input: {
    id: "gid://gitlab/WorkItem/1"
    iterationWidget: {
      iterationId: "gid://gitlab/Iteration/1"
    }
  }) {
    workItem {
      widgets {
        ... on WorkItemWidgetIteration {
          iteration {
            id
          }
        }
      }
    }
    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.

Edited by euko

Merge request reports

Loading