Skip to content

Add linkedWorkItems field to EpicType

What does this MR do and why?

Related to #499772 (closed)

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

Because epics are a type of work item, we can reuse WorkItems::LinkedItemsResolver to return the items linked to the epic. 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 workItemsLinkedToEpic {
  group(fullPath: "flightjs") {
    epic(iid: "8") {
      linkedWorkItems {
        nodes {
          title
        }
      }
    }
  }
}
response
{
  "data": {
    "group": {
      "epic": {
        "linkedWorkItems": {
          "nodes": [
            {
              "title": "Blocking Task"
            },
            {
              "title": "Blocked Task"
            },
            {
              "title": "Related Task"
            }
          ]
        }
      }
    }
  },
  "correlationId": "01JH0D6SG7MW25TRR988FVNGRC"
}
  • Returns work items related to the epic
query workItemsLinkedToEpic {
  group(fullPath: "flightjs") {
    epic(iid: "8") {
      linkedWorkItems(filter: RELATED) {
        nodes {
          title
        }
      }
    }
  }
}
response
{
  "data": {
    "group": {
      "epic": {
        "linkedWorkItems": {
          "nodes": [
            {
              "title": "Related Task"
            }
          ]
        }
      }
    }
  },
  "correlationId": "01JH0D87FJMXGYW8B88RY5X54S"
}
  • Returns work items blocked by the epic
query workItemsLinkedToEpic {
  group(fullPath: "flightjs") {
    epic(iid: "8") {
      linkedWorkItems(filter: BLOCKS) {
        nodes {
          title
        }
      }
    }
  }
}
response
{
  "data": {
    "group": {
      "epic": {
        "linkedWorkItems": {
          "nodes": [
            {
              "title": "Blocked Task"
            }
          ]
        }
      }
    }
  },
  "correlationId": "01JH0DANKNZ0EVMYTQ1CN46RCK"
}
  • Returns work items blocking the epic
query workItemsLinkedToEpic {
  group(fullPath: "flightjs") {
    epic(iid: "8") {
      linkedWorkItems(filter: BLOCKED_BY) {
        nodes {
          title
        }
      }
    }
  }
}
response
{
  "data": {
    "group": {
      "epic": {
        "linkedWorkItems": {
          "nodes": [
            {
              "title": "Blocking Task"
            }
          ]
        }
      }
    }
  },
  "correlationId": "01JH0DBZ95BRJWNZRJ8RKX7EWG"
}

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 UX changes

How to set up and validate locally

  1. In a rails console generate the data and the query
group, project, author = Group.first, Project.first, User.first
epic_work_item = FactoryBot.create(:epic, :with_synced_work_item, group: group, author: author).work_item

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

FactoryBot.create(:work_item, :task, title: 'blocked task', project: project).tap { |task| FactoryBot.create(:work_item_link, source: epic_work_item, 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: epic_work_item, link_type: 'blocks') }

query = <<~QUERY
  query workITemsLinkedToEpic {
    group(fullPath: "#{group.full_path}") {
      epic(iid: "#{epic_work_item.iid}") {
        linkedWorkItems {
          edges {
            node {
              title
            }
          }
        }
      }
    }
  }
QUERY

print(query)
  1. Login with root user and verify the printed query in http://gdk.test:3000/-/graphql-explorer
  2. Verify the filtering by link type works correctly by adding the filter argument with the values RELATED, BLOCKS and BLOCKED_BY (as shown in the example queries above)
Edited by Eugenia Grieff

Merge request reports

Loading