Skip to content

Change type of ApprovalState.eligibleApprovers in GraphQL API

What does this MR do?

While I was testing how previous MR (!68502 (merged)) is working on staging, I've noticed that there is an error (ActiveRecord::ImmutableRelation) while querying for eligibleApprovers -> https://sentry.gitlab.net/gitlab/staginggitlabcom/issues/2768106/?query=is%3Aunresolved%20Immutable

I've noticed that method that is executed when querying for that field (ApprovalMergeRequestRule#approvers) is returning either scope or an array (https://gitlab.com/gitlab-org/gitlab/blob/master/ee/app/models/approval_merge_request_rule.rb#L106). While I was testing this locally I've not encountered that error. This MR fixes that by changing the type of the field from connection_type to array.

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)

Merge request reports