Skip to content

Resolve "Delete Merge Train Car GraphQL mutation"

What does this MR do and why?

This MR adds a new graphql mutation that deletes a MergeTrainCar

  • a merge train car represents an existing merge request that has been associated with a project's merge train(a record in the MergeTrain table)

  • the mutation calls an existing service AutoMerge::MergeTrainService to remove the :car from the merge train by cancelling it

  • the mutation raises errors if it is not successful

  • This MR also exposes the :delete_car user permission to the frontend through the CarType

  • Fixes a small for the branch field's type on CarType

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.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Screenshot_2024-06-27_at_10.50.52_AM

Screenshot_2024-06-27_at_11.56.52_AM

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. In rails console enable the experiment fully
    Feature.enable(:merge_trains_viz)
  2. EE license required
  3. In order to delete a merge train car you must have existing merge train cars (records on the merge train table associated with the same project) AND be a maintainer of the project
  4. Visit http://localhost:3000/-/graphql-explorer to test the mutation

Delete mutation syntax:

mutation {
  mergeTrainsDeleteCar(
    input: { 
      carId: "gid://gitlab/MergeTrains::Car/<merge_train.id>"
    }) {
    errors
  }
}

Select mutation syntax (for checking userPermissions field and the branch type fix)

{
  project(fullPath: "namespace1/project-1") {
    id
    mergeTrains {
      count
      nodes { 
       targetBranch
        cars {
          nodes {
            status
            targetBranch
            userPermissions {
              deleteCar
            }
          }
        }
      }
    }
  }
}

Related to #458749

Edited by Panos Kanellidis

Merge request reports