summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/ci/pipeline/cancel.rb
blob: 3fb34a37cfcd94306f2e266b34e2e13a29463330 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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