import { UseGuards } from "@nestjs/common"; import { Resolver, Query, Args, Int } from "@nestjs/graphql"; import { GamificationService } from "./gamification.service.js"; import { GqlJwtGuard } from "../../common/guards/gql-jwt.guard.js"; import { CurrentUser } from "../../common/decorators/current-user.decorator.js"; import { CurrentTenant } from "../../common/decorators/current-tenant.decorator.js"; @Resolver() @UseGuards(GqlJwtGuard) export class GamificationResolver { constructor(private readonly gamificationService: GamificationService) {} @Query(() => Object) async userXP(@CurrentUser() user: { id: string }) { return this.gamificationService.getUserXP(user.id); } @Query(() => Object) async userLevel(@CurrentUser() user: { id: string }) { return this.gamificationService.getUserLevel(user.id); } @Query(() => [Object]) async badges(@CurrentUser() user: { id: string }) { return this.gamificationService.getBadges(user.id); } @Query(() => Object) async streak(@CurrentUser() user: { id: string }) { return this.gamificationService.checkStreak(user.id); } @Query(() => [Object]) async leaderboard( @CurrentTenant() tenantId: string, @Args("limit", { type: () => Int, nullable: true, defaultValue: 20 }) limit: number, ) { return this.gamificationService.getLeaderboard(tenantId, limit); } }