import { Args, Int, Parent, Query, ResolveField, Resolver, } from '@nestjs/graphql'; import { TicketObjectType } from '../app-ticket-system/ticket.object-type'; import { AccountingFilterArgs } from './accounting-arg.types'; import { AccountingState } from './accounting-state'; import { AccountingValidationService } from './accounting-validation.service'; import { PaginatedTourObjectType, TourCostBreakdownObjectType, TourStateMetaObjectType, } from './accounting.object-type'; import { TourObjectType } from './tour.object-type'; @Resolver(() => TourObjectType) export class AccountingValidationResolver { constructor(private readonly service: AccountingValidationService) {} @Query(() => PaginatedTourObjectType) accountingTours( @Args('state', { type: () => AccountingState }) state: AccountingState, @Args('filters', { type: () => AccountingFilterArgs, nullable: true }) filters: AccountingFilterArgs, @Args('cursor', { nullable: true }) cursor: string, @Args('take', { type: () => Int, nullable: true }) take: number = 10, ) { return this.service.paginateToursByState(state, take, cursor); } @Query(() => TourStateMetaObjectType) accountingStateMeta( @Args('state', { type: () => AccountingState }) accountingState: AccountingState, ) { return this.service.getAccountingStateMeta(accountingState); } @Query(() => TourCostBreakdownObjectType) tourCostBreakdown(@Args('operationId') operationId: string) { return this.service.getTourCostBreakdown(operationId); } @ResolveField(() => TicketObjectType, { nullable: true }) ticket(@Parent() tour: TourObjectType) { return this.service.findTicketByTicketId(tour.ticketId); } }