Welcome to mirror list, hosted at ThFree Co, Russian Federation.

play.rb « pipeline_schedule « ci « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 056890852c9df4d22495e0bbceeca13ed2552748 (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
25
26
27
28
29
30
31
32
# frozen_string_literal: true

module Mutations
  module Ci
    module PipelineSchedule
      class Play < Base
        graphql_name 'PipelineSchedulePlay'

        authorize :play_pipeline_schedule

        field :pipeline_schedule,
              Types::Ci::PipelineScheduleType,
              null: true,
              description: 'Pipeline schedule after mutation.'

        def resolve(id:)
          schedule = authorized_find!(id: id)

          job_id = ::Ci::PipelineScheduleService
            .new(schedule.project, current_user)
            .execute(schedule)

          if job_id
            { pipeline_schedule: schedule, errors: [] }
          else
            { pipeline_schedule: nil, errors: ['Unable to schedule a pipeline to run immediately.'] }
          end
        end
      end
    end
  end
end