Skip to content

Commit

Permalink
refactor: ♻️ 리스트에 자신이 있는 경우 isFollowing을 null로 반환
Browse files Browse the repository at this point in the history
  • Loading branch information
niamu01 committed Feb 20, 2024
1 parent cd3d4fb commit 18749ea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions app/src/follow/follow.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,18 @@ export class FollowService {
throw new NotFoundException();
}

const isFollowed = await this.followModel.findOne({
userId: userId,
followId: user.id,
});
let isFollowing: boolean | undefined = undefined;

if (userId !== user.id) {
const isFollowed = await this.followModel.findOne({
userId: userId,
followId: user.id,
});

isFollowing = !!isFollowed;
}

return { isFollowing: !!isFollowed, user };
return { isFollowing, user };
});

return Promise.all(followList);
Expand Down
4 changes: 2 additions & 2 deletions app/src/follow/model/follow.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { UserPreview } from 'src/common/models/common.user.model';

@ObjectType()
export class FollowList {
@Field()
isFollowing: boolean;
@Field({ nullable: true })
isFollowing?: boolean;

@Field()
user: UserPreview;
Expand Down
2 changes: 1 addition & 1 deletion app/src/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type UserRankingIndexPaginated {
}

type FollowList {
isFollowing: Boolean!
isFollowing: Boolean
user: UserPreview!
}

Expand Down

0 comments on commit 18749ea

Please sign in to comment.