Skip to content

GraphQL Type authorization

Luke Duncalfe requested to merge 54417-graphql-type-authorization into master

What does this MR do?

Enables authorizations to be defined on GraphQL Types.

A single permission:

module Types
  class ProjectType < BaseObject
    authorize :read_project
  end
end

A collection of permissions:

module Types
  class ProjectType < BaseObject
    authorize [:read_project, :another_permission]
  end
end

Type and Field authorizations together

Permissions are cumulative, so where permissions are defined in both the Type and the Field:

class UserType
  authorize :some_permission
end

class IssueType
  field :author, UserType, authorize: :another_permission
end

The currently authenticated user would need both permissions on the User.

Connection authorizations

Connection fields are checked by "digging" to find the type class of the "node" field in the expected location of edges->node.

What are the relevant issue numbers?

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

Does this MR meet the acceptance criteria?

Edited by Luke Duncalfe

Merge request reports