Allow excluding group-level work items in group.workItems GQL field

What does this MR do and why?

Adds exclude_group_work_items parameter to WorkItems::WorkItemsFinder to match IssuesFinder behaviour, which will enable migrating the group-level issues list to use the work items API.

ETA: The parameter was included in a separate MR (!202865 (merged)), this one was updated to add the GQL argument and tests.

Changes:

  • Add exclude_group_work_items param to WorkItems::WorkItemsFinder (defaults false). When true, filters out group-level work items, returning only project work items
  • Add argument excludeGroupWorkItems to the GraphQL fields namespace.workItems and group.workItems

Database

  • No new DB queries - reuses existing exclusion logic
  • Same query plan as the current IssuesFinder group behaviour
WorkItems::WorkItemsFinder.new(current_user, { group_id: group.id, include_descendants: true, exclude_projects: false, exclude_group_work_items: true }).execute
exclude_group_work_items value query plan
false https://console.postgres.ai/gitlab/gitlab-production-main/sessions/42808/commands/131076
true https://console.postgres.ai/gitlab/gitlab-production-main/sessions/42808/commands/131066

References

Related to #565433 (closed)

Screenshots or screen recordings

GraphQL request to fetch work items
Before After
Screenshot_2025-08-27_at_13.32.46 Screenshot_2025-08-27_at_13.33.04

How to set up and validate locally

  1. Create a group and a subgroup. Add a project in each level
  2. Create a work item in each (requires enabling the flag create_group_level_work_items for the group-level work item)
createWorkItem
mutation createWorkItem {
  workItemCreate(input: {
    namespacePath: {group_path|project_path}, title: "Issue in {group_path|project_path}",
    workItemTypeId: "gid://gitlab/WorkItems::Type/1"
  }) {	
    workItem {
      id
      workItemType { name }
    }
    errors
  }
}
  1. Use the following query with the different argument combinations to verify that group-level work items are excluded
getWorkItems
query getWorkItems($excludeProjects: Boolean, $includeDescendants: Boolean, $excludeGroupWorkItems: Boolean, $fullPath: ID!) {
  group(fullPath: $fullPath) {
    workItems(
      excludeProjects: $excludeProjects
      includeDescendants: $includeDescendants
      excludeGroupWorkItems: $excludeGroupWorkItems
    ) {
      nodes {
        title
      }
    }
  }
}
{
  "excludeProjects": false,
  "includeDescendants": true,
  "excludeGroupWorkItems": true,
  "fullPath": "root-group"
}

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 Eugenia Grieff

Merge request reports

Loading