Skip to content

Fix fetching discussions for group level work items with system notes

Mario Celi requested to merge 428853-fix-discussions-with-system-notes into master

What does this MR do and why?

Fetching discussions for group level work items / issues was broken when the work item has system notes related to labels (added, removed). Other events that inherit from ResourceEvent were also checked for errors

How to set up and validate locally

  1. Enable the feature flag in Rails console Feature.enable(:namespace_level_work_items)
  2. Create a group level work item with the following query at http://127.0.0.1:3000/-/graphql-explorer so you can use it in the next query
    mutation {
       workItemCreate(input: {namespacePath: "flightjs", title: "test group level work item", workItemTypeId: "gid://gitlab/WorkItems::Type/1"}) {
         errors
         workItem {
           id
           iid
         }
       }
     }
  3. Go to the new work item page at http://127.0.0.1:3000/groups/flightjs/-/work_items/<iid_from_previous_step> and add some labels. Make sure they are added by refreshing the page. No system notes are shown since fetching notes is currently broken in the frontend too.
  4. Fetch notes using the GraphQL API again. Note that this query uses a global ID and not an internal ID
     {
       workItem(id: "<id_from_previous_step>") {
         id
         widgets {
           ... on WorkItemWidgetNotes {
             discussions {
               nodes {
                 notes {
                   nodes {
                     body
                   }
                 }
               }
             }
           }
         }
       }
     }

Before this change you would get an exception. Now you should receive a list of notes including those related to labels as system notes

This feature is still behind a feature flag so no changelog required

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #428853 (closed)

Edited by Mario Celi

Merge request reports