guesstimate/client/src/gql/queries/user.tsx

25 lines
557 B
TypeScript

import { gql, useQuery } from '@apollo/client';
import { User } from '../../types/user';
import { useGraphQLData } from './helper';
export const QUERY_CURRENT_USER = gql`
query userProfile {
currentUser {
id,
name,
email,
createdAt,
connectedAt
}
}`;
export function useUserProfileQuery() {
return useQuery(QUERY_CURRENT_USER);
}
export function useUserProfile() {
const { data, loading, error } = useGraphQLData<User>(
QUERY_CURRENT_USER, 'currentUser', {id: '', email: ''}
);
return { user: data, loading, error };
}