Class: Mutations::Labels::Create

Inherits:
BaseMutation
  • Object
show all
Includes:
ResolvesResourceParent
Defined in:
app/graphql/mutations/labels/create.rb

Constant Summary

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Instance Method Summary collapse

Methods included from ResolvesResourceParent

#ready?

Methods included from ResolvesProject

#resolve_project

Methods included from ResolvesGroup

#group_resolver, #resolve_group

Methods inherited from BaseMutation

#api_user?, authorization, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #read_only?, #ready?, #unauthorized_object

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!

Instance Method Details

#resolve(args) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'app/graphql/mutations/labels/create.rb', line 37

def resolve(args)
  parent = authorized_resource_parent_find!(args)
  parent_key = parent.is_a?(Project) ? :project : :group

  label = ::Labels::CreateService.new(args).execute(parent_key => parent)

  {
    label: label.persisted? ? label : nil,
    errors: errors_on_object(label)
  }
end