Class: Mutations::WorkItems::UpdateTask

Inherits:
BaseMutation
  • Object
show all
Includes:
SpamProtection
Defined in:
app/graphql/mutations/work_items/update_task.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 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?, #raise_resource_not_available_error!

Instance Method Details

#resolve(id:, task_data:) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/graphql/mutations/work_items/update_task.rb', line 27

def resolve(id:, task_data:)
  task_data_hash = task_data.to_h
  work_item = authorized_find!(id: id)
  task = authorized_find_task!(task_data_hash[:id])

  ::WorkItems::UpdateService.new(
    container: task.project,
    current_user: current_user,
    params: task_data_hash.except(:id),
    perform_spam_check: true
  ).execute(task)

  check_spam_action_response!(task)

  response = { errors: errors_on_object(task) }

  if task.valid?
    work_item.expire_etag_cache

    response.merge(work_item: work_item, task: task)
  else
    response
  end
end