From 5534fe518a05ee0246530e42814f3f6a788d2244 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Tue, 23 Aug 2022 11:10:51 +0300 Subject: [PATCH] feat: make all profile sections reactive to mutation changes --- .../BasicProfileInfoTab.Skeleton.tsx} | 2 +- .../BasicProfileInfoTab.tsx} | 17 +- .../BasicProfileInfoTab/profileAbout.graphql | 28 ++ .../pages/EditProfilePage/EditProfilePage.tsx | 8 +- .../RolesSkillsTab/RolesSkillsTab.tsx | 17 +- .../RolesSkillsTab/rolesSkills.graphql | 24 +- .../UpdateMyProfileTab/profileAbout.graphql | 37 --- .../pages/ProfilePage/ProfilePage.tsx | 22 +- .../pages/ProfilePage/profile.graphql | 26 +- src/graphql/index.tsx | 291 +++++++++--------- src/utils/apollo.ts | 3 + 11 files changed, 209 insertions(+), 266 deletions(-) rename src/features/Profiles/pages/EditProfilePage/{UpdateMyProfileTab/UpdateMyProfileTab.Skeleton.tsx => BasicProfileInfoTab/BasicProfileInfoTab.Skeleton.tsx} (95%) rename src/features/Profiles/pages/EditProfilePage/{UpdateMyProfileTab/UpdateMyProfileTab.tsx => BasicProfileInfoTab/BasicProfileInfoTab.tsx} (95%) create mode 100644 src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/profileAbout.graphql delete mode 100644 src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/profileAbout.graphql diff --git a/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/UpdateMyProfileTab.Skeleton.tsx b/src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/BasicProfileInfoTab.Skeleton.tsx similarity index 95% rename from src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/UpdateMyProfileTab.Skeleton.tsx rename to src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/BasicProfileInfoTab.Skeleton.tsx index 51e7e45..3954b5f 100644 --- a/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/UpdateMyProfileTab.Skeleton.tsx +++ b/src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/BasicProfileInfoTab.Skeleton.tsx @@ -1,7 +1,7 @@ import Card from 'src/Components/Card/Card'; import Skeleton from 'react-loading-skeleton'; -export default function UpdateProfileAboutTabSkeleton() { +export default function BasicProfileInfoTabSkeleton() { return (
diff --git a/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/UpdateMyProfileTab.tsx b/src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/BasicProfileInfoTab.tsx similarity index 95% rename from src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/UpdateMyProfileTab.tsx rename to src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/BasicProfileInfoTab.tsx index 2af4dbe..0d31d32 100644 --- a/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/UpdateMyProfileTab.tsx +++ b/src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/BasicProfileInfoTab.tsx @@ -1,6 +1,5 @@ import { SubmitHandler, useForm } from "react-hook-form" -import Button from "src/Components/Button/Button"; -import { User, useUpdateProfileAboutMutation, useMyProfileAboutQuery, UpdateProfileAboutMutationVariables } from "src/graphql"; +import { useUpdateProfileAboutMutation, useMyProfileAboutQuery, UpdateProfileAboutMutationVariables, UserBasicInfoFragmentDoc } from "src/graphql"; import { NotificationsService } from "src/services/notifications.service"; import * as yup from "yup"; import { yupResolver } from "@hookform/resolvers/yup"; @@ -9,10 +8,10 @@ import { useAppDispatch, usePrompt } from "src/utils/hooks"; import SaveChangesCard from "../SaveChangesCard/SaveChangesCard"; import { toast } from "react-toastify"; import Card from "src/Components/Card/Card"; -import LoadingPage from "src/Components/LoadingPage/LoadingPage"; import NotFoundPage from "src/features/Shared/pages/NotFoundPage/NotFoundPage"; import { setUser } from "src/redux/features/user.slice"; -import UpdateProfileAboutTabSkeleton from "./UpdateMyProfileTab.Skeleton"; +import UpdateProfileAboutTabSkeleton from "./BasicProfileInfoTab.Skeleton"; +import { useApolloClient } from "@apollo/client"; interface Props { } @@ -53,7 +52,7 @@ const schema: yup.SchemaOf = yup.object({ }).required(); -export default function UpdateMyProfileTab() { +export default function BasicProfileInfoTab() { const { register, formState: { errors, isDirty, }, handleSubmit, reset } = useForm({ defaultValues: {}, @@ -61,7 +60,7 @@ export default function UpdateMyProfileTab() { mode: 'onBlur', }); - + const apolloClient = useApolloClient() const profileQuery = useMyProfileAboutQuery({ onCompleted: data => { if (data.me) @@ -70,6 +69,7 @@ export default function UpdateMyProfileTab() { }) const [mutate, mutationStatus] = useUpdateProfileAboutMutation(); + const dispatch = useAppDispatch() usePrompt('You may have some unsaved changes. You still want to leave?', isDirty) @@ -106,6 +106,11 @@ export default function UpdateMyProfileTab() { if (data) { dispatch(setUser(data)) reset(data); + apolloClient.writeFragment({ + id: `User:${data?.id}`, + data, + fragment: UserBasicInfoFragmentDoc, + }) toast.update(toastId, { render: "Saved changes successfully", type: "success", ...NotificationsService.defaultOptions, isLoading: false }); } } diff --git a/src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/profileAbout.graphql b/src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/profileAbout.graphql new file mode 100644 index 0000000..2c485e8 --- /dev/null +++ b/src/features/Profiles/pages/EditProfilePage/BasicProfileInfoTab/profileAbout.graphql @@ -0,0 +1,28 @@ +fragment UserBasicInfo on BaseUser { + id + name + avatar + join_date + role + email + jobTitle + lightning_address + website + twitter + github + linkedin + bio + location +} + +query MyProfileAbout { + me { + ...UserBasicInfo + } +} + +mutation updateProfileAbout($data: ProfileDetailsInput) { + updateProfileDetails(data: $data) { + ...UserBasicInfo + } +} diff --git a/src/features/Profiles/pages/EditProfilePage/EditProfilePage.tsx b/src/features/Profiles/pages/EditProfilePage/EditProfilePage.tsx index 67d8a04..204250b 100644 --- a/src/features/Profiles/pages/EditProfilePage/EditProfilePage.tsx +++ b/src/features/Profiles/pages/EditProfilePage/EditProfilePage.tsx @@ -3,18 +3,18 @@ import LoadingPage from "src/Components/LoadingPage/LoadingPage"; import NotFoundPage from "src/features/Shared/pages/NotFoundPage/NotFoundPage"; import Slider from "src/Components/Slider/Slider"; import { useAppSelector, useMediaQuery } from "src/utils/hooks"; -import UpdateMyProfileTab from "./UpdateMyProfileTab/UpdateMyProfileTab"; import { Helmet } from 'react-helmet' import { MEDIA_QUERIES } from "src/utils/theme"; import PreferencesTab from "./PreferencesTab/PreferencesTab"; import RolesSkillsTab from "./RolesSkillsTab/RolesSkillsTab"; import Card from "src/Components/Card/Card"; +import BasicProfileInfoTab from "./BasicProfileInfoTab/BasicProfileInfoTab"; const links = [ { text: "🤠 Basic information", - path: 'my-profile', + path: 'basic-info', }, { text: "🎛️ Roles & Skills", @@ -87,8 +87,8 @@ export default function EditProfilePage() {
- } /> - } /> + } /> + } /> } /> } /> diff --git a/src/features/Profiles/pages/EditProfilePage/RolesSkillsTab/RolesSkillsTab.tsx b/src/features/Profiles/pages/EditProfilePage/RolesSkillsTab/RolesSkillsTab.tsx index 9b11935..587b318 100644 --- a/src/features/Profiles/pages/EditProfilePage/RolesSkillsTab/RolesSkillsTab.tsx +++ b/src/features/Profiles/pages/EditProfilePage/RolesSkillsTab/RolesSkillsTab.tsx @@ -8,7 +8,7 @@ import { toast } from 'react-toastify'; import { NotificationsService } from 'src/services'; import { gql, NetworkStatus, useApolloClient } from '@apollo/client'; import { usePrompt } from 'src/utils/hooks'; -import { UpdateUserRolesSkillsMutationVariables, useMyProfileRolesSkillsQuery, useUpdateUserRolesSkillsMutation } from 'src/graphql' +import { UpdateUserRolesSkillsMutationVariables, useMyProfileRolesSkillsQuery, useUpdateUserRolesSkillsMutation, UserRolesSkillsFragmentDoc } from 'src/graphql' import UpdateRolesCard from "./UpdateRolesCard/UpdateRolesCard"; import UpdateSkillsCard from "./UpdateSkillsCard/UpdateSkillsCard"; import RolesSkillsTabSkeleton from "./RolesSkillsTab.Skeleton"; @@ -54,19 +54,14 @@ export default function PreferencesTab() { const apolloClient = useApolloClient() const [mutate, mutationStatus] = useUpdateUserRolesSkillsMutation({ - onCompleted: data => { + onCompleted: ({ updateProfileRoles: data }) => { apolloClient.writeFragment({ - id: `User:${data.updateProfileRoles?.id}`, + id: `User:${data?.id}`, data: { - roles: data.updateProfileRoles?.roles, - skills: data.updateProfileRoles?.skills + roles: data?.roles, + skills: data?.skills }, - fragment: gql` - fragment user on User{ - roles - skills - } - ` + fragment: UserRolesSkillsFragmentDoc, }) } }); diff --git a/src/features/Profiles/pages/EditProfilePage/RolesSkillsTab/rolesSkills.graphql b/src/features/Profiles/pages/EditProfilePage/RolesSkillsTab/rolesSkills.graphql index e80ea58..0f1957d 100644 --- a/src/features/Profiles/pages/EditProfilePage/RolesSkillsTab/rolesSkills.graphql +++ b/src/features/Profiles/pages/EditProfilePage/RolesSkillsTab/rolesSkills.graphql @@ -1,16 +1,20 @@ +fragment UserRolesSkills on BaseUser { + skills { + id + title + } + roles { + id + title + icon + level + } +} + query MyProfileRolesSkills { me { id - skills { - id - title - } - roles { - id - title - icon - level - } + ...UserRolesSkills } getAllMakersRoles { id diff --git a/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/profileAbout.graphql b/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/profileAbout.graphql deleted file mode 100644 index 3517a9b..0000000 --- a/src/features/Profiles/pages/EditProfilePage/UpdateMyProfileTab/profileAbout.graphql +++ /dev/null @@ -1,37 +0,0 @@ -query MyProfileAbout { - me { - id - name - avatar - join_date - role - email - jobTitle - lightning_address - website - twitter - github - linkedin - bio - location - } -} - -mutation updateProfileAbout($data: ProfileDetailsInput) { - updateProfileDetails(data: $data) { - id - name - avatar - join_date - role - email - jobTitle - lightning_address - website - twitter - github - linkedin - bio - location - } -} diff --git a/src/features/Profiles/pages/ProfilePage/ProfilePage.tsx b/src/features/Profiles/pages/ProfilePage/ProfilePage.tsx index 5730ba5..50f709c 100644 --- a/src/features/Profiles/pages/ProfilePage/ProfilePage.tsx +++ b/src/features/Profiles/pages/ProfilePage/ProfilePage.tsx @@ -31,27 +31,6 @@ export default function ProfilePage() { const isMediumScreen = useMediaQuery(MEDIA_QUERIES.isMedium) - const apolloClient = useApolloClient(); - - const profileFetched = !!profileQuery.data?.profile - - useEffect(() => { - if (profileFetched) - console.log(apolloClient.readFragment({ - id: `User:${id}`, - fragment: gql` - fragment MyUser on User{ - id - name - roles{ - id - title - } - } - ` - })) - - }, [apolloClient, profileFetched]) if (profileQuery.loading) return @@ -59,6 +38,7 @@ export default function ProfilePage() { if (!profileQuery.data?.profile) return + return ( <> diff --git a/src/features/Profiles/pages/ProfilePage/profile.graphql b/src/features/Profiles/pages/ProfilePage/profile.graphql index 8bdaa0e..76829c8 100644 --- a/src/features/Profiles/pages/ProfilePage/profile.graphql +++ b/src/features/Profiles/pages/ProfilePage/profile.graphql @@ -1,19 +1,5 @@ query profile($profileId: Int!) { profile(id: $profileId) { - id - name - avatar - join_date - role - email - jobTitle - lightning_address - website - twitter - github - linkedin - bio - location stories { id title @@ -24,16 +10,6 @@ query profile($profileId: Int!) { icon } } - skills { - id - title - } - roles { - id - title - icon - level - } tournaments { id title @@ -47,5 +23,7 @@ query profile($profileId: Int!) { avatar jobTitle } + ...UserBasicInfo + ...UserRolesSkills } } diff --git a/src/graphql/index.tsx b/src/graphql/index.tsx index e5f3a8d..cf552b9 100644 --- a/src/graphql/index.tsx +++ b/src/graphql/index.tsx @@ -652,29 +652,11 @@ export type PostDetailsQueryVariables = Exact<{ export type PostDetailsQuery = { __typename?: 'Query', getPostById: { __typename?: 'Bounty', id: number, title: string, createdAt: any, body: string, votes_count: number, type: string, cover_image: string | null, deadline: string, reward_amount: number, applicants_count: number, author: { __typename?: 'Author', id: number, name: string, avatar: string, join_date: any }, tags: Array<{ __typename?: 'Tag', id: number, title: string }>, applications: Array<{ __typename?: 'BountyApplication', id: number, date: string, workplan: string, author: { __typename?: 'Author', id: number, name: string, avatar: string } }> } | { __typename?: 'Question', id: number, title: string, createdAt: any, body: string, votes_count: number, type: string, author: { __typename?: 'Author', id: number, name: string, avatar: string, join_date: any }, tags: Array<{ __typename?: 'Tag', id: number, title: string }> } | { __typename?: 'Story', id: number, title: string, createdAt: any, body: string, votes_count: number, type: string, cover_image: string | null, is_published: boolean | null, author: { __typename?: 'Author', id: number, name: string, avatar: string, join_date: any }, tags: Array<{ __typename?: 'Tag', id: number, title: string }> } }; -export type MyProfilePreferencesQueryVariables = Exact<{ [key: string]: never; }>; +type UserBasicInfo_MyProfile_Fragment = { __typename?: 'MyProfile', id: number, name: string, avatar: string, join_date: any, role: string | null, email: string | null, jobTitle: string | null, lightning_address: string | null, website: string | null, twitter: string | null, github: string | null, linkedin: string | null, bio: string | null, location: string | null }; +type UserBasicInfo_User_Fragment = { __typename?: 'User', id: number, name: string, avatar: string, join_date: any, role: string | null, email: string | null, jobTitle: string | null, lightning_address: string | null, website: string | null, twitter: string | null, github: string | null, linkedin: string | null, bio: string | null, location: string | null }; -export type MyProfilePreferencesQuery = { __typename?: 'Query', me: { __typename?: 'MyProfile', id: number, nostr_prv_key: string | null, nostr_pub_key: string | null, walletsKeys: Array<{ __typename?: 'WalletKey', key: string, name: string }> } | null }; - -export type UpdateUserPreferencesMutationVariables = Exact<{ - walletsKeys: InputMaybe | UserKeyInputType>; -}>; - - -export type UpdateUserPreferencesMutation = { __typename?: 'Mutation', updateUserPreferences: { __typename?: 'MyProfile', id: number, nostr_pub_key: string | null, nostr_prv_key: string | null, walletsKeys: Array<{ __typename?: 'WalletKey', key: string, name: string }> } }; - -export type MyProfileRolesSkillsQueryVariables = Exact<{ [key: string]: never; }>; - - -export type MyProfileRolesSkillsQuery = { __typename?: 'Query', me: { __typename?: 'MyProfile', id: number, skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }>, roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }> } | null, getAllMakersRoles: Array<{ __typename?: 'GenericMakerRole', id: number, title: string, icon: string }>, getAllMakersSkills: Array<{ __typename?: 'MakerSkill', id: number, title: string }> }; - -export type UpdateUserRolesSkillsMutationVariables = Exact<{ - data: InputMaybe; -}>; - - -export type UpdateUserRolesSkillsMutation = { __typename?: 'Mutation', updateProfileRoles: { __typename?: 'MyProfile', id: number, skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }>, roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }> } | null }; +export type UserBasicInfoFragment = UserBasicInfo_MyProfile_Fragment | UserBasicInfo_User_Fragment; export type MyProfileAboutQueryVariables = Exact<{ [key: string]: never; }>; @@ -688,12 +670,42 @@ export type UpdateProfileAboutMutationVariables = Exact<{ export type UpdateProfileAboutMutation = { __typename?: 'Mutation', updateProfileDetails: { __typename?: 'MyProfile', id: number, name: string, avatar: string, join_date: any, role: string | null, email: string | null, jobTitle: string | null, lightning_address: string | null, website: string | null, twitter: string | null, github: string | null, linkedin: string | null, bio: string | null, location: string | null } | null }; +export type MyProfilePreferencesQueryVariables = Exact<{ [key: string]: never; }>; + + +export type MyProfilePreferencesQuery = { __typename?: 'Query', me: { __typename?: 'MyProfile', id: number, nostr_prv_key: string | null, nostr_pub_key: string | null, walletsKeys: Array<{ __typename?: 'WalletKey', key: string, name: string }> } | null }; + +export type UpdateUserPreferencesMutationVariables = Exact<{ + walletsKeys: InputMaybe | UserKeyInputType>; +}>; + + +export type UpdateUserPreferencesMutation = { __typename?: 'Mutation', updateUserPreferences: { __typename?: 'MyProfile', id: number, nostr_pub_key: string | null, nostr_prv_key: string | null, walletsKeys: Array<{ __typename?: 'WalletKey', key: string, name: string }> } }; + +type UserRolesSkills_MyProfile_Fragment = { __typename?: 'MyProfile', skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }>, roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }> }; + +type UserRolesSkills_User_Fragment = { __typename?: 'User', skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }>, roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }> }; + +export type UserRolesSkillsFragment = UserRolesSkills_MyProfile_Fragment | UserRolesSkills_User_Fragment; + +export type MyProfileRolesSkillsQueryVariables = Exact<{ [key: string]: never; }>; + + +export type MyProfileRolesSkillsQuery = { __typename?: 'Query', me: { __typename?: 'MyProfile', id: number, skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }>, roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }> } | null, getAllMakersRoles: Array<{ __typename?: 'GenericMakerRole', id: number, title: string, icon: string }>, getAllMakersSkills: Array<{ __typename?: 'MakerSkill', id: number, title: string }> }; + +export type UpdateUserRolesSkillsMutationVariables = Exact<{ + data: InputMaybe; +}>; + + +export type UpdateUserRolesSkillsMutation = { __typename?: 'Mutation', updateProfileRoles: { __typename?: 'MyProfile', id: number, skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }>, roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }> } | null }; + export type ProfileQueryVariables = Exact<{ profileId: Scalars['Int']; }>; -export type ProfileQuery = { __typename?: 'Query', profile: { __typename?: 'User', id: number, name: string, avatar: string, join_date: any, role: string | null, email: string | null, jobTitle: string | null, lightning_address: string | null, website: string | null, twitter: string | null, github: string | null, linkedin: string | null, bio: string | null, location: string | null, stories: Array<{ __typename?: 'Story', id: number, title: string, createdAt: any, tags: Array<{ __typename?: 'Tag', id: number, title: string, icon: string | null }> }>, skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }>, roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }>, tournaments: Array<{ __typename?: 'Tournament', id: number, title: string, thumbnail_image: string, start_date: any, end_date: any }>, similar_makers: Array<{ __typename?: 'User', id: number, name: string, avatar: string, jobTitle: string | null }> } | null }; +export type ProfileQuery = { __typename?: 'Query', profile: { __typename?: 'User', id: number, name: string, avatar: string, join_date: any, role: string | null, email: string | null, jobTitle: string | null, lightning_address: string | null, website: string | null, twitter: string | null, github: string | null, linkedin: string | null, bio: string | null, location: string | null, stories: Array<{ __typename?: 'Story', id: number, title: string, createdAt: any, tags: Array<{ __typename?: 'Tag', id: number, title: string, icon: string | null }> }>, tournaments: Array<{ __typename?: 'Tournament', id: number, title: string, thumbnail_image: string, start_date: any, end_date: any }>, similar_makers: Array<{ __typename?: 'User', id: number, name: string, avatar: string, jobTitle: string | null }>, skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }>, roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }> } | null }; export type CategoryPageQueryVariables = Exact<{ categoryId: Scalars['Int']; @@ -741,7 +753,38 @@ export type ConfirmVoteMutationVariables = Exact<{ export type ConfirmVoteMutation = { __typename?: 'Mutation', confirmVote: { __typename?: 'Vote', id: number, amount_in_sat: number, payment_request: string, payment_hash: string, paid: boolean, item_type: Vote_Item_Type, item_id: number } }; - +export const UserBasicInfoFragmentDoc = gql` + fragment UserBasicInfo on BaseUser { + id + name + avatar + join_date + role + email + jobTitle + lightning_address + website + twitter + github + linkedin + bio + location +} + `; +export const UserRolesSkillsFragmentDoc = gql` + fragment UserRolesSkills on BaseUser { + skills { + id + title + } + roles { + id + title + icon + level + } +} + `; export const OfficialTagsDocument = gql` query OfficialTags { officialTags { @@ -1474,6 +1517,73 @@ export function usePostDetailsLazyQuery(baseOptions?: Apollo.LazyQueryHookOption export type PostDetailsQueryHookResult = ReturnType; export type PostDetailsLazyQueryHookResult = ReturnType; export type PostDetailsQueryResult = Apollo.QueryResult; +export const MyProfileAboutDocument = gql` + query MyProfileAbout { + me { + ...UserBasicInfo + } +} + ${UserBasicInfoFragmentDoc}`; + +/** + * __useMyProfileAboutQuery__ + * + * To run a query within a React component, call `useMyProfileAboutQuery` and pass it any options that fit your needs. + * When your component renders, `useMyProfileAboutQuery` 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 } = useMyProfileAboutQuery({ + * variables: { + * }, + * }); + */ +export function useMyProfileAboutQuery(baseOptions?: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(MyProfileAboutDocument, options); + } +export function useMyProfileAboutLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(MyProfileAboutDocument, options); + } +export type MyProfileAboutQueryHookResult = ReturnType; +export type MyProfileAboutLazyQueryHookResult = ReturnType; +export type MyProfileAboutQueryResult = Apollo.QueryResult; +export const UpdateProfileAboutDocument = gql` + mutation updateProfileAbout($data: ProfileDetailsInput) { + updateProfileDetails(data: $data) { + ...UserBasicInfo + } +} + ${UserBasicInfoFragmentDoc}`; +export type UpdateProfileAboutMutationFn = Apollo.MutationFunction; + +/** + * __useUpdateProfileAboutMutation__ + * + * To run a mutation, you first call `useUpdateProfileAboutMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useUpdateProfileAboutMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [updateProfileAboutMutation, { data, loading, error }] = useUpdateProfileAboutMutation({ + * variables: { + * data: // value for 'data' + * }, + * }); + */ +export function useUpdateProfileAboutMutation(baseOptions?: Apollo.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useMutation(UpdateProfileAboutDocument, options); + } +export type UpdateProfileAboutMutationHookResult = ReturnType; +export type UpdateProfileAboutMutationResult = Apollo.MutationResult; +export type UpdateProfileAboutMutationOptions = Apollo.BaseMutationOptions; export const MyProfilePreferencesDocument = gql` query MyProfilePreferences { me { @@ -1557,16 +1667,7 @@ export const MyProfileRolesSkillsDocument = gql` query MyProfileRolesSkills { me { id - skills { - id - title - } - roles { - id - title - icon - level - } + ...UserRolesSkills } getAllMakersRoles { id @@ -1578,7 +1679,7 @@ export const MyProfileRolesSkillsDocument = gql` title } } - `; + ${UserRolesSkillsFragmentDoc}`; /** * __useMyProfileRolesSkillsQuery__ @@ -1649,116 +1750,9 @@ export function useUpdateUserRolesSkillsMutation(baseOptions?: Apollo.MutationHo export type UpdateUserRolesSkillsMutationHookResult = ReturnType; export type UpdateUserRolesSkillsMutationResult = Apollo.MutationResult; export type UpdateUserRolesSkillsMutationOptions = Apollo.BaseMutationOptions; -export const MyProfileAboutDocument = gql` - query MyProfileAbout { - me { - id - name - avatar - join_date - role - email - jobTitle - lightning_address - website - twitter - github - linkedin - bio - location - } -} - `; - -/** - * __useMyProfileAboutQuery__ - * - * To run a query within a React component, call `useMyProfileAboutQuery` and pass it any options that fit your needs. - * When your component renders, `useMyProfileAboutQuery` 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 } = useMyProfileAboutQuery({ - * variables: { - * }, - * }); - */ -export function useMyProfileAboutQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(MyProfileAboutDocument, options); - } -export function useMyProfileAboutLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(MyProfileAboutDocument, options); - } -export type MyProfileAboutQueryHookResult = ReturnType; -export type MyProfileAboutLazyQueryHookResult = ReturnType; -export type MyProfileAboutQueryResult = Apollo.QueryResult; -export const UpdateProfileAboutDocument = gql` - mutation updateProfileAbout($data: ProfileDetailsInput) { - updateProfileDetails(data: $data) { - id - name - avatar - join_date - role - email - jobTitle - lightning_address - website - twitter - github - linkedin - bio - location - } -} - `; -export type UpdateProfileAboutMutationFn = Apollo.MutationFunction; - -/** - * __useUpdateProfileAboutMutation__ - * - * To run a mutation, you first call `useUpdateProfileAboutMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useUpdateProfileAboutMutation` returns a tuple that includes: - * - A mutate function that you can call at any time to execute the mutation - * - An object with fields that represent the current status of the mutation's execution - * - * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; - * - * @example - * const [updateProfileAboutMutation, { data, loading, error }] = useUpdateProfileAboutMutation({ - * variables: { - * data: // value for 'data' - * }, - * }); - */ -export function useUpdateProfileAboutMutation(baseOptions?: Apollo.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(UpdateProfileAboutDocument, options); - } -export type UpdateProfileAboutMutationHookResult = ReturnType; -export type UpdateProfileAboutMutationResult = Apollo.MutationResult; -export type UpdateProfileAboutMutationOptions = Apollo.BaseMutationOptions; export const ProfileDocument = gql` query profile($profileId: Int!) { profile(id: $profileId) { - id - name - avatar - join_date - role - email - jobTitle - lightning_address - website - twitter - github - linkedin - bio - location stories { id title @@ -1769,16 +1763,6 @@ export const ProfileDocument = gql` icon } } - skills { - id - title - } - roles { - id - title - icon - level - } tournaments { id title @@ -1792,9 +1776,12 @@ export const ProfileDocument = gql` avatar jobTitle } + ...UserBasicInfo + ...UserRolesSkills } } - `; + ${UserBasicInfoFragmentDoc} +${UserRolesSkillsFragmentDoc}`; /** * __useProfileQuery__ diff --git a/src/utils/apollo.ts b/src/utils/apollo.ts index aac1f1e..55abc16 100644 --- a/src/utils/apollo.ts +++ b/src/utils/apollo.ts @@ -49,6 +49,9 @@ export const apolloClient = new ApolloClient({ httpLink ]), cache: new InMemoryCache({ + possibleTypes: { + BaseUser: ['User', 'MyProfile'] + }, typePolicies: { Query: { fields: {