feat: introducing get team info by id in admin module as a query (HBE-182) (#54)

* feat: introducing get team info by id in admin module as a query

* chore: adding resolve field for admin

* chore: remove nullable false

* refactor: rename getTeamInfo to teamInfo

* refactor: make myRole nullable
This commit is contained in:
Ankit Sridhar
2023-03-28 15:35:38 +05:30
committed by GitHub
parent 96a4125f15
commit 9d6a7f709c
3 changed files with 28 additions and 0 deletions

View File

@@ -102,6 +102,22 @@ export class AdminResolver {
const teams = await this.adminService.fetchAllTeams(args.cursor, args.take);
return teams;
}
@ResolveField(() => Team, {
description: 'Returns a team info by ID when requested by Admin',
})
async teamInfo(
@Parent() admin: Admin,
@Args({
name: 'teamID',
type: () => ID,
description: 'Team ID for which info to fetch',
})
teamID: string,
): Promise<Team> {
const team = await this.adminService.getTeamInfo(teamID);
if (E.isLeft(team)) throwErr(team.left);
return team.right;
}
@ResolveField(() => Number, {
description: 'Return count of all the members in a team',

View File

@@ -393,4 +393,15 @@ export class AdminService {
const teamRequestCount = this.teamRequestService.getTeamRequestsCount();
return teamRequestCount;
}
/**
* Get team info by ID
* @param teamID Team ID
* @returns an Either of `Team` or error
*/
async getTeamInfo(teamID: string) {
const team = await this.teamService.getTeamWithIDTE(teamID)();
if (E.isLeft(team)) return E.left(team.left);
return E.right(team.right);
}
}

View File

@@ -61,6 +61,7 @@ export class TeamResolver {
@ResolveField(() => TeamMemberRole, {
description: 'The role of the current user in the team',
nullable: true,
})
@UseGuards(GqlAuthGuard)
myRole(