summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/ci/ci_cd_settings_update.rb
blob: 6b7750ee860c937a3a77a7bd08d10bd50439da37 (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
# frozen_string_literal: true

module Mutations
  module Ci
    class CiCdSettingsUpdate < BaseMutation
      include FindsProject

      graphql_name 'CiCdSettingsUpdate'

      authorize :admin_project

      argument :full_path, GraphQL::ID_TYPE,
        required: true,
        description: 'Full Path of the project the settings belong to.'

      argument :keep_latest_artifact, GraphQL::BOOLEAN_TYPE,
        required: false,
        description: 'Indicates if the latest artifact should be kept for this project.'

      def resolve(full_path:, **args)
        project = authorized_find!(full_path)
        settings = project.ci_cd_settings
        settings.update(args)

        { errors: errors_on_object(settings) }
      end
    end
  end
end