-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(be): add problemTag and problemTestcase to Admin Problem GET API (#…
…1397) * feat: add field resolvers - problem -> problemTag - problem -> problemTestcase - problemTag -> tag * test: add test cases * test: add seed data isVisible이 false인 problem 데이터 2개 * refactor: add PR review comments * docs: add selection set for getProblems query Co-authored-by: Jaehyeon1020 <[email protected]>
- Loading branch information
1 parent
6d73c0e
commit faee9a2
Showing
7 changed files
with
220 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { InternalServerErrorException, Logger } from '@nestjs/common' | ||
import { Query, Resolver, ResolveField, Parent } from '@nestjs/graphql' | ||
import { ProblemTag, Tag } from '@generated' | ||
import { ProblemService } from './problem.service' | ||
|
||
@Resolver(() => ProblemTag) | ||
export class ProblemTagResolver { | ||
private readonly logger = new Logger(ProblemTagResolver.name) | ||
|
||
constructor(private readonly problemService: ProblemService) {} | ||
|
||
@ResolveField('tag', () => Tag) | ||
async getTag(@Parent() problemTag: ProblemTag) { | ||
try { | ||
return await this.problemService.getTag(problemTag.tagId) | ||
} catch (error) { | ||
this.logger.error(error) | ||
throw new InternalServerErrorException() | ||
} | ||
} | ||
} | ||
|
||
@Resolver(() => Tag) | ||
export class TagResolver { | ||
private readonly logger = new Logger(TagResolver.name) | ||
|
||
constructor(private readonly problemService: ProblemService) {} | ||
|
||
@Query(() => [Tag]) | ||
async getTags() { | ||
try { | ||
return await this.problemService.getTags() | ||
} catch (error) { | ||
this.logger.error(error) | ||
throw new InternalServerErrorException() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { Module } from '@nestjs/common' | ||
import { StorageModule } from '@admin/storage/storage.module' | ||
import { ProblemTagResolver, TagResolver } from './problem-tag.resolver' | ||
import { ProblemResolver } from './problem.resolver' | ||
import { ProblemService } from './problem.service' | ||
|
||
@Module({ | ||
imports: [StorageModule], | ||
providers: [ProblemResolver, ProblemService] | ||
providers: [ProblemResolver, ProblemTagResolver, TagResolver, ProblemService] | ||
}) | ||
export class ProblemModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters