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