Skip to content

expose permissions on types

Bob Van Landuyt requested to merge bvl-graphql-permissions into master

What does this MR do?

This provides a reusable way to expose permissions for the current user to resources in GraphQL.

The permissions are exposed through a userPermission field, that has a certain type for a resource. The field contains a boolean field for each exposed permission.

A query could look like this:

{
  project(fullPath: "twitter/typeahead-js") {
    mergeRequest(iid: "1") {
      userPermissions {
        readMergeRequest
        adminMergeRequest
        pushToSourceBranch
        cherryPickOnCurrentMergeRequest
        revertOnCurrentMergeRequest
      }
    }
  }
}

With this kind of response:

{
  "data": {
    "project": {
      "mergeRequest": {
        "userPermissions": {
          "readMergeRequest": true,
          "adminMergeRequest": false,
          "pushToSourceBranch": false,
          "cherryPickOnCurrentMergeRequest": false,
          "revertOnCurrentMergeRequest": false
        }
      }
    }
  }
}

Are there points in the code the reviewer needs to double check?

Why was this MR needed?

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/47695

Edited by Bob Van Landuyt

Merge request reports