Add GraphQL endpoints for workflow-pipeline links

What does this MR do and why?

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

  1. Allows fetching all pipelines for a session (pipelineLinks on DuoWorkflow)
  2. Allows fetching all sessions from a pipeline (duoWorkflowLinks on Pipeline)

This mirrors the pattern established for merge request links, notes, and work items.

References

Relates to #603665 (closed)

How to set up and validate locally

  1. Start a fix_pipeline flow against a failing pipeline. Note the workflow ID (from the session info) and the pipeline ID (from the pipeline URL)
  2. Get the GID for the pipeline:
pipeline_id = <MY_PIPELINE_ID_FROM_PIPELINE_URL>
Ci::Pipeline.find(pipeline_id).to_global_id
  1. Confirm the link from the pipeline to the session is available via GraphQL, and the linked workflow matches the noted ID above:
query PipelineWorkflowLinks($pipelineId: CiPipelineID!) {
  project(fullPath: "gitlab-duo/test") {
    pipeline(id: $pipelineId) {
      duoWorkflowLinks {
        nodes {
          linkType
          workflow { id }
        }
      }
    }
  }
}

example output:

{
  "data": {
    "project": {
      "pipeline": {
        "duoWorkflowLinks": {
          "nodes": [
            {
              "linkType": "SOURCE",
              "workflow": {
                "id": "gid://gitlab/Ai::DuoWorkflows::Workflow/4772"
              }
            }
          ]
        }
      }
    }
  },
  "correlationId": "01M0D7B85TYYDMC1HDZZ0YP10W"
}
  1. Confirm the pipelines are available from the session:
query WorkflowPipelineLinks {
  duoWorkflowWorkflows(workflowId: "gid://gitlab/Ai::DuoWorkflows::Workflow/4772") {
    nodes {
      id
      pipelineLinks {
        nodes {
          linkType
          pipeline { id iid }
        }
      }
    }
  }
}

example output:

{
  "data": {
    "duoWorkflowWorkflows": {
      "nodes": [
        {
          "id": "gid://gitlab/Ai::DuoWorkflows::Workflow/4772",
          "pipelineLinks": {
            "nodes": [
              {
                "linkType": "SOURCE",
                "pipeline": {
                  "id": "gid://gitlab/Ci::Pipeline/6582",
                  "iid": "362"
                }
              }
            ]
          }
        }
      ]
    }
  },
  "correlationId": "01M0D7H11A777SX9XG8B2DD0YR"
}

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