gitlab-org--gitlab-foss/lib/gitlab/graphql/expose_permissions.rb
Bob Van Landuyt 54b56f20b7 Expose permissions on types in GraphQL
This adds a reusable way to expose permissions for a user to types in
GraphQL.
2018-06-28 13:50:17 +02:00

15 lines
444 B
Ruby

module Gitlab
module Graphql
module ExposePermissions
extend ActiveSupport::Concern
prepended do
def self.expose_permissions(permission_type, description: 'Permissions for the current user on the resource')
field :user_permissions, permission_type,
description: description,
null: false,
resolve: -> (obj, _, _) { obj }
end
end
end
end
end