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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
921 B
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
module Mutations
module MergeRequests
class SetDraft < Base
graphql_name 'MergeRequestSetDraft'
argument :draft,
2021-10-27 15:23:28 +05:30
GraphQL::Types::Boolean,
2021-06-08 01:23:25 +05:30
required: true,
description: <<~DESC
Whether or not to set the merge request as a draft.
DESC
def resolve(project_path:, iid:, draft: nil)
merge_request = authorized_find!(project_path: project_path, iid: iid)
project = merge_request.project
::MergeRequests::UpdateService.new(project: project, current_user: current_user, params: { wip_event: wip_event(draft) })
.execute(merge_request)
{
merge_request: merge_request,
errors: errors_on_object(merge_request)
}
end
private
2022-07-23 23:45:48 +05:30
def wip_event(draft)
draft ? 'draft' : 'ready'
2021-06-08 01:23:25 +05:30
end
end
end
end