daddy/client/src/gql/queries/profile.tsx

26 lines
602 B
TypeScript
Raw Normal View History

2020-07-21 22:25:39 +02:00
import { gql, useQuery } from '@apollo/client';
import { User } from '../../types/user';
import { useState, useEffect } from 'react';
import { useGraphQLData } from './helper';
2020-07-21 22:25:39 +02:00
export const QUERY_USER_PROFILE = gql`
2020-07-21 22:25:39 +02:00
query userProfile {
userProfile {
id,
name,
email,
createdAt,
connectedAt
}
}`;
export function useUserProfileQuery() {
2020-07-22 09:18:50 +02:00
return useQuery(QUERY_USER_PROFILE);
}
export function useUserProfile() {
const { data, loading, error } = useGraphQLData<User>(
QUERY_USER_PROFILE, 'userProfile', {id: '', email: ''}
);
return { user: data, loading, error };
2020-07-21 22:25:39 +02:00
}