From 8859ad8951dfe890cbb5c02fef9dc31a85c3660f Mon Sep 17 00:00:00 2001 From: Loewy Date: Fri, 16 May 2025 17:31:58 -0700 Subject: [PATCH] add lightweight query to refetch social interractions on comment mutation completion --- src/index.tsx | 184 +++++++++++++++++++++++++++++++++++++++ src/operations/feed.gql | 1 + src/operations/video.gql | 51 +++++++++++ 3 files changed, 236 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index f7eb967..10b8109 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -4763,6 +4763,82 @@ export type GetVideoDetailsQuery = { }; }; +export type GetVideoSocialDetailsByIdQueryVariables = Exact<{ + videoId: Scalars["Int"]["input"]; +}>; + +export type GetVideoSocialDetailsByIdQuery = { + __typename?: "Query"; + getVideo: { + __typename?: "VideoGQL"; + id: number; + name?: string | null; + owner?: { + __typename?: "UserGQL"; + id: number; + firebaseUid?: string | null; + username: string; + profileImageUri?: string | null; + } | null; + tags: Array<{ + __typename?: "VideoTag"; + name: string; + tagClasses: Array<{ __typename?: "VideoTagClass"; name: string }>; + }>; + reactions: Array<{ + __typename?: "ReactionGQL"; + videoId: number; + reaction: ReactionEnum; + user: { + __typename?: "UserGQL"; + id: number; + username: string; + profileImageUri?: string | null; + followers?: Array<{ + __typename?: "UserGQL"; + id: number; + username: string; + profileImageUri?: string | null; + }> | null; + }; + }>; + comments: Array<{ + __typename?: "CommentGQL"; + id: number; + message: string; + user: { + __typename?: "UserGQL"; + id: number; + username: string; + profileImageUri?: string | null; + followers?: Array<{ + __typename?: "UserGQL"; + id: number; + username: string; + profileImageUri?: string | null; + }> | null; + }; + replies: Array<{ + __typename?: "CommentGQL"; + id: number; + message: string; + user: { + __typename?: "UserGQL"; + id: number; + username: string; + profileImageUri?: string | null; + followers?: Array<{ + __typename?: "UserGQL"; + id: number; + username: string; + profileImageUri?: string | null; + }> | null; + }; + }>; + }>; + }; +}; + export type GetVideosQueryVariables = Exact<{ videoIds: Array | Scalars["Int"]["input"]; }>; @@ -8823,6 +8899,114 @@ export type GetVideoDetailsQueryResult = Apollo.QueryResult< GetVideoDetailsQuery, GetVideoDetailsQueryVariables >; +export const GetVideoSocialDetailsByIdDocument = gql` + query GetVideoSocialDetailsById($videoId: Int!) { + getVideo(videoId: $videoId) { + id + name + owner { + id + firebaseUid + username + profileImageUri + } + tags { + tagClasses { + name + } + name + } + reactions { + videoId + user { + ...UserSocialsFields + } + reaction + } + comments { + id + message + user { + ...UserSocialsFields + } + replies { + id + message + user { + ...UserSocialsFields + } + } + } + } + } + ${UserSocialsFieldsFragmentDoc} +`; + +/** + * __useGetVideoSocialDetailsByIdQuery__ + * + * To run a query within a React component, call `useGetVideoSocialDetailsByIdQuery` and pass it any options that fit your needs. + * When your component renders, `useGetVideoSocialDetailsByIdQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useGetVideoSocialDetailsByIdQuery({ + * variables: { + * videoId: // value for 'videoId' + * }, + * }); + */ +export function useGetVideoSocialDetailsByIdQuery( + baseOptions: Apollo.QueryHookOptions< + GetVideoSocialDetailsByIdQuery, + GetVideoSocialDetailsByIdQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery< + GetVideoSocialDetailsByIdQuery, + GetVideoSocialDetailsByIdQueryVariables + >(GetVideoSocialDetailsByIdDocument, options); +} +export function useGetVideoSocialDetailsByIdLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + GetVideoSocialDetailsByIdQuery, + GetVideoSocialDetailsByIdQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery< + GetVideoSocialDetailsByIdQuery, + GetVideoSocialDetailsByIdQueryVariables + >(GetVideoSocialDetailsByIdDocument, options); +} +export function useGetVideoSocialDetailsByIdSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetVideoSocialDetailsByIdQuery, + GetVideoSocialDetailsByIdQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetVideoSocialDetailsByIdQuery, + GetVideoSocialDetailsByIdQueryVariables + >(GetVideoSocialDetailsByIdDocument, options); +} +export type GetVideoSocialDetailsByIdQueryHookResult = ReturnType< + typeof useGetVideoSocialDetailsByIdQuery +>; +export type GetVideoSocialDetailsByIdLazyQueryHookResult = ReturnType< + typeof useGetVideoSocialDetailsByIdLazyQuery +>; +export type GetVideoSocialDetailsByIdSuspenseQueryHookResult = ReturnType< + typeof useGetVideoSocialDetailsByIdSuspenseQuery +>; +export type GetVideoSocialDetailsByIdQueryResult = Apollo.QueryResult< + GetVideoSocialDetailsByIdQuery, + GetVideoSocialDetailsByIdQueryVariables +>; export const GetVideosDocument = gql` query GetVideos($videoIds: [Int!]!) { getVideos(videoIds: $videoIds) { diff --git a/src/operations/feed.gql b/src/operations/feed.gql index cf27ec4..39baaa8 100644 --- a/src/operations/feed.gql +++ b/src/operations/feed.gql @@ -14,6 +14,7 @@ query GetFeed( } } } + fragment UserSocialsFields on UserGQL { id username diff --git a/src/operations/video.gql b/src/operations/video.gql index 9c6e4a1..f76405f 100644 --- a/src/operations/video.gql +++ b/src/operations/video.gql @@ -82,6 +82,57 @@ query GetVideoDetails($videoId: Int!) { } } +fragment UserSocialsFields on UserGQL { + id + username + profileImageUri + followers { + id + username + profileImageUri + } +} + +query GetVideoSocialDetailsById($videoId: Int!) { + getVideo(videoId: $videoId) { + id + name + owner { + id + firebaseUid + username + profileImageUri + } + tags { + tagClasses { + name + } + name + } + reactions { + videoId + user { + ...UserSocialsFields + } + reaction + } + comments { + id + message + user { + ...UserSocialsFields + } + replies { + id + message + user { + ...UserSocialsFields + } + } + } + } +} + query GetVideos($videoIds: [Int!]!) { getVideos(videoIds: $videoIds) { ...VideoStreamMetadata