Class: Mutations::Snippets::Update
- Inherits:
-
Base
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Base
- Mutations::Snippets::Update
- Defined in:
- app/graphql/mutations/snippets/update.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?, #find_object, #raise_resource_not_available_error!
Instance Method Details
#resolve(id:, **args) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/graphql/mutations/snippets/update.rb', line 32 def resolve(id:, **args) snippet = (id: id) process_args_for_params!(args) service = ::Snippets::UpdateService.new( project: snippet.project, current_user: current_user, params: args, perform_spam_check: true ) service_response = service.execute(snippet) # TODO: DRY this up - From here down, this is all duplicated with Mutations::Snippets::Create#resolve, except # for `snippet.reset`, which is required in order to return the object in its non-dirty, unmodified, database # state. # See issue here: https://gitlab.com/gitlab-org/gitlab/-/issues/300250. # 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: snippet.project ) end snippet = service_response.payload[:snippet] check_spam_action_response!(snippet) { snippet: service_response.success? ? snippet : snippet.reset, errors: errors_on_object(snippet) } end |