From d51d2491caf13bdad7b8bb9c9252ce11c2cc05d8 Mon Sep 17 00:00:00 2001 From: Loewy Date: Tue, 23 Apr 2024 11:49:42 -0700 Subject: [PATCH] new lighter weight queries --- src/index.tsx | 210 ++++++++++++++++++++++++++++++++ src/operations/video_upload.gql | 30 +++++ 2 files changed, 240 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index fd58200..e39d435 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -786,6 +786,50 @@ export type EditUploadStreamMutation = { editUploadStream: boolean; }; +export type GetUploadStreamsQueryVariables = Exact<{ + limit?: Scalars["Int"]["input"]; + after?: InputMaybe; + filters?: InputMaybe; +}>; + +export type GetUploadStreamsQuery = { + __typename?: "Query"; + getUserVideos: { + __typename?: "VideoHistoryGQL"; + videos: Array<{ + __typename?: "VideoGQL"; + id: number; + stream?: { + __typename?: "UploadStreamGQL"; + isCompleted: boolean; + lowestUnuploadedSegmentIndex: number; + } | null; + }>; + pageInfo: { + __typename?: "PageInfoGQL"; + hasNextPage: boolean; + endCursor?: string | null; + }; + }; +}; + +export type GetUploadStreamDetailsQueryVariables = Exact<{ + videoId: Scalars["Int"]["input"]; +}>; + +export type GetUploadStreamDetailsQuery = { + __typename?: "Query"; + getVideo: { + __typename?: "VideoGQL"; + id: number; + stream?: { + __typename?: "UploadStreamGQL"; + isCompleted: boolean; + lowestUnuploadedSegmentIndex: number; + } | null; + }; +}; + export const GetAggregatedShotMetricsDocument = gql` query GetAggregatedShotMetrics($aggregateInput: AggregateInputGQL!) { getAggregatedShotMetrics(aggregateInput: $aggregateInput) { @@ -1986,3 +2030,169 @@ export type EditUploadStreamMutationOptions = Apollo.BaseMutationOptions< EditUploadStreamMutation, EditUploadStreamMutationVariables >; +export const GetUploadStreamsDocument = gql` + query GetUploadStreams( + $limit: Int! = 5 + $after: String = null + $filters: VideoFilterInput = null + ) { + getUserVideos(limit: $limit, after: $after, filters: $filters) { + videos { + id + stream { + isCompleted + lowestUnuploadedSegmentIndex + } + } + pageInfo { + hasNextPage + endCursor + } + } + } +`; + +/** + * __useGetUploadStreamsQuery__ + * + * To run a query within a React component, call `useGetUploadStreamsQuery` and pass it any options that fit your needs. + * When your component renders, `useGetUploadStreamsQuery` 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 } = useGetUploadStreamsQuery({ + * variables: { + * limit: // value for 'limit' + * after: // value for 'after' + * filters: // value for 'filters' + * }, + * }); + */ +export function useGetUploadStreamsQuery( + baseOptions?: Apollo.QueryHookOptions< + GetUploadStreamsQuery, + GetUploadStreamsQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery( + GetUploadStreamsDocument, + options, + ); +} +export function useGetUploadStreamsLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + GetUploadStreamsQuery, + GetUploadStreamsQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery< + GetUploadStreamsQuery, + GetUploadStreamsQueryVariables + >(GetUploadStreamsDocument, options); +} +export function useGetUploadStreamsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetUploadStreamsQuery, + GetUploadStreamsQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetUploadStreamsQuery, + GetUploadStreamsQueryVariables + >(GetUploadStreamsDocument, options); +} +export type GetUploadStreamsQueryHookResult = ReturnType< + typeof useGetUploadStreamsQuery +>; +export type GetUploadStreamsLazyQueryHookResult = ReturnType< + typeof useGetUploadStreamsLazyQuery +>; +export type GetUploadStreamsSuspenseQueryHookResult = ReturnType< + typeof useGetUploadStreamsSuspenseQuery +>; +export type GetUploadStreamsQueryResult = Apollo.QueryResult< + GetUploadStreamsQuery, + GetUploadStreamsQueryVariables +>; +export const GetUploadStreamDetailsDocument = gql` + query GetUploadStreamDetails($videoId: Int!) { + getVideo(videoId: $videoId) { + id + stream { + isCompleted + lowestUnuploadedSegmentIndex + } + } + } +`; + +/** + * __useGetUploadStreamDetailsQuery__ + * + * To run a query within a React component, call `useGetUploadStreamDetailsQuery` and pass it any options that fit your needs. + * When your component renders, `useGetUploadStreamDetailsQuery` 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 } = useGetUploadStreamDetailsQuery({ + * variables: { + * videoId: // value for 'videoId' + * }, + * }); + */ +export function useGetUploadStreamDetailsQuery( + baseOptions: Apollo.QueryHookOptions< + GetUploadStreamDetailsQuery, + GetUploadStreamDetailsQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery< + GetUploadStreamDetailsQuery, + GetUploadStreamDetailsQueryVariables + >(GetUploadStreamDetailsDocument, options); +} +export function useGetUploadStreamDetailsLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + GetUploadStreamDetailsQuery, + GetUploadStreamDetailsQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery< + GetUploadStreamDetailsQuery, + GetUploadStreamDetailsQueryVariables + >(GetUploadStreamDetailsDocument, options); +} +export function useGetUploadStreamDetailsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetUploadStreamDetailsQuery, + GetUploadStreamDetailsQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetUploadStreamDetailsQuery, + GetUploadStreamDetailsQueryVariables + >(GetUploadStreamDetailsDocument, options); +} +export type GetUploadStreamDetailsQueryHookResult = ReturnType< + typeof useGetUploadStreamDetailsQuery +>; +export type GetUploadStreamDetailsLazyQueryHookResult = ReturnType< + typeof useGetUploadStreamDetailsLazyQuery +>; +export type GetUploadStreamDetailsSuspenseQueryHookResult = ReturnType< + typeof useGetUploadStreamDetailsSuspenseQuery +>; +export type GetUploadStreamDetailsQueryResult = Apollo.QueryResult< + GetUploadStreamDetailsQuery, + GetUploadStreamDetailsQueryVariables +>; diff --git a/src/operations/video_upload.gql b/src/operations/video_upload.gql index 50ca82f..04b9e1f 100644 --- a/src/operations/video_upload.gql +++ b/src/operations/video_upload.gql @@ -20,3 +20,33 @@ mutation EditUploadStream( ) { editUploadStream(videoId: $videoId, videoMetadata: $videoMetadataInput) } + +query GetUploadStreams( + $limit: Int! = 5 + $after: String = null + $filters: VideoFilterInput = null +) { + getUserVideos(limit: $limit, after: $after, filters: $filters) { + videos { + id + stream { + isCompleted + lowestUnuploadedSegmentIndex + } + } + pageInfo { + hasNextPage + endCursor + } + } +} + +query GetUploadStreamDetails($videoId: Int!) { + getVideo(videoId: $videoId) { + id + stream { + isCompleted + lowestUnuploadedSegmentIndex + } + } +}