You need to sign in or sign up before continuing.
Presenting abilities permitted to a user on a resource in GraphQL
To present what actions are allowed to a resource I would like to open up the Ability.allowed?
interface that we use internally.
We could do this by adding a field allowed
, with type Boolean to each permittable-type. The field takes the ability to check as an argument in the form of a GraphQL-enum.
The query could then look roughly like this:
project(fullPath: "gitlab-org/gitlab-ce") {
canCreateIssue: allowed(ability: CREATE_ISSUE)
canCreateMergeRequest: allowed(ability: CREATE_MERGE_REQUEST)
}
I think we would be able to generate the ENUM of abilities on the fly. This means that the clients would be able to name the field theirselves. And we don't need to add a field when new abilities get introduced.