delete.rb 625 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class Ticket::Article::Delete < BaseMutation
  4. description 'Deletes ticket article if eligible'
  5. argument :article_id, GraphQL::Types::ID, loads: Gql::Types::Ticket::ArticleType, description: 'The article to be updated'
  6. field :success, Boolean, null: false, description: 'Was the ticket article deletion successful?'
  7. def resolve(article:)
  8. article.destroy!
  9. { success: true }
  10. end
  11. def authorized?(article:)
  12. Pundit.authorize(context.current_user, article, :destroy?)
  13. end
  14. end
  15. end