From 5181612f6212742c214665c7316ff2fc1092906d Mon Sep 17 00:00:00 2001 From: Kat Huang Date: Mon, 22 Apr 2024 16:18:06 -0600 Subject: [PATCH 1/3] Create get videos with playlist gql --- src/index.tsx | 13 ++++++++ src/operations/video.gql | 67 ++++++++++++++++++++++++++++++++++++++++ src/schema.gql | 8 +++++ 3 files changed, 88 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index 1c1445d..f1703bd 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -153,6 +153,13 @@ export type GetUploadLinkReturn = { uploadUrl: Scalars["String"]["output"]; }; +export type HlsPlaylistGql = { + __typename?: "HLSPlaylistGQL"; + m3u8Text: Scalars["String"]["output"]; + segmentDurations: Array; + videoId: Scalars["Int"]["output"]; +}; + export type Header = { __typename?: "Header"; key: Scalars["String"]["output"]; @@ -271,6 +278,7 @@ export type Query = { getUserVideos: VideoHistoryGql; getVideo: VideoGql; getVideoMakePercentageIntervals: Array; + getVideos: Array; }; export type QueryGetAggregatedShotMetricsArgs = { @@ -309,6 +317,10 @@ export type QueryGetVideoMakePercentageIntervalsArgs = { videoId: Scalars["ID"]["input"]; }; +export type QueryGetVideosArgs = { + videoIds: Array; +}; + export type RangeFilter = { greaterThanEqualTo?: InputMaybe; lessThan?: InputMaybe; @@ -402,6 +414,7 @@ export type VideoGql = { medianRun?: Maybe; name?: Maybe; owner?: Maybe; + playlist?: Maybe; shots: Array; startTime?: Maybe; stream?: Maybe; diff --git a/src/operations/video.gql b/src/operations/video.gql index b7c9477..27a6557 100644 --- a/src/operations/video.gql +++ b/src/operations/video.gql @@ -102,3 +102,70 @@ query GetVideoDetails($videoId: Int!) { } } } + +query GetVideos($videoIds: [Int!]!) { + getVideos(videoIds: $videoIds) { + id + name + totalShotsMade + totalShots + makePercentage + medianRun + averageTimeBetweenShots + createdAt + updatedAt + start_time + end_time + elapsed_time + frames_per_second + owner { + id + firebaseUid + username + profileImageUri + } + tags { + tagClasses { + name + } + name + } + playlist { + video_id + m3u8_text + segment_durations + } + shots { + id + timeOffset + coordinates + } + homography_history { + frame_index + crop { + x1 + y1 + x2 + y2 + } + pockets { + x1 + y1 + x2 + y2 + } + source_points { + topLeft + topRight + bottomLeft + bottomRight + } + dest_points { + topLeft + topRight + bottomLeft + bottomRight + } + } + } +} diff --git a/src/schema.gql b/src/schema.gql index 103971e..050270d 100644 --- a/src/schema.gql +++ b/src/schema.gql @@ -19,6 +19,7 @@ type Query { filters: VideoFilterInput = null ): VideoHistoryGQL! getVideo(videoId: Int!): VideoGQL! + getVideos(videoIds: [Int!]!): [VideoGQL!]! } type AggregateResultGQL { @@ -207,6 +208,7 @@ type VideoGQL { elapsedTime: Float framesPerSecond: Int! stream: UploadStreamGQL + playlist: HLSPlaylistGQL tags: [VideoTag!]! homographyHistory: [HomographyInfoGQL!]! } @@ -227,6 +229,12 @@ type StreamErrorGQL { message: String! } +type HLSPlaylistGQL { + videoId: Int! + m3u8Text: String! + segmentDurations: [Float!]! +} + type VideoTag { tagClasses: [VideoTagClass!]! name: String! From c6c59713256870076e486ec65e08645ae16f0115 Mon Sep 17 00:00:00 2001 From: Kat Huang Date: Mon, 22 Apr 2024 21:13:16 -0600 Subject: [PATCH 2/3] Use relevant fields --- src/operations/video.gql | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/src/operations/video.gql b/src/operations/video.gql index 27a6557..c2d51cf 100644 --- a/src/operations/video.gql +++ b/src/operations/video.gql @@ -107,16 +107,6 @@ query GetVideos($videoIds: [Int!]!) { getVideos(videoIds: $videoIds) { id name - totalShotsMade - totalShots - makePercentage - medianRun - averageTimeBetweenShots - createdAt - updatedAt - start_time - end_time - elapsed_time frames_per_second owner { id @@ -140,32 +130,5 @@ query GetVideos($videoIds: [Int!]!) { timeOffset coordinates } - homography_history { - frame_index - crop { - x1 - y1 - x2 - y2 - } - pockets { - x1 - y1 - x2 - y2 - } - source_points { - topLeft - topRight - bottomLeft - bottomRight - } - dest_points { - topLeft - topRight - bottomLeft - bottomRight - } - } } } From db39c5a576d8ee9d5aba2107d384a9679efb8556 Mon Sep 17 00:00:00 2001 From: Kat Huang Date: Mon, 22 Apr 2024 22:20:59 -0600 Subject: [PATCH 3/3] Add generated api hooks --- src/index.tsx | 93 ++++++++++++++++++++++++++++++++++++++++ src/operations/video.gql | 24 ++--------- 2 files changed, 96 insertions(+), 21 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index f1703bd..221f848 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -755,6 +755,25 @@ export type GetVideoDetailsQuery = { }; }; +export type GetVideosQueryVariables = Exact<{ + videoIds: Array | Scalars["Int"]["input"]; +}>; + +export type GetVideosQuery = { + __typename?: "Query"; + getVideos: Array<{ + __typename?: "VideoGQL"; + id: number; + name?: string | null; + framesPerSecond: number; + playlist?: { + __typename?: "HLSPlaylistGQL"; + m3u8Text: string; + segmentDurations: Array; + } | null; + }>; +}; + export type CreateUploadStreamMutationVariables = Exact<{ videoMetadataInput: VideoMetadataInput; }>; @@ -1837,6 +1856,80 @@ export type GetVideoDetailsQueryResult = Apollo.QueryResult< GetVideoDetailsQuery, GetVideoDetailsQueryVariables >; +export const GetVideosDocument = gql` + query GetVideos($videoIds: [Int!]!) { + getVideos(videoIds: $videoIds) { + id + name + framesPerSecond + playlist { + m3u8Text + segmentDurations + } + } + } +`; + +/** + * __useGetVideosQuery__ + * + * To run a query within a React component, call `useGetVideosQuery` and pass it any options that fit your needs. + * When your component renders, `useGetVideosQuery` 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 } = useGetVideosQuery({ + * variables: { + * videoIds: // value for 'videoIds' + * }, + * }); + */ +export function useGetVideosQuery( + baseOptions: Apollo.QueryHookOptions, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery( + GetVideosDocument, + options, + ); +} +export function useGetVideosLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + GetVideosQuery, + GetVideosQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery( + GetVideosDocument, + options, + ); +} +export function useGetVideosSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetVideosQuery, + GetVideosQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetVideosDocument, + options, + ); +} +export type GetVideosQueryHookResult = ReturnType; +export type GetVideosLazyQueryHookResult = ReturnType< + typeof useGetVideosLazyQuery +>; +export type GetVideosSuspenseQueryHookResult = ReturnType< + typeof useGetVideosSuspenseQuery +>; +export type GetVideosQueryResult = Apollo.QueryResult< + GetVideosQuery, + GetVideosQueryVariables +>; export const CreateUploadStreamDocument = gql` mutation CreateUploadStream($videoMetadataInput: VideoMetadataInput!) { createUploadStream(videoMetadata: $videoMetadataInput) { diff --git a/src/operations/video.gql b/src/operations/video.gql index c2d51cf..ef1c86c 100644 --- a/src/operations/video.gql +++ b/src/operations/video.gql @@ -107,28 +107,10 @@ query GetVideos($videoIds: [Int!]!) { getVideos(videoIds: $videoIds) { id name - frames_per_second - owner { - id - firebaseUid - username - profileImageUri - } - tags { - tagClasses { - name - } - name - } + framesPerSecond playlist { - video_id - m3u8_text - segment_durations - } - shots { - id - timeOffset - coordinates + m3u8Text + segmentDurations } } }