diff options
Diffstat (limited to 'app/graphql/mutations/packages/destroy_file.rb')
-rw-r--r-- | app/graphql/mutations/packages/destroy_file.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/app/graphql/mutations/packages/destroy_file.rb b/app/graphql/mutations/packages/destroy_file.rb new file mode 100644 index 00000000000..35a486666d5 --- /dev/null +++ b/app/graphql/mutations/packages/destroy_file.rb @@ -0,0 +1,35 @@ +# 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.destroy + return { errors: [] } + end + + { errors: package_file.errors.full_messages } + end + + private + + def find_object(id:) + # TODO: remove this line when the compatibility layer is removed + # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883 + id = ::Types::GlobalIDType[::Packages::PackageFile].coerce_isolated_input(id) + GitlabSchema.find_by_gid(id) + end + end + end +end |