Class: Mutations::WorkItems::SavedViews::Create

Inherits:
BaseMutation
  • Object
show all
Includes:
FindsNamespace, SpamProtection
Defined in:
app/graphql/mutations/work_items/saved_views/create.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, authorization_scopes, 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(namespace_path:, **attrs) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/graphql/mutations/work_items/saved_views/create.rb', line 65

def resolve(namespace_path:, **attrs)
  container = authorized_find!(namespace_path)

  result = ::WorkItems::SavedViews::CreateService.new(
    current_user: current_user,
    container: container,
    params: attrs
  ).execute

  if result.success?
    check_spam_action_response!(result.payload[:saved_view])
    { saved_view: result.payload[:saved_view], errors: [] }
  else
    { saved_view: nil, errors: result.errors }
  end
end