Skip to content

Add group level work item description diff endpoints

Mario Celi requested to merge 431215-diff-routes-group-level into master

What does this MR do and why?

Adding two new routes to our internal REST API. This are necessary in the new work items API to fetch legacy diffs. In the future they will be replaced in the GQL API. Created &12091 to track that work

How to set up and validate locally

  1. Go to GraphiQL locally at http://127.0.0.1:3000/-/graphql-explorer
  2. Enable the feature flag in Rails console Feature.enable(:namespace_level_work_items)
  3. 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
         }
       }
     }
  4. update the description on the newly created work item
    mutation {
       workItemUpdate(input: {id: "<gid_from_previous_step>", descriptionWidget: {description: "updated description"}}) {
         errors
         workItem {
           iid
           workItemType {
             name
           }
           widgets {
             ... on WorkItemWidgetDescription {
               description
             }
           }
         }
       }
     }
  5. Fetch description diffs:
     {
       group(fullPath: "flightjs") {
         id
         workItem(iid: "<work_item_iid>") {
           nodes {
             widgets {
               ... on WorkItemWidgetNotes {
                 discussions {
                   nodes {
                     notes {
                       nodes {
                         systemNoteMetadata {
                           descriptionVersion {
                             diffPath
                             deletePath
                           }
                         }
                       }
                     }
                   }
                 }
               }
             }
           }
         }
       }
     }
    The query would error before this change. Now diffPath will be returned and you can use it in the url to get the diff. This is a new route added in this MR too

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 #431215 (closed)

Edited by Mario Celi

Merge request reports