update.rb 907 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class Ticket::Update < BaseMutation
  4. description 'Update a ticket.'
  5. argument :ticket_id, GraphQL::Types::ID, loads: Gql::Types::TicketType, description: 'The ticket to be updated'
  6. argument :input, Gql::Types::Input::Ticket::UpdateInputType, description: 'The ticket data'
  7. field :ticket, Gql::Types::TicketType, description: 'The updated ticket. If this is present but empty, the mutation was successful but the user has no rights to view the updated ticket.'
  8. def self.authorize(_obj, ctx)
  9. ctx.current_user.permissions?(['ticket.agent', 'ticket.customer'])
  10. end
  11. def resolve(ticket:, input:)
  12. {
  13. ticket: Service::Ticket::Update
  14. .new(current_user: context.current_user)
  15. .execute(ticket: ticket, ticket_data: input)
  16. }
  17. end
  18. end
  19. end