Class: Mutations::WorkItems::CreateFromTask

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

Instance Method Details

#resolve(id:, work_item_data:) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/graphql/mutations/work_items/create_from_task.rb', line 30

def resolve(id:, work_item_data:)
  work_item = authorized_find!(id: id)

  result = ::WorkItems::CreateFromTaskService.new(
    work_item: work_item,
    current_user: current_user,
    work_item_params: work_item_data
  ).execute

  check_spam_action_response!(result[:work_item]) if result[:work_item]

  response = { errors: result.errors }
  response.merge!(work_item: work_item, new_work_item: result[:work_item]) if result.success?

  response
end