Add GraphQL for linking Duo workflow sessions to merge requests

What does this MR do and why?

Adds GraphQL support for linking GitLab Duo Agent Platform workflow sessions to merge requests (both directions):

  1. Allows fetching all MRs for a session (created by session, and MRs that the session was created from)
  2. Allows fetching all Session from an MR

References

Links to Work Items previously added in !242540 (merged)

MR to add link to Notes: !246267 (merged)

Relates to #604024 (closed)

How to set up and validate locally

  1. In a Merge Request, note the URL.

  2. Start a developer flow in a comment, e.g. @duo-developer-gitlab-duo - What is the date?

  3. After the flow completes, get the GID for the merge request:

    project_path = "gitlab-duo/test"
    mr_id = <MY_MR_ID_FROM_URL>
    Project.find_by_full_path(project_path).merge_requests.find_by_iid(mr_id).to_global_id
  4. Confirm the link between the Merge Request and session are available via GraphQL:

    query WorkflowsforMR ($mergeRequestId: MergeRequestID!) {
      mergeRequest(id: $mergeRequestId) {
        id
        duoWorkflowLinks {
          nodes {
            linkType
            workflow { id title }
          }
        }
      }
    }
  5. Confirm the MRs are available from the session:

query WorkflowMRs {                                                                                                                                                                                    
  duoWorkflowWorkflows(workflowId: "gid://gitlab/Ai::DuoWorkflows::Workflow/<YOUR_SESSION_ID_HERE>") {                                                                                                                       
    nodes {                                                                                                                                                                                              
      id                                                                                                                                                                                                 
      mergeRequestLinks {                                                                                                                                                                                
        nodes {                                                                                                                                                                                          
          linkType                                                                                                                                                                                       
          createdAt                                                                                                                                                                                      
          mergeRequest { iid title webUrl }                                                                                                                                                              
        }                                                                                                                                                                                                
      }                                                                                                                                                                                                  
    }                                                                                                                                                                                                    
  }                                                                                                                                                                                                      
} 

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 Roman Eisner

Merge request reports

Loading
Loading