Add count field for related_vulnerabilities

What does this MR do and why?

Related #538913 (closed)

This adds a new type CountableVulnerabilityType which set the connection type to CountableConnectionType. This adds a field count for the related_vulnerabilities which allows to show the exact count of related vulnerabilities in the vulnerabilities work item widget.

We will implement a limit (https://gitlab.com/gitlab-org/gitlab/-/issues/538916) for the number of linked vulnerabilities to prevent performance issues with the count.

References

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. Enable feature flag for bulk action: http://gdk.test:3000/rails/features/new_issue_attachment_from_vulnerability_bulk_action
  2. Enable feature flag for work item related vulnerabilities: http://gdk.test:3000/rails/features/work_item_related_vulnerabilities
  3. Import security reports https://gitlab.com/gitlab-examples/security/security-reports
  4. Run pipeline on master
  5. Select some vulnerabilities
  6. In "Select action", choose "Attach to new issue" and click "Create issue"
  7. Add diff below, refresh issue and check graphql call for workItemVulnerabilities and validate it has a count field
diff --git a/ee/app/assets/javascripts/work_items/graphql/work_item_vulnerabilities.query.graphql b/ee/app/assets/javascripts/work_items/graphql/work_item_vulnerabilities.query.graphql
index b209e78d631e..7f843632402f 100644
--- a/ee/app/assets/javascripts/work_items/graphql/work_item_vulnerabilities.query.graphql
+++ b/ee/app/assets/javascripts/work_items/graphql/work_item_vulnerabilities.query.graphql
@@ -28,6 +28,7 @@ query workItemVulnerabilities(
             pageInfo {
               ...PageInfo
             }
+            count
           }
         }
       }

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Lorenz van Herwaarden

Merge request reports

Loading