Class: Mutations::Snippets::Create
- Inherits:
-
BaseMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Mutations::Snippets::Create
- Defined in:
- app/graphql/mutations/snippets/create.rb
Constant Summary
Constants included from Mutations::SpamProtection
Mutations::SpamProtection::NEEDS_CAPTCHA_RESPONSE_MESSAGE, Mutations::SpamProtection::NeedsCaptchaResponseError, Mutations::SpamProtection::SPAM_DISALLOWED_MESSAGE, Mutations::SpamProtection::SpamActionError, Mutations::SpamProtection::SpamDisallowedError
Constants inherited from BaseMutation
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 Gitlab::InternalEventsTracking
Methods included from Spam::Concerns::HasSpamActionResponseFields
Methods included from ServiceCompatibility
#convert_blob_actions_to_snippet_actions!
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?, #raise_resource_not_available_error!
Instance Method Details
#resolve(project_path: nil, **args) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/graphql/mutations/snippets/create.rb', line 43 def resolve(project_path: nil, **args) if project_path.present? project = (project_path) else (:global) end process_args_for_params!(args) service = ::Snippets::CreateService.new(project: project, current_user: current_user, params: args) service_response = service.execute # Only when the user is not an api user and the operation was successful if !api_user? && service_response.success? track_internal_event( 'g_edit_by_snippet_ide', user: current_user, project: project ) end snippet = service_response.payload[:snippet] check_spam_action_response!(snippet) { snippet: service_response.success? ? snippet : nil, errors: errors_on_object(snippet) } end |