Class: Mutations::WorkItems::Update

Inherits:
BaseMutation
  • Object
show all
Includes:
SpamProtection, UpdateArguments, Widgetable
Defined in:
app/graphql/mutations/work_items/update.rb

Constant Summary

Constants included from SpamProtection

SpamProtection::NEEDS_CAPTCHA_RESPONSE_MESSAGE, SpamProtection::NeedsCaptchaResponseError, SpamProtection::SPAM_DISALLOWED_MESSAGE, SpamProtection::SpamActionError, SpamProtection::SpamDisallowedError

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Instance Method Summary collapse

Methods included from Widgetable

#extract_widget_params!

Methods included from Spam::Concerns::HasSpamActionResponseFields

#spam_action_response_fields

Methods inherited from BaseMutation

#api_user?, authorization, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #read_only?, #ready?, #unauthorized_object

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!

Instance Method Details

#resolve(id:, **attributes) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/graphql/mutations/work_items/update.rb', line 19

def resolve(id:, **attributes)
  Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/408575')

  work_item = authorized_find!(id: id)

  widget_params = extract_widget_params!(work_item.work_item_type, attributes)

  interpret_quick_actions!(work_item, current_user, widget_params, attributes)

  update_result = ::WorkItems::UpdateService.new(
    container: work_item.project,
    current_user: current_user,
    params: attributes,
    widget_params: widget_params,
    perform_spam_check: true
  ).execute(work_item)

  check_spam_action_response!(work_item)

  {
    work_item: (update_result[:work_item] if update_result[:status] == :success),
    errors: Array.wrap(update_result[:message])
  }
end