Merge pull request 'GetUser operation + fragment' (#151) from loewy/get-user-operation-and-fragment into master

Reviewed-on: #151
This commit is contained in:
loewy 2024-12-19 12:47:20 -07:00
commit 284334606d
2 changed files with 145 additions and 32 deletions

View File

@ -3646,9 +3646,13 @@ export type EditProfileImageUriMutation = {
id: number; id: number;
firebaseUid?: string | null; firebaseUid?: string | null;
username: string; username: string;
isAdmin?: boolean | null;
profileImageUri?: string | null; profileImageUri?: string | null;
fargoRating?: number | null;
activeVideoId?: number | null;
createdAt?: any | null; createdAt?: any | null;
updatedAt?: any | null; updatedAt?: any | null;
videosPrivateByDefault?: boolean | null;
}; };
}; };
@ -3671,6 +3675,27 @@ export type GetLoggedInUserQuery = {
} | null; } | 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<{ export type GetUserPlayTimeQueryVariables = Exact<{
userId: Scalars["Int"]["input"]; userId: Scalars["Int"]["input"];
filters?: InputMaybe<VideoFilterInput>; filters?: InputMaybe<VideoFilterInput>;
@ -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<{ export type GetStreamMonitoringDetailsQueryVariables = Exact<{
videoId: Scalars["Int"]["input"]; videoId: Scalars["Int"]["input"];
debuggingJson?: InputMaybe<Scalars["JSON"]["input"]>; debuggingJson?: InputMaybe<Scalars["JSON"]["input"]>;
@ -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` export const VideoStreamMetadataFragmentDoc = gql`
fragment VideoStreamMetadata on VideoGQL { fragment VideoStreamMetadata on VideoGQL {
id id
@ -6032,14 +6085,10 @@ export type GetProfileImageUploadLinkMutationOptions =
export const EditProfileImageUriDocument = gql` export const EditProfileImageUriDocument = gql`
mutation editProfileImageUri($profileImageUri: String!) { mutation editProfileImageUri($profileImageUri: String!) {
editProfileImageUri(profileImageUri: $profileImageUri) { editProfileImageUri(profileImageUri: $profileImageUri) {
id ...UserFragment
firebaseUid
username
profileImageUri
createdAt
updatedAt
} }
} }
${UserFragmentFragmentDoc}
`; `;
export type EditProfileImageUriMutationFn = Apollo.MutationFunction< export type EditProfileImageUriMutationFn = Apollo.MutationFunction<
EditProfileImageUriMutation, EditProfileImageUriMutation,
@ -6087,18 +6136,10 @@ export type EditProfileImageUriMutationOptions = Apollo.BaseMutationOptions<
export const GetLoggedInUserDocument = gql` export const GetLoggedInUserDocument = gql`
query getLoggedInUser { query getLoggedInUser {
getLoggedInUser { getLoggedInUser {
id ...UserFragment
firebaseUid
username
isAdmin
profileImageUri
fargoRating
activeVideoId
createdAt
updatedAt
videosPrivateByDefault
} }
} }
${UserFragmentFragmentDoc}
`; `;
/** /**
@ -6165,6 +6206,73 @@ export type GetLoggedInUserQueryResult = Apollo.QueryResult<
GetLoggedInUserQuery, GetLoggedInUserQuery,
GetLoggedInUserQueryVariables 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<GetUserQuery, GetUserQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useQuery<GetUserQuery, GetUserQueryVariables>(
GetUserDocument,
options,
);
}
export function useGetUserLazyQuery(
baseOptions?: Apollo.LazyQueryHookOptions<
GetUserQuery,
GetUserQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<GetUserQuery, GetUserQueryVariables>(
GetUserDocument,
options,
);
}
export function useGetUserSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
GetUserQuery,
GetUserQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<GetUserQuery, GetUserQueryVariables>(
GetUserDocument,
options,
);
}
export type GetUserQueryHookResult = ReturnType<typeof useGetUserQuery>;
export type GetUserLazyQueryHookResult = ReturnType<typeof useGetUserLazyQuery>;
export type GetUserSuspenseQueryHookResult = ReturnType<
typeof useGetUserSuspenseQuery
>;
export type GetUserQueryResult = Apollo.QueryResult<
GetUserQuery,
GetUserQueryVariables
>;
export const GetUserPlayTimeDocument = gql` export const GetUserPlayTimeDocument = gql`
query GetUserPlayTime($userId: Int!, $filters: VideoFilterInput) { query GetUserPlayTime($userId: Int!, $filters: VideoFilterInput) {
getPlayTime(userId: $userId, filters: $filters) { getPlayTime(userId: $userId, filters: $filters) {

View File

@ -21,27 +21,19 @@ mutation getProfileImageUploadLink($fileExt: String = ".png") {
mutation editProfileImageUri($profileImageUri: String!) { mutation editProfileImageUri($profileImageUri: String!) {
editProfileImageUri(profileImageUri: $profileImageUri) { editProfileImageUri(profileImageUri: $profileImageUri) {
id ...UserFragment
firebaseUid
username
profileImageUri
createdAt
updatedAt
} }
} }
query getLoggedInUser { query getLoggedInUser {
getLoggedInUser { getLoggedInUser {
id ...UserFragment
firebaseUid }
username }
isAdmin
profileImageUri query GetUser($userId: Int!) {
fargoRating getUser(userId: $userId) {
activeVideoId ...UserFragment
createdAt
updatedAt
videosPrivateByDefault
} }
} }
@ -157,3 +149,16 @@ mutation editUser(
videosPrivateByDefault videosPrivateByDefault
} }
} }
fragment UserFragment on UserGQL {
id
firebaseUid
username
isAdmin
profileImageUri
fargoRating
activeVideoId
createdAt
updatedAt
videosPrivateByDefault
}