tickets_by_overview.rb 996 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Queries
  3. class TicketsByOverview < BaseQuery
  4. description 'Fetch tickets of a given ticket overview'
  5. argument :overview_id, GraphQL::Types::ID, description: 'Overview ID'
  6. argument :order_by, String, required: false, description: 'Set a custom order by'
  7. argument :order_direction, Gql::Types::Enum::OrderDirectionType, required: false, description: 'Set a custom order direction'
  8. type Gql::Types::TicketType.connection_type, null: false
  9. def resolve(overview_id: nil, order_by: nil, order_direction: nil)
  10. overview = Gql::ZammadSchema.authorized_object_from_id(overview_id, type: ::Overview, user: context.current_user)
  11. # This will fetch tickets with 'overview' permissions, which logically include 'read' permissions.
  12. ::Ticket::Overviews.tickets_for_overview(overview, context.current_user, order_by: order_by, order_direction: order_direction)
  13. end
  14. end
  15. end