Ajout types génériques pour autocomplétion

This commit is contained in:
2020-09-10 19:25:52 +02:00
parent 04b32772fc
commit 6845e1ce50
5 changed files with 16 additions and 16 deletions

View File

@ -1,4 +1,4 @@
import { gql, useQuery } from '@apollo/client';
import { gql, useQuery, QueryHookOptions } from '@apollo/client';
import { User } from '../../types/user';
import { useState, useEffect } from 'react';
import { useGraphQLData } from './helper';
@ -14,13 +14,13 @@ query userProfile {
}
}`;
export function useUserProfileQuery() {
return useQuery(QUERY_USER_PROFILE);
export function useUserProfileQuery<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
return useQuery(QUERY_USER_PROFILE, options);
}
export function useUserProfile() {
export function useUserProfile<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
const { data, loading, error } = useGraphQLData<User>(
QUERY_USER_PROFILE, 'userProfile', {id: '', email: ''}
QUERY_USER_PROFILE, 'userProfile', {id: '', email: ''}, options
);
return { user: data, loading, error };
}