feat(core): billing history pagination (#4787)

This commit is contained in:
Cats Juice
2023-10-31 17:47:59 +08:00
committed by GitHub
parent 8ca53326a7
commit 93e286177f
7 changed files with 86 additions and 15 deletions

View File

@@ -8,10 +8,12 @@ import {
Args,
Field,
ID,
Int,
Mutation,
ObjectType,
Query,
registerEnumType,
ResolveField,
Resolver,
} from '@nestjs/graphql';
import type { User } from '@prisma/client';
@@ -156,6 +158,17 @@ export class UserResolver {
return user;
}
@Throttle({ default: { limit: 10, ttl: 60 } })
@ResolveField(() => Int, {
name: 'invoiceCount',
description: 'Get user invoice count',
})
async invoiceCount(@CurrentUser() user: UserType) {
return this.prisma.userInvoice.count({
where: { userId: user.id },
});
}
@Throttle({
default: {
limit: 10,

View File

@@ -23,6 +23,9 @@ type UserType {
"""User password has been set"""
hasPassword: Boolean
token: TokenType!
"""Get user invoice count"""
invoiceCount: Int!
subscription: UserSubscription
invoices(take: Int = 8, skip: Int): [UserInvoice!]!
}