Skip to content

Fix issue.hasParent field

What does this MR do and why?

Related to #451920 (closed)

Issues can only have one type of parent at a time, so if they are assigned to an epic issues.hasParent should be false, however, there is currently one exception to this when the epic is synced to a work item and the issue is linked to an epic as well as a work item.

Regardless, the GraphQL field issues.hasParent should still be false for these cases because the epic relationship is prioritised while we keep supporting legacy epics.

This MR updates the method used by this field so it always returns false if there is an epic assigned to the issue.

issue.epic.work_item == issue.work_item_parent.synced_epic #=> true

# current
issue.has_epic? #=> true
issue.has_parent_link? #=> true

# expected
issue.has_epic? #=> true
issue.has_parent_link? #=> false

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.

How to set up and validate locally

  1. Enable the feature flag epic_creation_with_synced_work_item

  2. Go to Groups > Select any group > Epics > New Epic > Create an Epic

  3. Go to any project of the selected group where Epic is created

  4. Create an issue and select the legacy Epic from the sideba

  5. Visit http://<gdk_root>/-/graphql-explorer and test the following query, replacing the issue details:

    query getIssue {
      project(fullPath: <project_path>) {
        issues(iid: <issue_iid>) {
          edges {
            node {
              hasEpic
              hasParent
            }
          }
        }
      }
    }
  6. Verify the response returns the correct values

    {
      "data": {
        "project": {
          "issues": {
            "edges": [
              {
                "node": {
                  "hasEpic": true,
                  "hasParent": false
                }
              }
            ]}}}}
Edited by Eugenia Grieff

Merge request reports