Class: Mutations::Ci::JobTokenScope::AddProject
- Inherits:
-
BaseMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Mutations::Ci::JobTokenScope::AddProject
- Includes:
- FindsProject
- Defined in:
- app/graphql/mutations/ci/job_token_scope/add_project.rb
Constant Summary
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 inherited from BaseMutation
#api_user?, authorization, 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(project_path:, target_project_path:, direction: nil) ⇒ Object
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 |
# File 'app/graphql/mutations/ci/job_token_scope/add_project.rb', line 35 def resolve(project_path:, target_project_path:, direction: nil) project = (project_path) target_project = Project.find_by_full_path(target_project_path) if direction == :outbound raise Gitlab::Graphql::Errors::ArgumentError, 'direction: OUTBOUND scope entries can only be removed. ' \ 'Only INBOUND scope can be expanded.' end direction ||= :inbound result = ::Ci::JobTokenScope::AddProjectService .new(project, current_user) .execute(target_project, direction: direction) if result.success? { ci_job_token_scope: ::Ci::JobToken::Scope.new(project), errors: [] } else { ci_job_token_scope: nil, errors: [result.] } end end |