Commit c9c83537 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Use find_object instead of resolve_project in EE

Use `include FindsProject` instead of `resolve_project`
in GraphQL mutations
parent e4ab3eff
......@@ -4,7 +4,7 @@ module Mutations
module Clusters
module Agents
class Create < BaseMutation
include ResolvesProject
include FindsProject
authorize :create_cluster
......@@ -24,7 +24,7 @@ module Mutations
description: 'Cluster agent created after mutation.'
def resolve(project_path:, name:)
project = authorized_find!(full_path: project_path)
project = authorized_find!(project_path)
result = ::Clusters::Agents::CreateService.new(project, current_user).execute(name: name)
{
......@@ -32,12 +32,6 @@ module Mutations
errors: Array.wrap(result[:message])
}
end
private
def find_object(full_path:)
resolve_project(full_path: full_path)
end
end
end
end
......
......@@ -3,7 +3,7 @@
module Mutations
module DastScannerProfiles
class Update < BaseMutation
include ResolvesProject
include FindsProject
graphql_name 'DastScannerProfileUpdate'
......@@ -53,7 +53,7 @@ module Mutations
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
gid = ::Types::GlobalIDType[::DastScannerProfile].coerce_isolated_input(service_args[:id])
project = authorized_find!(full_path: full_path)
project = authorized_find!(full_path)
service = ::DastScannerProfiles::UpdateService.new(project, current_user)
result = service.execute(**service_args, id: gid.model_id)
......@@ -64,12 +64,6 @@ module Mutations
{ errors: result.errors }
end
end
private
def find_object(full_path:)
resolve_project(full_path: full_path)
end
end
end
end
......@@ -4,7 +4,7 @@ module Mutations
module IncidentManagement
module OncallSchedule
class Create < OncallScheduleBase
include ResolvesProject
include FindsProject
graphql_name 'OncallScheduleCreate'
......@@ -25,7 +25,7 @@ module Mutations
description: 'The timezone of the on-call schedule.'
def resolve(args)
project = authorized_find!(full_path: args[:project_path])
project = authorized_find!(args[:project_path])
response ::IncidentManagement::OncallSchedules::CreateService.new(
project,
......@@ -33,12 +33,6 @@ module Mutations
args.slice(:name, :description, :timezone)
).execute
end
private
def find_object(full_path:)
resolve_project(full_path: full_path)
end
end
end
end
......
......@@ -3,7 +3,7 @@
module Mutations
module Pipelines
class RunDastScan < BaseMutation
include ResolvesProject
include FindsProject
graphql_name 'RunDASTScan'
......@@ -30,7 +30,7 @@ module Mutations
authorize :create_on_demand_dast_scan
def resolve(project_path:, target_url:, branch:, scan_type:)
project = authorized_find!(full_path: project_path)
project = authorized_find!(project_path)
service = ::Ci::RunDastScanService.new(project, current_user)
result = service.execute(branch: branch, target_url: target_url)
......@@ -44,10 +44,6 @@ module Mutations
private
def find_object(full_path:)
resolve_project(full_path: full_path)
end
def success_response(project:, pipeline:)
pipeline_url = Rails.application.routes.url_helpers.project_pipeline_url(
project,
......
......@@ -4,7 +4,7 @@ module Mutations
module QualityManagement
module TestCases
class Create < BaseMutation
include ResolvesProject
include FindsProject
graphql_name 'CreateTestCase'
......@@ -33,7 +33,7 @@ module Mutations
def resolve(args)
project_path = args.delete(:project_path)
project = authorized_find!(full_path: project_path)
project = authorized_find!(project_path)
result = ::QualityManagement::TestCases::CreateService.new(
project,
......@@ -48,12 +48,6 @@ module Mutations
errors: Array.wrap(result.message)
}
end
private
def find_object(full_path:)
resolve_project(full_path: full_path)
end
end
end
end
......
......@@ -3,13 +3,15 @@
module Mutations
module RequirementsManagement
class CreateRequirement < BaseRequirement
include FindsProject
graphql_name 'CreateRequirement'
authorize :create_requirement
def resolve(args)
project_path = args.delete(:project_path)
project = authorized_find!(full_path: project_path)
project = authorized_find!(project_path)
requirement = ::RequirementsManagement::CreateRequirementService.new(
project,
......@@ -22,12 +24,6 @@ module Mutations
errors: errors_on_object(requirement)
}
end
private
def find_object(full_path:)
resolve_project(full_path: full_path)
end
end
end
end
......@@ -3,7 +3,7 @@
module Mutations
module RequirementsManagement
class ExportRequirements < BaseMutation
include ResolvesProject
include FindsProject
include CommonRequirementArguments
graphql_name 'ExportRequirements'
......@@ -16,19 +16,13 @@ module Mutations
def resolve(args)
project_path = args.delete(:project_path)
project = authorized_find!(full_path: project_path)
project = authorized_find!(project_path)
IssuableExportCsvWorker.perform_async(:requirement, current_user.id, project.id, args)
{
errors: []
}
end
private
def find_object(full_path:)
resolve_project(full_path: full_path)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment