Class: Mutations::WorkItems::Hierarchy::Reorder

Inherits:
BaseMutation
  • Object
show all
Defined in:
app/graphql/mutations/work_items/hierarchy/reorder.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 inherited from BaseMutation

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

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

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

Instance Method Details

#ready?(**args) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/graphql/mutations/work_items/hierarchy/reorder.rb', line 38

def ready?(**args)
  validate_position_args!(args)

  @work_item = authorized_find!(id: args.delete(:id))
  @adjacent_item = authorized_find!(id: args.delete(:adjacent_work_item_id)) if args[:adjacent_work_item_id]
  new_parent = authorized_find!(id: args.delete(:parent_id)) if args[:parent_id]
  @parent = new_parent || work_item.work_item_parent

  validate_parent!

  super
end

#resolve(**args) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/graphql/mutations/work_items/hierarchy/reorder.rb', line 51

def resolve(**args)
  arguments = {
    target_issuable: work_item,
    adjacent_work_item: adjacent_item,
    relative_position: args.delete(:relative_position)
  }

  service_response = ::WorkItems::ParentLinks::ReorderService.new(parent, current_user, arguments).execute

  {
    work_item: work_item,
    adjacent_work_item: adjacent_item,
    parent_work_item: parent,
    errors: service_response[:status] == :error ? Array.wrap(service_response[:message]) : []
  }
end