Class: Mutations::Ci::JobTokenScope::RemoveProject

Inherits:
BaseMutation
  • Object
show all
Includes:
FindsProject
Defined in:
app/graphql/mutations/ci/job_token_scope/remove_project.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, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #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(project_path:, target_project_path:) ⇒ Object


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/graphql/mutations/ci/job_token_scope/remove_project.rb', line 26

def resolve(project_path:, target_project_path:)
  project = authorized_find!(project_path)
  target_project = Project.find_by_full_path(target_project_path)

  result = ::Ci::JobTokenScope::RemoveProjectService
    .new(project, current_user)
    .execute(target_project)

  if result.success?
    {
      ci_job_token_scope: ::Ci::JobToken::Scope.new(project),
      errors: []
    }
  else
    {
      ci_job_token_scope: nil,
      errors: [result.message]
    }
  end
end