Skip to content

Commit

Permalink
Add all crags query.
Browse files Browse the repository at this point in the history
  • Loading branch information
salamca committed Dec 31, 2023
1 parent f5696c8 commit d9b2883
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/crags/resolvers/crags.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ export class CragsResolver {
});
}

@UseGuards(UserAuthGuard)
// TODO: add conditions for showing 'public' crags to everyone (in service)
@Query(() => [Crag])
async crags(): Promise<Crag[]> {
return this.cragsService.findAll();
}

/* MUTATIONS */

@UseGuards(UserAuthGuard)
Expand Down
8 changes: 7 additions & 1 deletion src/crags/services/crags.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export class CragsService {
return crags;
}

async findAll(): Promise<Crag[]> {
const qb = this.cragsRepository.createQueryBuilder('c');
const result = qb.getMany();
return result;
}

async processAllCrags() {
(
await this.cragsRepository.find({
Expand Down Expand Up @@ -257,7 +263,7 @@ export class CragsService {
routeTypeId: params.routeTypeId,
});
}

console.log(builder.getSql());
setBuilderCache(builder);

return builder;
Expand Down

0 comments on commit d9b2883

Please sign in to comment.