2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module MergeRequests
|
|
|
|
class SetWip < Base
|
|
|
|
graphql_name 'MergeRequestSetWip'
|
|
|
|
|
|
|
|
argument :wip,
|
2021-10-27 15:23:28 +05:30
|
|
|
GraphQL::Types::Boolean,
|
2018-11-18 11:00:15 +05:30
|
|
|
required: true,
|
|
|
|
description: <<~DESC
|
2021-04-17 20:07:23 +05:30
|
|
|
Whether or not to set the merge request as a draft.
|
2020-11-24 15:15:51 +05:30
|
|
|
DESC
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
def resolve(project_path:, iid:, wip: nil)
|
|
|
|
merge_request = authorized_find!(project_path: project_path, iid: iid)
|
|
|
|
project = merge_request.project
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
::MergeRequests::UpdateService.new(project: project, current_user: current_user, params: { wip_event: wip_event(merge_request, wip) })
|
2018-11-18 11:00:15 +05:30
|
|
|
.execute(merge_request)
|
|
|
|
|
|
|
|
{
|
|
|
|
merge_request: merge_request,
|
2020-06-23 00:09:42 +05:30
|
|
|
errors: errors_on_object(merge_request)
|
2018-11-18 11:00:15 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def wip_event(merge_request, wip)
|
|
|
|
wip ? 'wip' : 'unwip'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|