Skip to content

Commit

Permalink
n71: fix: Increase relations depth for typeorm queries
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandr-kiliushin committed Oct 18, 2022
1 parent 6a759dc commit bfd8e38
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/helpers/authorization.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export class AuthorizationGuard implements CanActivate {
if (decodingResult === null) throw new Error()
gqlExecutionContext.authorizedUser = await this.usersService.find({
userId: decodingResult.id,
relations: { administratedBoards: true, boards: true },
relations: {
administratedBoards: { admins: true, members: true, subject: true },
boards: { admins: true, members: true, subject: true },
},
})
} catch {
throw new UnauthorizedException("Invalid token.")
Expand Down
5 changes: 4 additions & 1 deletion src/models/budget-categories/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export class BudgetCategoriesService {
categoryId: BudgetCategoryEntity["id"]
}): Promise<BudgetCategoryEntity> {
const category = await this.budgetCategoriesRepository.findOne({
relations: { board: { admins: true, members: true, subject: true }, type: true },
relations: {
board: { admins: true, members: true, subject: true },
type: true,
},
where: { id: categoryId },
})
if (category === null) throw new NotFoundException({ message: "Not found." })
Expand Down
7 changes: 6 additions & 1 deletion src/models/budget-records/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ export class BudgetRecordsService {
id: args.orderingById ?? "ASC",
date: args.orderingById ?? "ASC",
},
relations: { category: { board: true, type: true } },
relations: {
category: {
board: { admins: true, members: true, subject: true },
type: true,
},
},
skip: args.skip === undefined ? 0 : args.skip,
...(args.take !== undefined && { take: args.take }),
where: {
Expand Down

0 comments on commit bfd8e38

Please sign in to comment.