2021-04-29 21:17:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module ReleaseAssetLinks
|
|
|
|
class Delete < BaseMutation
|
|
|
|
graphql_name 'ReleaseAssetLinkDelete'
|
|
|
|
|
|
|
|
authorize :destroy_release
|
|
|
|
|
|
|
|
ReleaseAssetLinkID = ::Types::GlobalIDType[::Releases::Link]
|
|
|
|
|
|
|
|
argument :id, ReleaseAssetLinkID,
|
|
|
|
required: true,
|
|
|
|
description: 'ID of the release asset link to delete.'
|
|
|
|
|
|
|
|
field :link,
|
|
|
|
Types::ReleaseAssetLinkType,
|
|
|
|
null: true,
|
2021-10-27 15:23:28 +05:30
|
|
|
description: 'Deleted release asset link.'
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
def resolve(id:)
|
|
|
|
link = authorized_find!(id)
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
result = ::Releases::Links::DestroyService
|
|
|
|
.new(link.release, current_user)
|
|
|
|
.execute(link)
|
|
|
|
|
|
|
|
if result.success?
|
|
|
|
{ link: result.payload[:link], errors: [] }
|
|
|
|
else
|
|
|
|
{ link: nil, errors: result.message }
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_object(id)
|
|
|
|
GitlabSchema.find_by_gid(id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|