Commit 0f48633f authored by lauraMon's avatar lauraMon

Improves DestroyPipelineService and mutatio

* Adds error messaging to Service
* Updates DestroyPipeline mutatio to return success and errors
* Moves pipeline field to PipelineRetry resolver
parent 838bd54a
......@@ -6,12 +6,6 @@ module Mutations
argument :id, GraphQL::ID_TYPE,
required: true,
description: 'The id of the pipeline to mutate'
field :pipeline,
Types::Ci::PipelineType,
null: true,
description: 'The pipeline after mutation'
private
def find_object(id:)
......
......@@ -11,10 +11,10 @@ module Mutations
pipeline = authorized_find!(id: id)
project = pipeline.project
::Ci::DestroyPipelineService.new(project, current_user).execute(pipeline)
rescue ActiveRecord::RecordNotFound
result = ::Ci::DestroyPipelineService.new(project, current_user).execute(pipeline)
{
errors: ['Pipeline not found']
success: result.success?,
errors: result.errors
}
end
end
......
......@@ -5,6 +5,11 @@ module Mutations
class PipelineRetry < Base
graphql_name 'PipelineRetry'
field :pipeline,
Types::Ci::PipelineType,
null: true,
description: 'The pipeline after mutation'
authorize :update_pipeline
def resolve(id:)
......
......@@ -8,6 +8,11 @@ module Ci
Ci::ExpirePipelineCacheService.new.execute(pipeline, delete: true)
pipeline.destroy!
ServiceResponse.success(message: 'Pipeline not found')
rescue ActiveRecord::RecordNotFound
ServiceResponse.error(message: 'Pipeline not found')
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