diff --git a/app/src/follow/follow.service.ts b/app/src/follow/follow.service.ts index 098c0491..1a63c220 100644 --- a/app/src/follow/follow.service.ts +++ b/app/src/follow/follow.service.ts @@ -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); diff --git a/app/src/follow/model/follow.model.ts b/app/src/follow/model/follow.model.ts index 928f7bc4..8eb28961 100644 --- a/app/src/follow/model/follow.model.ts +++ b/app/src/follow/model/follow.model.ts @@ -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; diff --git a/app/src/schema.gql b/app/src/schema.gql index 41945f97..a8938161 100644 --- a/app/src/schema.gql +++ b/app/src/schema.gql @@ -60,7 +60,7 @@ type UserRankingIndexPaginated { } type FollowList { - isFollowing: Boolean! + isFollowing: Boolean user: UserPreview! }