Skip to content

Add linkedWorkItems field to IssueType

What does this MR do and why?

Related to #499362

This MR adds the linkedWorkItems field to IssueType on GraphQL. This field exposes a list of work items that are related, blocking or blocked by the issue.

Because issues are a type of work item, we can reuse WorkItems::LinkedItemsResolver to return the items linked to the issue. This means that the same data is already available for WorkItemType but this change is still required for parts of the application that use the legacy endpoints.

Example queries

  • No filter
query workITemsLinkedToIssue {
  project(fullPath: "flightjs/public-project") {
    issue(iid: "4") {
      linkedWorkItems {
        edges {
          node {
            title
          }
        }
      }
    }
  }
}
response
{
  "data": {
    "project": {
      "issue": {
        "linkedWorkItems": {
          "edges": [
            {
              "node": {
                "title": "Blocking Task"
              }
            },
            {
              "node": {
                "title": "Blocked Task"
              }
            },
            {
              "node": {
                "title": "Related Task"
              }
            }
          ]
        }
      }
    }
  },
  "correlationId": "01JH0HS219PGEKHDXD3W7A5PHP"
}
  • Returns work items related to the issue
query workITemsLinkedToIssue {
  project(fullPath: "flightjs/public-project") {
    issue(iid: "4") {
      linkedWorkItems(filter: RELATED) {
        edges {
          node {
            title
          }
        }
      }
    }
  }
}
response
{
  "data": {
    "project": {
      "issue": {
        "linkedWorkItems": {
          "edges": [
            {
              "node": {
                "title": "Related Task"
              }
            }
          ]
        }
      }
    }
  },
  "correlationId": "01JH0HR7G5HX0PCD1DQH2RM3WP"
}
  • Returns work items blocked by the issue
query workITemsLinkedToIssue {
  project(fullPath: "flightjs/public-project") {
    issue(iid: "4") {
      linkedWorkItems(filter: BLOCKS) {
        edges {
          node {
            title
          }
        }
      }
    }
  }
}
response
{
  "data": {
    "project": {
      "issue": {
        "linkedWorkItems": {
          "edges": [
            {
              "node": {
                "title": "Blocked Task"
              }
            }
          ]
        }
      }
    }
  },
  "correlationId": "01JH0HSV7BJ35SPEZGQY2CMC7Y"
}
  • Returns work items blocking the issue
query workITemsLinkedToIssue {
  project(fullPath: "flightjs/public-project") {
    issue(iid: "4") {
      linkedWorkItems(filter: BLOCKED_BY) {
        edges {
          node {
            title
          }
        }
      }
    }
  }
}
response
{
  "data": {
    "project": {
      "issue": {
        "linkedWorkItems": {
          "edges": [
            {
              "node": {
                "title": "Blocking Task"
              }
            }
          ]
        }
      }
    }
  },
  "correlationId": "01JH0HTTRWVNA891V2MPP75PPK"
}

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

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.

Screenshots or screen recordings

No UI changes

How to set up and validate locally

  1. In a rails console generate the records and the values for the request
project, author = Project.first, User.first
work_item_issue = WorkItem.find_by_id(FactoryBot.create(:issue, project: project, author: author).id)

FactoryBot.create(:work_item, :task, title: 'related task', project: project).tap { |task| FactoryBot.create(:work_item_link, source: work_item_issue, target: task) }

FactoryBot.create(:work_item, :task, title: 'blocked task', project: project).tap { |task| FactoryBot.create(:work_item_link, source: work_item_issue, target: task, link_type: 'blocks') }

FactoryBot.create(:work_item, :task, title: 'blocking task', project: project).tap { |task| FactoryBot.create(:work_item_link, source: task, target: work_item_issue, link_type: 'blocks') }

query = <<~QUERY
  query workITemsLinkedToIssue {
    project(fullPath: "#{project.full_path}") {
      issue(iid: "#{issue.iid}") {
        linkedWorkItems {
          edges {
            node {
              title
            }
          }
        }
      }
    }
  }
QUERY

print(query)
  1. Login with root user and visithttp://gdk.test:3000/-/graphql-explorer and verify the query from step 1
  2. Verify the filtering by link type works correctly by adding the filter argument with the values RELATED, BLOCKS and BLOCKED_BY
Edited by Eugenia Grieff

Merge request reports

Loading