update refund ticket

This commit is contained in:
2024-11-26 21:02:14 +07:00
parent e63f900cf4
commit 12b1e8e764
4 changed files with 21 additions and 2 deletions

View File

@@ -43,6 +43,9 @@ export class OrderSchema extends PothosSchema {
schedule: t.relation('schedule', {
description: 'The schedule of the order.',
}),
disbursed: t.exposeBoolean('disbursed', {
description: 'Whether the order has been disbursed.',
}),
chatRoomId: t.exposeID('chatRoomId', {
description: 'The ID of the chat room.',
}),

View File

@@ -56,6 +56,22 @@ export class RefundTicketSchema extends PothosSchema {
@Pothos()
init(): void {
this.builder.queryFields((t) => ({
refundTicket: t.prismaField({
type: this.refundTicket(),
description: 'Retrieve a refund ticket by ID.',
args: {
id: t.arg({ type: 'String', required: true }),
},
resolve: async (query, _root, args, ctx, _info) => {
if (ctx.isSubscription) {
throw new Error('Subscription is not allowed')
}
if (ctx.http.me?.role !== Role.MODERATOR) {
throw new Error('Only moderators can retrieve refund tickets')
}
return await this.prisma.refundTicket.findUnique({ ...query, where: { id: args.id } })
},
}),
refundTickets: t.prismaField({
type: [this.refundTicket()],
description: 'Retrieve a list of refund tickets with optional filtering, ordering, and pagination.',

File diff suppressed because one or more lines are too long