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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
# frozen_string_literal: true
module Mutations
module Groups
class Update < Mutations::BaseMutation
graphql_name 'GroupUpdate'
include ::Gitlab::Allowable
include Mutations::ResolvesGroup
authorize :admin_group_or_admin_runner
field :group, Types::GroupType,
null: true,
description: 'Group after update.'
argument :full_path, GraphQL::Types::ID,
required: true,
description: 'Full path of the group that will be updated.'
argument :lock_math_rendering_limits_enabled, GraphQL::Types::Boolean,
required: false,
description: copy_field_description(Types::GroupType, :lock_math_rendering_limits_enabled)
argument :math_rendering_limits_enabled, GraphQL::Types::Boolean,
required: false,
description: copy_field_description(Types::GroupType, :math_rendering_limits_enabled)
argument :name, GraphQL::Types::String,
required: false,
description: copy_field_description(Types::GroupType, :name)
argument :path, GraphQL::Types::String,
required: false,
description: copy_field_description(Types::GroupType, :path)
argument :shared_runners_setting, Types::Namespace::SharedRunnersSettingEnum,
required: false,
description: copy_field_description(Types::GroupType, :shared_runners_setting)
argument :visibility, Types::VisibilityLevelsEnum,
required: false,
description: copy_field_description(Types::GroupType, :visibility)
def resolve(full_path:, **args)
group = authorized_find!(full_path: full_path)
unless ::Groups::UpdateService.new(group, current_user, authorized_args(group, args)).execute
return { group: nil, errors: group.errors.full_messages }
end
{ group: group, errors: [] }
end
private
def find_object(full_path:)
resolve_group(full_path: full_path)
end
def authorized_args(group, args)
return args if can?(current_user, :admin_group, group)
if can?(current_user, :admin_runner, group) && args.keys == [:shared_runners_setting]
return { shared_runners_setting: args[:shared_runners_setting] }
end
raise_resource_not_available_error!
end
end
end
end
Mutations::Groups::Update.prepend_mod_with('Mutations::Groups::Update')
|