Skip to content

[GraphQL] Add query support for user's merge requests

Alex Kalderimis requested to merge ajk-GQL-user-mrs into master

What does this MR do?

Addresses: #217475 (closed)

This MR adds missing functionality in GraphQL to:

  • find MRs by a given author
  • find MRs assigned to a given author

To support this, we also need to find users by username.

Example Query

query {
  root: user(username: "root") {
    allAssignedMRs: assignedMergeRequests {
      nodes { title }
    }
    deliverables: assignedMergeRequests(labels: ["Altima"]) {
      nodes { title, description }
    }
    authoredMergeRequests(projectPath: "gitlab-org/gitlab-test") {
      nodes { title, description, project {fullPath} }
    }
  }
}

Example response:

{
  "data": {
    "root": {
      "allAssignedMRs": {
        "nodes": [
          {
            "title": "Voluptas fuga dolor soluta reprehenderit amet perferendis at debitis."
          },
          {
            "title": "Voluptatum quibusdam non rerum ut et sed."
          },
          {
            "title": "Vel velit consequuntur nemo ut omnis provident."
          },
          {
            "title": "Sed pariatur omnis aut inventore repellat ut."
          }
        ]
      },
      "deliverables": {
        "nodes": [
          {
            "title": "Vel velit consequuntur nemo ut omnis provident.",
            "description": "Natus voluptatibus voluptatem sit atque. Dolorem atque et eius qui. Fuga omnis corrupti est sed iusto."
          }
        ]
      },
      "authoredMergeRequests": {
        "nodes": [
          {
            "title": "Cannot be automatically merged",
            "description": null,
            "project": {
              "fullPath": "gitlab-org/gitlab-test"
            }
          },
          {
            "title": "Can be automatically merged",
            "description": null,
            "project": {
              "fullPath": "gitlab-org/gitlab-test"
            }
          },
          {
            "title": "Animi alias aliquam delectus voluptatem deleniti error voluptates perspiciatis ut.",
            "description": "Eum ab nulla sapiente sit maxime veniam. Eaque quas veritatis inventore quo atque. Consequatur sint quia vitae itaque tenetur.",
            "project": {
              "fullPath": "gitlab-org/gitlab-test"
            }
          }
        ]
      }
    }
  }
}

Screenshots

1588774072

1588772144

1588772097

1588771745

1588771715

1588774805

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Alex Kalderimis

Merge request reports

Loading