2022-10-11 01:57:18 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module Ci
|
|
|
|
module JobArtifact
|
|
|
|
class Destroy < BaseMutation
|
|
|
|
graphql_name 'ArtifactDestroy'
|
|
|
|
|
|
|
|
authorize :destroy_artifacts
|
|
|
|
|
|
|
|
ArtifactID = ::Types::GlobalIDType[::Ci::JobArtifact]
|
|
|
|
|
|
|
|
argument :id,
|
|
|
|
ArtifactID,
|
|
|
|
required: true,
|
|
|
|
description: 'ID of the artifact to delete.'
|
|
|
|
|
|
|
|
field :artifact,
|
|
|
|
Types::Ci::JobArtifactType,
|
|
|
|
null: true,
|
|
|
|
description: 'Deleted artifact.'
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
def find_object(id:)
|
2022-10-11 01:57:18 +05:30
|
|
|
GlobalID::Locator.locate(id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve(id:)
|
|
|
|
artifact = authorized_find!(id: id)
|
|
|
|
|
|
|
|
if artifact.destroy
|
|
|
|
{ errors: [] }
|
|
|
|
else
|
|
|
|
{ errors: artifact.errors.full_messages }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|