Class: Mutations::Boards::Issues::IssueMoveList

Inherits:
Issues::Base show all
Defined in:
app/graphql/mutations/boards/issues/issue_move_list.rb

Constant Summary collapse

BoardGID =
::Types::GlobalIDType[::Board]
ListID =
::GraphQL::Types::ID
IssueID =
::GraphQL::Types::ID

Constants inherited from Mutations::BaseMutation

Mutations::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 ResolvesIssuable

#resolve_issuable

Methods inherited from Mutations::BaseMutation

#api_user?, authorization, 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?, #find_object, #raise_resource_not_available_error!

Instance Method Details

#ready?(**args) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/graphql/mutations/boards/issues/issue_move_list.rb', line 46

def ready?(**args)
  if move_arguments(args).blank?
    raise Gitlab::Graphql::Errors::ArgumentError,
          'At least one of the arguments ' \
          'fromListId, toListId, positionInList, moveAfterId, or moveBeforeId is required'
  end

  if move_list_arguments(args).one?
    raise Gitlab::Graphql::Errors::ArgumentError,
          'Both fromListId and toListId must be present'
  end

  if args[:position_in_list].present?
    if move_list_arguments(args).empty?
      raise Gitlab::Graphql::Errors::ArgumentError,
            'Both fromListId and toListId are required when positionInList is given'
    end

    if args[:move_before_id].present? || args[:move_after_id].present?
      raise Gitlab::Graphql::Errors::ArgumentError,
            'positionInList is mutually exclusive with any of moveBeforeId or moveAfterId'
    end

    if args[:position_in_list] != ::Boards::Issues::MoveService::LIST_END_POSITION &&
        args[:position_in_list] < 0
      raise Gitlab::Graphql::Errors::ArgumentError,
            "positionInList must be >= 0 or #{::Boards::Issues::MoveService::LIST_END_POSITION}"
    end
  end

  super
end

#resolve(board:, project_path:, iid:, **args) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
# File 'app/graphql/mutations/boards/issues/issue_move_list.rb', line 79

def resolve(board:, project_path:, iid:, **args)
  issue = authorized_find!(project_path: project_path, iid: iid)
  move_params = { id: issue.id, board_id: board.id }.merge(move_arguments(args))

  result = move_issue(board, issue, move_params)

  {
    issue: issue.reset,
    errors: error_for(result)
  }
end