35 lines
708 B
Ruby
35 lines
708 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Types
|
|
class BaseObject < GraphQL::Schema::Object
|
|
prepend Gitlab::Graphql::Present
|
|
prepend Gitlab::Graphql::ExposePermissions
|
|
prepend Gitlab::Graphql::MarkdownField
|
|
|
|
field_class Types::BaseField
|
|
|
|
def self.accepts(*types)
|
|
@accepts ||= []
|
|
@accepts += types
|
|
@accepts
|
|
end
|
|
|
|
# All graphql fields exposing an id, should expose a global id.
|
|
def id
|
|
GitlabSchema.id_from_object(object)
|
|
end
|
|
|
|
def current_user
|
|
context[:current_user]
|
|
end
|
|
|
|
def self.assignable?(object)
|
|
assignable = accepts
|
|
|
|
return true if assignable.blank?
|
|
|
|
assignable.any? { |cls| object.is_a?(cls) }
|
|
end
|
|
end
|
|
end
|