debian-mirror-gitlab/app/graphql/mutations/packages/destroy_file.rb

33 lines
710 B
Ruby
Raw Normal View History

2021-10-27 15:23:28 +05:30
# 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)
2022-03-02 08:16:31 +05:30
if package_file.update(status: :pending_destruction)
2021-10-27 15:23:28 +05:30
return { errors: [] }
end
{ errors: package_file.errors.full_messages }
end
private
def find_object(id:)
GitlabSchema.find_by_gid(id)
end
end
end
end