From 8378f7ae0b23c5eee1f98a31260beab8c02088a4 Mon Sep 17 00:00:00 2001 From: Loewy Date: Mon, 6 May 2024 15:16:06 -0700 Subject: [PATCH] just gql stuff + use it on uncompletedStreams hook --- src/index.tsx | 124 +++++++++++++++++++++++++++++++- src/operations/video_upload.gql | 22 ++++++ src/schema.gql | 2 +- 3 files changed, 146 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index bb0fc26..3e664f9 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -378,7 +378,7 @@ export type UploadStreamGql = { errors: Array; id: Scalars["ID"]["output"]; isCompleted: Scalars["Boolean"]["output"]; - lastIntendedSegmentBound: Scalars["Int"]["output"]; + lastIntendedSegmentBound?: Maybe; linksRequested: Scalars["Int"]["output"]; lowestUnuploadedSegmentIndex: Scalars["Int"]["output"]; segmentProcessingCursor: Scalars["Int"]["output"]; @@ -861,6 +861,36 @@ export type GetUploadStreamsQuery = { }; }; +export type GetUploadStreamsWithDetailsQueryVariables = Exact<{ + limit?: Scalars["Int"]["input"]; + after?: InputMaybe; + filters?: InputMaybe; +}>; + +export type GetUploadStreamsWithDetailsQuery = { + __typename?: "Query"; + getUserVideos: { + __typename?: "VideoHistoryGQL"; + videos: Array<{ + __typename?: "VideoGQL"; + id: number; + name?: string | null; + startTime?: any | null; + stream?: { + __typename?: "UploadStreamGQL"; + isCompleted: boolean; + lastIntendedSegmentBound?: number | null; + uploadCompletionCursor: number; + } | null; + }>; + pageInfo: { + __typename?: "PageInfoGQL"; + hasNextPage: boolean; + endCursor?: string | null; + }; + }; +}; + export type GetUploadStreamDetailsQueryVariables = Exact<{ videoId: Scalars["Int"]["input"]; }>; @@ -2243,6 +2273,98 @@ export type GetUploadStreamsQueryResult = Apollo.QueryResult< GetUploadStreamsQuery, GetUploadStreamsQueryVariables >; +export const GetUploadStreamsWithDetailsDocument = gql` + query GetUploadStreamsWithDetails( + $limit: Int! = 5 + $after: String = null + $filters: VideoFilterInput = null + ) { + getUserVideos(limit: $limit, after: $after, filters: $filters) { + videos { + id + name + startTime + stream { + isCompleted + lastIntendedSegmentBound + uploadCompletionCursor + } + } + pageInfo { + hasNextPage + endCursor + } + } + } +`; + +/** + * __useGetUploadStreamsWithDetailsQuery__ + * + * To run a query within a React component, call `useGetUploadStreamsWithDetailsQuery` and pass it any options that fit your needs. + * When your component renders, `useGetUploadStreamsWithDetailsQuery` 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 } = useGetUploadStreamsWithDetailsQuery({ + * variables: { + * limit: // value for 'limit' + * after: // value for 'after' + * filters: // value for 'filters' + * }, + * }); + */ +export function useGetUploadStreamsWithDetailsQuery( + baseOptions?: Apollo.QueryHookOptions< + GetUploadStreamsWithDetailsQuery, + GetUploadStreamsWithDetailsQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery< + GetUploadStreamsWithDetailsQuery, + GetUploadStreamsWithDetailsQueryVariables + >(GetUploadStreamsWithDetailsDocument, options); +} +export function useGetUploadStreamsWithDetailsLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + GetUploadStreamsWithDetailsQuery, + GetUploadStreamsWithDetailsQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery< + GetUploadStreamsWithDetailsQuery, + GetUploadStreamsWithDetailsQueryVariables + >(GetUploadStreamsWithDetailsDocument, options); +} +export function useGetUploadStreamsWithDetailsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetUploadStreamsWithDetailsQuery, + GetUploadStreamsWithDetailsQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetUploadStreamsWithDetailsQuery, + GetUploadStreamsWithDetailsQueryVariables + >(GetUploadStreamsWithDetailsDocument, options); +} +export type GetUploadStreamsWithDetailsQueryHookResult = ReturnType< + typeof useGetUploadStreamsWithDetailsQuery +>; +export type GetUploadStreamsWithDetailsLazyQueryHookResult = ReturnType< + typeof useGetUploadStreamsWithDetailsLazyQuery +>; +export type GetUploadStreamsWithDetailsSuspenseQueryHookResult = ReturnType< + typeof useGetUploadStreamsWithDetailsSuspenseQuery +>; +export type GetUploadStreamsWithDetailsQueryResult = Apollo.QueryResult< + GetUploadStreamsWithDetailsQuery, + GetUploadStreamsWithDetailsQueryVariables +>; export const GetUploadStreamDetailsDocument = gql` query GetUploadStreamDetails($videoId: Int!) { getVideo(videoId: $videoId) { diff --git a/src/operations/video_upload.gql b/src/operations/video_upload.gql index ebebe7b..c88e3b2 100644 --- a/src/operations/video_upload.gql +++ b/src/operations/video_upload.gql @@ -36,6 +36,28 @@ query GetUploadStreams( } } } +query GetUploadStreamsWithDetails( + $limit: Int! = 5 + $after: String = null + $filters: VideoFilterInput = null +) { + getUserVideos(limit: $limit, after: $after, filters: $filters) { + videos { + id + name + startTime + stream { + isCompleted + lastIntendedSegmentBound + uploadCompletionCursor + } + } + pageInfo { + hasNextPage + endCursor + } + } +} query GetUploadStreamDetails($videoId: Int!) { getVideo(videoId: $videoId) { diff --git a/src/schema.gql b/src/schema.gql index 951a0af..0c39be2 100644 --- a/src/schema.gql +++ b/src/schema.gql @@ -224,7 +224,7 @@ type UploadStreamGQL { linksRequested: Int! uploadsCompleted: Int! segmentProcessingCursor: Int! - lastIntendedSegmentBound: Int! + lastIntendedSegmentBound: Int isCompleted: Boolean! lowestUnuploadedSegmentIndex: Int! uploadCompletionCursor: Int!