Class: Mutations::Ci::ProjectCiCdSettingsUpdate

Inherits:
BaseMutation
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize, FindsProject
Defined in:
app/graphql/mutations/ci/project_ci_cd_settings_update.rb

Constant Summary

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 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(full_path:, **args) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'app/graphql/mutations/ci/project_ci_cd_settings_update.rb', line 63

def resolve(full_path:, **args)
  if args[:job_token_scope_enabled]
    raise Gitlab::Graphql::Errors::ArgumentError, 'job_token_scope_enabled can only be set to false'
  end

  project = authorized_find!(full_path)

  response = ::Projects::UpdateService.new(
    project,
    current_user,
    project_update_params(project, **args)
  ).execute

  settings = project.ci_cd_settings

  if response[:status] == :success
    {
      ci_cd_settings: settings,
      errors: errors_on_object(settings)
    }
  else
    {
      ci_cd_settings: settings,
      errors: [response[:message]]
    }
  end
end