remove.rb 959 B

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class Link::Remove < BaseMutation
  4. include Gql::Concerns::HandlesPossibleObjects
  5. description 'Remove link between objects'
  6. argument :input, Gql::Types::Input::LinkInputType, required: true, description: 'The link data'
  7. field :success, Boolean, description: 'Was the mutation successful?'
  8. possible_objects ::Ticket, ::KnowledgeBase::Answer::Translation
  9. def resolve(input:)
  10. source = fetch_object(input.source_id)
  11. target = fetch_object(input.target_id, permission: :update?)
  12. type = input.type
  13. ::Link.remove(
  14. link_type: type,
  15. link_object_source: source.class.name,
  16. link_object_source_value: source.id,
  17. link_object_target: target.class.name,
  18. link_object_target_value: target.id
  19. )
  20. {
  21. success: true
  22. }
  23. end
  24. end
  25. end