From a883bc3e2f596afb25ac28784ce4afb3f612eb78 Mon Sep 17 00:00:00 2001 From: Loewy Date: Thu, 19 Dec 2024 10:25:51 -0800 Subject: [PATCH] getUser by user id query --- src/index.tsx | 140 +++++++++++++++++++++++++++++++++++----- src/operations/user.gql | 37 ++++++----- 2 files changed, 145 insertions(+), 32 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 268837f..ae0cd9d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3646,9 +3646,13 @@ export type EditProfileImageUriMutation = { id: number; firebaseUid?: string | null; username: string; + isAdmin?: boolean | null; profileImageUri?: string | null; + fargoRating?: number | null; + activeVideoId?: number | null; createdAt?: any | null; updatedAt?: any | null; + videosPrivateByDefault?: boolean | null; }; }; @@ -3671,6 +3675,27 @@ export type GetLoggedInUserQuery = { } | null; }; +export type GetUserQueryVariables = Exact<{ + userId: Scalars["Int"]["input"]; +}>; + +export type GetUserQuery = { + __typename?: "Query"; + getUser?: { + __typename?: "UserGQL"; + id: number; + firebaseUid?: string | null; + username: string; + isAdmin?: boolean | null; + profileImageUri?: string | null; + fargoRating?: number | null; + activeVideoId?: number | null; + createdAt?: any | null; + updatedAt?: any | null; + videosPrivateByDefault?: boolean | null; + } | null; +}; + export type GetUserPlayTimeQueryVariables = Exact<{ userId: Scalars["Int"]["input"]; filters?: InputMaybe; @@ -3815,6 +3840,20 @@ export type EditUserMutation = { }; }; +export type UserFragmentFragment = { + __typename?: "UserGQL"; + id: number; + firebaseUid?: string | null; + username: string; + isAdmin?: boolean | null; + profileImageUri?: string | null; + fargoRating?: number | null; + activeVideoId?: number | null; + createdAt?: any | null; + updatedAt?: any | null; + videosPrivateByDefault?: boolean | null; +}; + export type GetStreamMonitoringDetailsQueryVariables = Exact<{ videoId: Scalars["Int"]["input"]; debuggingJson?: InputMaybe; @@ -4585,6 +4624,20 @@ export const ShotWithAllFeaturesFragmentDoc = gql` } } `; +export const UserFragmentFragmentDoc = gql` + fragment UserFragment on UserGQL { + id + firebaseUid + username + isAdmin + profileImageUri + fargoRating + activeVideoId + createdAt + updatedAt + videosPrivateByDefault + } +`; export const VideoStreamMetadataFragmentDoc = gql` fragment VideoStreamMetadata on VideoGQL { id @@ -6032,14 +6085,10 @@ export type GetProfileImageUploadLinkMutationOptions = export const EditProfileImageUriDocument = gql` mutation editProfileImageUri($profileImageUri: String!) { editProfileImageUri(profileImageUri: $profileImageUri) { - id - firebaseUid - username - profileImageUri - createdAt - updatedAt + ...UserFragment } } + ${UserFragmentFragmentDoc} `; export type EditProfileImageUriMutationFn = Apollo.MutationFunction< EditProfileImageUriMutation, @@ -6087,18 +6136,10 @@ export type EditProfileImageUriMutationOptions = Apollo.BaseMutationOptions< export const GetLoggedInUserDocument = gql` query getLoggedInUser { getLoggedInUser { - id - firebaseUid - username - isAdmin - profileImageUri - fargoRating - activeVideoId - createdAt - updatedAt - videosPrivateByDefault + ...UserFragment } } + ${UserFragmentFragmentDoc} `; /** @@ -6165,6 +6206,73 @@ export type GetLoggedInUserQueryResult = Apollo.QueryResult< GetLoggedInUserQuery, GetLoggedInUserQueryVariables >; +export const GetUserDocument = gql` + query GetUser($userId: Int!) { + getUser(userId: $userId) { + ...UserFragment + } + } + ${UserFragmentFragmentDoc} +`; + +/** + * __useGetUserQuery__ + * + * To run a query within a React component, call `useGetUserQuery` and pass it any options that fit your needs. + * When your component renders, `useGetUserQuery` 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 } = useGetUserQuery({ + * variables: { + * userId: // value for 'userId' + * }, + * }); + */ +export function useGetUserQuery( + baseOptions: Apollo.QueryHookOptions, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery( + GetUserDocument, + options, + ); +} +export function useGetUserLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + GetUserQuery, + GetUserQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery( + GetUserDocument, + options, + ); +} +export function useGetUserSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetUserQuery, + GetUserQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetUserDocument, + options, + ); +} +export type GetUserQueryHookResult = ReturnType; +export type GetUserLazyQueryHookResult = ReturnType; +export type GetUserSuspenseQueryHookResult = ReturnType< + typeof useGetUserSuspenseQuery +>; +export type GetUserQueryResult = Apollo.QueryResult< + GetUserQuery, + GetUserQueryVariables +>; export const GetUserPlayTimeDocument = gql` query GetUserPlayTime($userId: Int!, $filters: VideoFilterInput) { getPlayTime(userId: $userId, filters: $filters) { diff --git a/src/operations/user.gql b/src/operations/user.gql index e5e597b..71489ec 100644 --- a/src/operations/user.gql +++ b/src/operations/user.gql @@ -21,27 +21,19 @@ mutation getProfileImageUploadLink($fileExt: String = ".png") { mutation editProfileImageUri($profileImageUri: String!) { editProfileImageUri(profileImageUri: $profileImageUri) { - id - firebaseUid - username - profileImageUri - createdAt - updatedAt + ...UserFragment } } query getLoggedInUser { getLoggedInUser { - id - firebaseUid - username - isAdmin - profileImageUri - fargoRating - activeVideoId - createdAt - updatedAt - videosPrivateByDefault + ...UserFragment + } +} + +query GetUser($userId: Int!) { + getUser(userId: $userId) { + ...UserFragment } } @@ -157,3 +149,16 @@ mutation editUser( videosPrivateByDefault } } + +fragment UserFragment on UserGQL { + id + firebaseUid + username + isAdmin + profileImageUri + fargoRating + activeVideoId + createdAt + updatedAt + videosPrivateByDefault +}