debian-mirror-gitlab/app/graphql/mutations/ci/pipeline_schedule/play.rb
2023-03-04 22:38:38 +05:30

32 lines
820 B
Ruby

# 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