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