debian-mirror-gitlab/app/graphql/mutations/packages/destroy_file.rb
2022-07-16 19:58:13 +02:00

32 lines
710 B
Ruby

# frozen_string_literal: true
module Mutations
module Packages
class DestroyFile < ::Mutations::BaseMutation
graphql_name 'DestroyPackageFile'
authorize :destroy_package
argument :id,
::Types::GlobalIDType[::Packages::PackageFile],
required: true,
description: 'ID of the Package file.'
def resolve(id:)
package_file = authorized_find!(id: id)
if package_file.update(status: :pending_destruction)
return { errors: [] }
end
{ errors: package_file.errors.full_messages }
end
private
def find_object(id:)
GitlabSchema.find_by_gid(id)
end
end
end
end