Skip to content

Add the `draft` argument to GraphQL MergeRequestsResolver

What does this MR do and why?

This also makes the MergeRequestsFinder more robust by converting the draft/wip params value to a boolean.

This is needed for gitlab-org/ruby/gems/gitlab-triage#253 (closed).

Screenshots or screen recordings

No draft param draft: true draft: false
Screen_Shot_2022-01-13_at_13.14.37 Screen_Shot_2022-01-13_at_13.11.30 Screen_Shot_2022-01-13_at_13.14.15

How to set up and validate locally

  1. Ensure a MR is in draft in the gitlab-org/gitlab-test project
  2. Visit http://gdk.test:3000/-/graphql-explorer (or your own local URL of the GraphQL explorer
  3. Try the following 3 queries and check the results:
  • No draft param => results should include draft & non-draft MRs:
{
  project(fullPath: "gitlab-org/gitlab-test") {
    id
    mergeRequests(state: opened) {
      pageInfo {
        hasNextPage
        endCursor
      }
      nodes {
        id
        iid
        title
        state
        webUrl
        targetBranch
        draft
      }
    }
  }
}
  • draft: true param => results should only include draft MRs:
{
  project(fullPath: "gitlab-org/gitlab-test") {
    id
    mergeRequests(draft: true, state: opened) {
      pageInfo {
        hasNextPage
        endCursor
      }
      nodes {
        id
        iid
        title
        state
        webUrl
        targetBranch
        draft
      }
    }
  }
}
  • draft: false param => results should include non-draft MRs:
{
  project(fullPath: "gitlab-org/gitlab-test") {
    id
    mergeRequests(draft: false, state: opened) {
      pageInfo {
        hasNextPage
        endCursor
      }
      nodes {
        id
        iid
        title
        state
        webUrl
        targetBranch
        draft
      }
    }
  }
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Rémy Coutable

Merge request reports