debian-mirror-gitlab/app/graphql/mutations/merge_requests/update.rb

45 lines
1.3 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
module Mutations
module MergeRequests
class Update < Base
graphql_name 'MergeRequestUpdate'
description 'Update attributes of a merge request'
argument :title, GraphQL::STRING_TYPE,
required: false,
description: copy_field_description(Types::MergeRequestType, :title)
argument :target_branch, GraphQL::STRING_TYPE,
required: false,
description: copy_field_description(Types::MergeRequestType, :target_branch)
argument :description, GraphQL::STRING_TYPE,
required: false,
description: copy_field_description(Types::MergeRequestType, :description)
2021-03-11 19:13:27 +05:30
argument :state, ::Types::MergeRequestStateEventEnum,
required: false,
as: :state_event,
description: 'The action to perform to change the state.'
def resolve(project_path:, iid:, **args)
merge_request = authorized_find!(project_path: project_path, iid: iid)
attributes = args.compact
2020-07-28 23:09:34 +05:30
::MergeRequests::UpdateService
.new(merge_request.project, current_user, attributes)
.execute(merge_request)
errors = errors_on_object(merge_request)
{
merge_request: merge_request.reset,
errors: errors
}
end
end
end
end