Commit 36d7c7ca authored by Fabio Pitino's avatar Fabio Pitino

Merge branch 'ab-namespace-pipeline-gql' into 'master'

Namespace CI Pipeline Mutations

See merge request gitlab-org/gitlab!50292
parents 8467c199 f47c6b6d
# frozen_string_literal: true
module Mutations
module Ci
class Base < BaseMutation
PipelineID = ::Types::GlobalIDType[::Ci::Pipeline]
argument :id, PipelineID,
required: true,
description: 'The ID of the pipeline to mutate'
private
def find_object(id:)
# TODO: remove this line when the compatibility layer is removed
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
id = PipelineID.coerce_isolated_input(id)
GlobalID::Locator.locate(id)
end
end
end
end
# frozen_string_literal: true
module Mutations
module Ci
module Pipeline
class Base < BaseMutation
PipelineID = ::Types::GlobalIDType[::Ci::Pipeline]
argument :id, PipelineID,
required: true,
description: 'The ID of the pipeline to mutate.'
private
def find_object(id:)
# TODO: remove this line when the compatibility layer is removed
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
id = PipelineID.coerce_isolated_input(id)
GlobalID::Locator.locate(id)
end
end
end
end
end
# frozen_string_literal: true
module Mutations
module Ci
module Pipeline
class Cancel < Base
graphql_name 'PipelineCancel'
authorize :update_pipeline
def resolve(id:)
pipeline = authorized_find!(id: id)
if pipeline.cancelable?
pipeline.cancel_running
{ success: true, errors: [] }
else
{ success: false, errors: ['Pipeline is not cancelable'] }
end
end
end
end
end
end
# frozen_string_literal: true
module Mutations
module Ci
module Pipeline
class Destroy < Base
graphql_name 'PipelineDestroy'
authorize :destroy_pipeline
def resolve(id:)
pipeline = authorized_find!(id: id)
project = pipeline.project
result = ::Ci::DestroyPipelineService.new(project, current_user).execute(pipeline)
{
success: result.success?,
errors: result.errors
}
end
end
end
end
end
# frozen_string_literal: true
module Mutations
module Ci
module Pipeline
class Retry < Base
graphql_name 'PipelineRetry'
field :pipeline,
Types::Ci::PipelineType,
null: true,
description: 'The pipeline after mutation.'
authorize :update_pipeline
def resolve(id:)
pipeline = authorized_find!(id: id)
project = pipeline.project
::Ci::RetryPipelineService.new(project, current_user).execute(pipeline)
{
pipeline: pipeline,
errors: errors_on_object(pipeline)
}
end
end
end
end
end
# frozen_string_literal: true
module Mutations
module Ci
class PipelineCancel < Base
graphql_name 'PipelineCancel'
authorize :update_pipeline
def resolve(id:)
pipeline = authorized_find!(id: id)
if pipeline.cancelable?
pipeline.cancel_running
{ success: true, errors: [] }
else
{ success: false, errors: ['Pipeline is not cancelable'] }
end
end
end
end
end
# frozen_string_literal: true
module Mutations
module Ci
class PipelineDestroy < Base
graphql_name 'PipelineDestroy'
authorize :destroy_pipeline
def resolve(id:)
pipeline = authorized_find!(id: id)
project = pipeline.project
result = ::Ci::DestroyPipelineService.new(project, current_user).execute(pipeline)
{
success: result.success?,
errors: result.errors
}
end
end
end
end
# frozen_string_literal: true
module Mutations
module Ci
class PipelineRetry < Base
graphql_name 'PipelineRetry'
field :pipeline,
Types::Ci::PipelineType,
null: true,
description: 'The pipeline after mutation'
authorize :update_pipeline
def resolve(id:)
pipeline = authorized_find!(id: id)
project = pipeline.project
::Ci::RetryPipelineService.new(project, current_user).execute(pipeline)
{
pipeline: pipeline,
errors: errors_on_object(pipeline)
}
end
end
end
end
......@@ -88,9 +88,9 @@ module Types
mount_mutation Mutations::ContainerExpirationPolicies::Update
mount_mutation Mutations::ContainerRepositories::Destroy
mount_mutation Mutations::ContainerRepositories::DestroyTags
mount_mutation Mutations::Ci::PipelineCancel
mount_mutation Mutations::Ci::PipelineDestroy
mount_mutation Mutations::Ci::PipelineRetry
mount_mutation Mutations::Ci::Pipeline::Cancel
mount_mutation Mutations::Ci::Pipeline::Destroy
mount_mutation Mutations::Ci::Pipeline::Retry
end
end
......
......@@ -16732,7 +16732,7 @@ input PipelineCancelInput {
clientMutationId: String
"""
The ID of the pipeline to mutate
The ID of the pipeline to mutate.
"""
id: CiPipelineID!
}
......@@ -16798,7 +16798,7 @@ input PipelineDestroyInput {
clientMutationId: String
"""
The ID of the pipeline to mutate
The ID of the pipeline to mutate.
"""
id: CiPipelineID!
}
......@@ -16860,7 +16860,7 @@ input PipelineRetryInput {
clientMutationId: String
"""
The ID of the pipeline to mutate
The ID of the pipeline to mutate.
"""
id: CiPipelineID!
}
......@@ -16880,7 +16880,7 @@ type PipelineRetryPayload {
errors: [String!]!
"""
The pipeline after mutation
The pipeline after mutation.
"""
pipeline: Pipeline
}
......
......@@ -49465,7 +49465,7 @@
"inputFields": [
{
"name": "id",
"description": "The ID of the pipeline to mutate",
"description": "The ID of the pipeline to mutate.",
"type": {
"kind": "NON_NULL",
"name": null,
......@@ -49697,7 +49697,7 @@
"inputFields": [
{
"name": "id",
"description": "The ID of the pipeline to mutate",
"description": "The ID of the pipeline to mutate.",
"type": {
"kind": "NON_NULL",
"name": null,
......@@ -49897,7 +49897,7 @@
"inputFields": [
{
"name": "id",
"description": "The ID of the pipeline to mutate",
"description": "The ID of the pipeline to mutate.",
"type": {
"kind": "NON_NULL",
"name": null,
......@@ -49971,7 +49971,7 @@
},
{
"name": "pipeline",
"description": "The pipeline after mutation",
"description": "The pipeline after mutation.",
"args": [
],
......@@ -2565,7 +2565,7 @@ Autogenerated return type of PipelineRetry.
| ----- | ---- | ----------- |
| `clientMutationId` | String | A unique identifier for the client performing the mutation. |
| `errors` | String! => Array | Errors encountered during execution of the mutation. |
| `pipeline` | Pipeline | The pipeline after mutation |
| `pipeline` | Pipeline | The pipeline after mutation. |
### Project
......
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