Skip to content

Add approvalRules to MergeRequest GraphQL API

What does this MR do?

This change adds new field to MergeRequest GraphQL API that allow users to fetch information about MR approvals.

Screenshots or Screencasts (strongly suggested)

screencapture-gdk-alan-3000-graphql-explorer-2021-08-19-00_21_25

How to setup and validate locally (strongly suggested)

  1. Create new project.
  2. Go to Settings -> Merge request (MR) approvals
  3. Configure at least one approval rule.
  4. Create at least one MR for created project.
  5. Go to GraphQL Explorer.
  6. Use query to fetch information about the rules for given Merge Request:
query {
  project(fullPath: "root/new-project") {
    id  
    mergeRequests {
        nodes {
          iid
          approvalState {
            approvalRulesOverwritten
            rules {
              approvalsRequired
              approved
              section
              approvedBy {
                nodes {
                  id
                  name
                }
              }
              containsHiddenGroups
              eligibleApprovers {
                nodes {
                  id
                }
              }
              groups {
                nodes {
                  id
                  name
                }
              }
            
              name
              id
              overridden
              sourceRule {
                id
                name
              }
              type
              users {
                nodes {
                  id
                  name
                }
              }
            }
          }
        }
      }
    }
  }

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • [-] 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

Related to #323116 (closed)

Edited by Alex Kalderimis

Merge request reports