2020-07-21 22:25:39 +02:00
|
|
|
import { gql, useQuery } from '@apollo/client';
|
2020-07-31 17:36:10 +02:00
|
|
|
import { User } from '../../types/user';
|
|
|
|
import { useState, useEffect } from 'react';
|
|
|
|
import { useGraphQLData } from './helper';
|
2020-07-21 22:25:39 +02:00
|
|
|
|
2020-07-31 18:04:31 +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);
|
2020-07-31 17:36:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|