debian-mirror-gitlab/app/graphql/mutations/boards/lists/update.rb

53 lines
1.4 KiB
Ruby
Raw Normal View History

2020-10-24 23:57:45 +05:30
# frozen_string_literal: true
module Mutations
module Boards
module Lists
class Update < BaseMutation
graphql_name 'UpdateBoardList'
2021-01-29 00:20:46 +05:30
argument :list_id, Types::GlobalIDType[List],
2020-10-24 23:57:45 +05:30
required: true,
loads: Types::BoardListType,
description: 'Global ID of the list.'
argument :position, GraphQL::INT_TYPE,
required: false,
2021-03-08 18:12:59 +05:30
description: 'Position of list within the board.'
2020-10-24 23:57:45 +05:30
argument :collapsed, GraphQL::BOOLEAN_TYPE,
required: false,
2021-03-08 18:12:59 +05:30
description: 'Indicates if list is collapsed for this user.'
2020-10-24 23:57:45 +05:30
field :list,
Types::BoardListType,
null: true,
2021-03-08 18:12:59 +05:30
description: 'Mutated list.'
2020-10-24 23:57:45 +05:30
def resolve(list: nil, **args)
raise_resource_not_available_error! unless can_read_list?(list)
update_result = update_list(list, args)
{
list: update_result[:list],
errors: list.errors.full_messages
}
end
private
def update_list(list, args)
service = ::Boards::Lists::UpdateService.new(list.board, current_user, args)
service.execute(list)
end
def can_read_list?(list)
return false unless list.present?
Ability.allowed?(current_user, :read_list, list.board)
end
end
end
end
end