Skip to content

Commit

Permalink
feat: ✨ 자신이 팔로우한 여부 확인 쿼리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
niamu01 committed Dec 29, 2023
1 parent 2b6dd7d commit a834d5a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/src/follow/follow.resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ export class FollowResolver {
return followResult;
}

@UseGuards(StatAuthGuard)
@Query((_returns) => Boolean, { nullable: true })
async getFollowStatus(
@MyUserId() userId: number,
@Args('target') target: string,
): Promise<boolean | undefined> {
return await this.followService.followStatus(userId, target);
}

@UseGuards(StatAuthGuard)
@Query((_returns) => FollowListWithCount)
async getFollowerList(
Expand Down
16 changes: 16 additions & 0 deletions app/src/follow/follow.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,22 @@ export class FollowService {
return await this.followModel.countDocuments({ userId, filter });
}

async followStatus(
userId: number,
target: string,
): Promise<boolean | undefined> {
const followId = await this.userIdByLogin(target);

let isFollowing: boolean | undefined = undefined;

await this.followModel.findOne({
userId,
followId,
});

return isFollowing;
}

async checkFollowingStatus(
userId: number,
userPreview: UserPreview[],
Expand Down
1 change: 1 addition & 0 deletions app/src/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ type Query {
getEvalLogs(after: String, first: Int! = 20, corrector: String, corrected: String, projectName: String, outstandingOnly: Boolean! = false, imperfectOnly: Boolean! = false, sortOrder: EvalLogSortOrder! = BEGIN_AT_DESC): EvalLogsPaginated!
getSetting: Setting!
getExpTable: [ExpTable!]!
getFollowStatus(target: String!): Boolean
getFollowerList(target: String!, limit: Int! = 3, sortOrder: FollowSortOrder!): FollowListWithCount!
getFollowerPaginated(after: String, first: Int! = 20, target: String!, sortOrder: FollowSortOrder! = FOLLOW_AT_DESC): FollowListPaginated!
getFollowingList(target: String!, limit: Int! = 3, sortOrder: FollowSortOrder!): FollowListWithCount!
Expand Down

0 comments on commit a834d5a

Please sign in to comment.