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

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

56 lines
1.6 KiB
Ruby
Raw Normal View History

2022-04-04 11:22:00 +05:30
# frozen_string_literal: true
module Mutations
module WorkItems
class Update < BaseMutation
graphql_name 'WorkItemUpdate'
description "Updates a work item by Global ID." \
2022-07-23 23:45:48 +05:30
" Available only when feature flag `work_items` is enabled."
2022-04-04 11:22:00 +05:30
include Mutations::SpamProtection
2022-07-23 23:45:48 +05:30
include Mutations::WorkItems::UpdateArguments
2022-08-13 15:12:31 +05:30
include Mutations::WorkItems::Widgetable
2022-04-04 11:22:00 +05:30
authorize :update_work_item
field :work_item, Types::WorkItemType,
null: true,
description: 'Updated work item.'
def resolve(id:, **attributes)
work_item = authorized_find!(id: id)
2022-06-21 17:19:12 +05:30
unless work_item.project.work_items_feature_flag_enabled?
2022-04-04 11:22:00 +05:30
return { errors: ['`work_items` feature flag disabled for this project'] }
end
spam_params = ::Spam::SpamParams.new_from_request(request: context[:request])
2022-08-13 15:12:31 +05:30
widget_params = extract_widget_params!(work_item.work_item_type, attributes)
2022-04-04 11:22:00 +05:30
2022-08-13 15:12:31 +05:30
update_result = ::WorkItems::UpdateService.new(
2022-04-04 11:22:00 +05:30
project: work_item.project,
current_user: current_user,
params: attributes,
2022-08-13 15:12:31 +05:30
widget_params: widget_params,
2022-04-04 11:22:00 +05:30
spam_params: spam_params
).execute(work_item)
check_spam_action_response!(work_item)
{
2022-08-13 15:12:31 +05:30
work_item: (update_result[:work_item] if update_result[:status] == :success),
errors: Array.wrap(update_result[:message])
2022-04-04 11:22:00 +05:30
}
end
private
def find_object(id:)
GitlabSchema.find_by_gid(id)
end
end
end
end
2022-08-27 11:52:29 +05:30
Mutations::WorkItems::Update.prepend_mod