Commit f47c6b6d authored by Allison Browne's avatar Allison Browne

Namespace pipeline related CI GraphQL code

Mutations::Ci::PipelineRetry -> Mutations::Ci::Pipeline::Retry
Mutations::Ci::PipelineCancel -> Mutations::Ci::Pipeline::Cancel
Mutations::Ci::PipelineDestroy -> Mutations::Ci::Pipeline::Destroy
Mutations::Ci::Base -> Mutations::Ci::Pipeline::Base
parent f0a70e7e
# 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 ...@@ -88,9 +88,9 @@ module Types
mount_mutation Mutations::ContainerExpirationPolicies::Update mount_mutation Mutations::ContainerExpirationPolicies::Update
mount_mutation Mutations::ContainerRepositories::Destroy mount_mutation Mutations::ContainerRepositories::Destroy
mount_mutation Mutations::ContainerRepositories::DestroyTags mount_mutation Mutations::ContainerRepositories::DestroyTags
mount_mutation Mutations::Ci::PipelineCancel mount_mutation Mutations::Ci::Pipeline::Cancel
mount_mutation Mutations::Ci::PipelineDestroy mount_mutation Mutations::Ci::Pipeline::Destroy
mount_mutation Mutations::Ci::PipelineRetry mount_mutation Mutations::Ci::Pipeline::Retry
end end
end end
......
...@@ -15918,7 +15918,7 @@ input PipelineCancelInput { ...@@ -15918,7 +15918,7 @@ input PipelineCancelInput {
clientMutationId: String clientMutationId: String
""" """
The ID of the pipeline to mutate The ID of the pipeline to mutate.
""" """
id: CiPipelineID! id: CiPipelineID!
} }
...@@ -15984,7 +15984,7 @@ input PipelineDestroyInput { ...@@ -15984,7 +15984,7 @@ input PipelineDestroyInput {
clientMutationId: String clientMutationId: String
""" """
The ID of the pipeline to mutate The ID of the pipeline to mutate.
""" """
id: CiPipelineID! id: CiPipelineID!
} }
...@@ -16046,7 +16046,7 @@ input PipelineRetryInput { ...@@ -16046,7 +16046,7 @@ input PipelineRetryInput {
clientMutationId: String clientMutationId: String
""" """
The ID of the pipeline to mutate The ID of the pipeline to mutate.
""" """
id: CiPipelineID! id: CiPipelineID!
} }
...@@ -16066,7 +16066,7 @@ type PipelineRetryPayload { ...@@ -16066,7 +16066,7 @@ type PipelineRetryPayload {
errors: [String!]! errors: [String!]!
""" """
The pipeline after mutation The pipeline after mutation.
""" """
pipeline: Pipeline pipeline: Pipeline
} }
......
...@@ -47438,7 +47438,7 @@ ...@@ -47438,7 +47438,7 @@
"inputFields": [ "inputFields": [
{ {
"name": "id", "name": "id",
"description": "The ID of the pipeline to mutate", "description": "The ID of the pipeline to mutate.",
"type": { "type": {
"kind": "NON_NULL", "kind": "NON_NULL",
"name": null, "name": null,
...@@ -47670,7 +47670,7 @@ ...@@ -47670,7 +47670,7 @@
"inputFields": [ "inputFields": [
{ {
"name": "id", "name": "id",
"description": "The ID of the pipeline to mutate", "description": "The ID of the pipeline to mutate.",
"type": { "type": {
"kind": "NON_NULL", "kind": "NON_NULL",
"name": null, "name": null,
...@@ -47870,7 +47870,7 @@ ...@@ -47870,7 +47870,7 @@
"inputFields": [ "inputFields": [
{ {
"name": "id", "name": "id",
"description": "The ID of the pipeline to mutate", "description": "The ID of the pipeline to mutate.",
"type": { "type": {
"kind": "NON_NULL", "kind": "NON_NULL",
"name": null, "name": null,
...@@ -47944,7 +47944,7 @@ ...@@ -47944,7 +47944,7 @@
}, },
{ {
"name": "pipeline", "name": "pipeline",
"description": "The pipeline after mutation", "description": "The pipeline after mutation.",
"args": [ "args": [
], ],
...@@ -2515,7 +2515,7 @@ Autogenerated return type of PipelineRetry. ...@@ -2515,7 +2515,7 @@ Autogenerated return type of PipelineRetry.
| ----- | ---- | ----------- | | ----- | ---- | ----------- |
| `clientMutationId` | String | A unique identifier for the client performing the mutation. | | `clientMutationId` | String | A unique identifier for the client performing the mutation. |
| `errors` | String! => Array | Errors encountered during execution of 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 ### 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