Skip to content

POC to retrieve a list of open MRs that change a specific file

Gavin Hinfey requested to merge 469574-open-mrs-for-blob-poc into master

What does this MR do and why?

It is a proof of concept for a GraphQL endpoint which lists open MRs which alter a given file. The query will need some work as it is taking 111.411 ms to run on a large repository for the master branch README.md file. See Postgres.ai query plan.

The GraphQL query below is running in GDK on a new project with a 3 merge requests targeting the 'main' branch and another merge request targeting a 'new-branch'.

GraphQL query:

query getOpenMrsForBlob {
    project(fullPath: "root/blob-mr-test"){
      name
      repository{
        new_branch_head: blobs(ref: "d732ea9f4bab32d7e6bdf37bca609c30ad44ef29", paths: ["README.md", "newfile", "newfile1.md", "newfile2.md", "newfile3.md"]){
          nodes{
            name
            openMrsForBlob(targetBranch: "new-branch"){
              title
              webPath
            }
          }
        }
        default_main_head: blobs(paths: ["README.md", "newfile", "newfile1.md", "newfile2.md", "newfile3.md"]){
          nodes{
            name
            openMrsForBlob(targetBranch: "main"){
              title
              webPath
            }
          }
        }
      }
    }
  }

Returns:

{
  "data": {
    "project": {
      "name": "blob mr test",
      "repository": {
        "new_branch_head": {
          "nodes": [
            {
              "name": "README.md",
              "openMrsForBlob": [
                {
                  "title": "creates new file, changes readme, targets new branch",
                  "webPath": "/root/blob-mr-test/-/merge_requests/2"
                }
              ]
            },
            {
              "name": "newfile",
              "openMrsForBlob": [
                {
                  "title": "creates new file, changes readme, targets new branch",
                  "webPath": "/root/blob-mr-test/-/merge_requests/2"
                }
              ]
            }
          ]
        },
        "default_main_head": {
          "nodes": [
            {
              "name": "README.md",
              "openMrsForBlob": [
                {
                  "title": "changes readme",
                  "webPath": "/root/blob-mr-test/-/merge_requests/1"
                }
              ]
            },
            {
              "name": "newfile1.md",
              "openMrsForBlob": [
                {
                  "title": "changes newfile1 newfile2",
                  "webPath": "/root/blob-mr-test/-/merge_requests/3"
                },
                {
                  "title": "Changes all 'new files'",
                  "webPath": "/root/blob-mr-test/-/merge_requests/4"
                }
              ]
            },
            {
              "name": "newfile2.md",
              "openMrsForBlob": [
                {
                  "title": "changes newfile1 newfile2",
                  "webPath": "/root/blob-mr-test/-/merge_requests/3"
                },
                {
                  "title": "Changes all 'new files'",
                  "webPath": "/root/blob-mr-test/-/merge_requests/4"
                }
              ]
            },
            {
              "name": "newfile3.md",
              "openMrsForBlob": [
                {
                  "title": "Changes all 'new files'",
                  "webPath": "/root/blob-mr-test/-/merge_requests/4"
                }
              ]
            }
          ]
        }
      }
    }
  }
}

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.

How to set up and validate locally

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

Related to #469574 (closed)

Edited by Gavin Hinfey

Merge request reports

Loading