Add isFollowedByCurrentUser field and hasFollowing to feed query
All checks were successful
Tests / Tests (pull_request) Successful in 9s

Updated GraphQL operations to support efficient follow status checking:
- Added isFollowedByCurrentUser field to UserSocialsFields fragment
- Removed nested followers array from UserSocialsFields (over-fetching)
- Simplified followUser/unfollowUser mutations to return minimal data
- Added hasFollowing field to GetVideoFeed query for feed mode detection
- Updated getUserFollowingFollowers query to include isFollowedByCurrentUser

These changes enable the mobile app to:
- Display correct follow/unfollow button states without client-side lookups
- Differentiate between "Following" and "Popular" feed modes
- Reduce payload size by removing unnecessary nested data

Backend handles efficient resolution via request-scoped caching.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
dean
2025-11-09 23:44:39 -08:00
parent 83b7f0d0f6
commit e4223a1a17
4 changed files with 31 additions and 159 deletions

View File

@@ -3546,12 +3546,7 @@ export type GetFeedQuery = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
}>;
comments: Array<{
@@ -3563,12 +3558,7 @@ export type GetFeedQuery = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
replies: Array<{
__typename?: "CommentGQL";
@@ -3579,12 +3569,7 @@ export type GetFeedQuery = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
}>;
}>;
@@ -3602,12 +3587,7 @@ export type UserSocialsFieldsFragment = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
export type VideoCardFieldsFragment = {
@@ -3664,12 +3644,7 @@ export type VideoCardFieldsFragment = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
}>;
comments: Array<{
@@ -3681,12 +3656,7 @@ export type VideoCardFieldsFragment = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
replies: Array<{
__typename?: "CommentGQL";
@@ -3697,12 +3667,7 @@ export type VideoCardFieldsFragment = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
}>;
}>;
@@ -3721,6 +3686,7 @@ export type GetVideoFeedQuery = {
__typename?: "Query";
getFeedVideos: {
__typename?: "VideoHistoryGQL";
hasFollowing: boolean;
videos: Array<{
__typename?: "VideoGQL";
id: number;
@@ -3778,12 +3744,7 @@ export type GetVideoFeedQuery = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
}>;
comments: Array<{
@@ -3795,12 +3756,7 @@ export type GetVideoFeedQuery = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
replies: Array<{
__typename?: "CommentGQL";
@@ -3811,12 +3767,7 @@ export type GetVideoFeedQuery = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
}>;
}>;
@@ -4847,21 +4798,7 @@ export type FollowUserMutationVariables = Exact<{
export type FollowUserMutation = {
__typename?: "Mutation";
followUser: {
__typename?: "UserGQL";
username: string;
id: number;
following?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
}> | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
}> | null;
};
followUser: { __typename?: "UserGQL"; id: number; username: string };
};
export type UnfollowUserMutationVariables = Exact<{
@@ -4870,21 +4807,7 @@ export type UnfollowUserMutationVariables = Exact<{
export type UnfollowUserMutation = {
__typename?: "Mutation";
unfollowUser: {
__typename?: "UserGQL";
username: string;
id: number;
following?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
}> | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
}> | null;
};
unfollowUser: { __typename?: "UserGQL"; id: number; username: string };
};
export type GetUserFollowingFollowersQueryVariables = Exact<{
@@ -4901,12 +4824,14 @@ export type GetUserFollowingFollowersQuery = {
id: number;
username: string;
profileImageUri?: string | null;
isFollowedByCurrentUser?: boolean | null;
}> | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
isFollowedByCurrentUser?: boolean | null;
}> | null;
} | null;
};
@@ -5129,12 +5054,7 @@ export type GetVideoSocialDetailsByIdQuery = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
}>;
comments: Array<{
@@ -5146,12 +5066,7 @@ export type GetVideoSocialDetailsByIdQuery = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
replies: Array<{
__typename?: "CommentGQL";
@@ -5162,12 +5077,7 @@ export type GetVideoSocialDetailsByIdQuery = {
id: number;
username: string;
profileImageUri?: string | null;
followers?: Array<{
__typename?: "UserGQL";
id: number;
username: string;
profileImageUri?: string | null;
}> | null;
isFollowedByCurrentUser?: boolean | null;
};
}>;
}>;
@@ -5755,11 +5665,7 @@ export const UserSocialsFieldsFragmentDoc = gql`
id
username
profileImageUri
followers {
id
username
profileImageUri
}
isFollowedByCurrentUser
}
`;
export const VideoCardFieldsFragmentDoc = gql`
@@ -6636,6 +6542,7 @@ export const GetVideoFeedDocument = gql`
hasNextPage
endCursor
}
hasFollowing
}
}
${VideoCardFieldsFragmentDoc}
@@ -9063,16 +8970,8 @@ export type GetUserTagsQueryResult = Apollo.QueryResult<
export const FollowUserDocument = gql`
mutation followUser($followedUserId: Int!) {
followUser(followedUserId: $followedUserId) {
username
id
following {
id
username
}
followers {
id
username
}
username
}
}
`;
@@ -9122,16 +9021,8 @@ export type FollowUserMutationOptions = Apollo.BaseMutationOptions<
export const UnfollowUserDocument = gql`
mutation unfollowUser($followedUserId: Int!) {
unfollowUser(followedUserId: $followedUserId) {
username
id
following {
id
username
}
followers {
id
username
}
username
}
}
`;
@@ -9186,11 +9077,13 @@ export const GetUserFollowingFollowersDocument = gql`
id
username
profileImageUri
isFollowedByCurrentUser
}
followers {
id
username
profileImageUri
isFollowedByCurrentUser
}
}
}

View File

@@ -19,11 +19,7 @@ fragment UserSocialsFields on UserGQL {
id
username
profileImageUri
followers {
id
username
profileImageUri
}
isFollowedByCurrentUser
}
fragment VideoCardFields on VideoGQL {
@@ -116,5 +112,6 @@ query GetVideoFeed(
hasNextPage
endCursor
}
hasFollowing
}
}

View File

@@ -88,31 +88,15 @@ query GetUserTags {
mutation followUser($followedUserId: Int!) {
followUser(followedUserId: $followedUserId) {
username
id
following {
id
username
}
followers {
id
username
}
username
}
}
mutation unfollowUser($followedUserId: Int!) {
unfollowUser(followedUserId: $followedUserId) {
username
id
following {
id
username
}
followers {
id
username
}
username
}
}
@@ -123,11 +107,13 @@ query getUserFollowingFollowers {
id
username
profileImageUri
isFollowedByCurrentUser
}
followers {
id
username
profileImageUri
isFollowedByCurrentUser
}
}
}

View File

@@ -86,11 +86,7 @@ fragment UserSocialsFields on UserGQL {
id
username
profileImageUri
followers {
id
username
profileImageUri
}
isFollowedByCurrentUser
}
query GetVideoSocialDetailsById($videoId: Int!) {