Ajout types génériques pour autocomplétion
This commit is contained in:
@ -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 };
|
||||
}
|
Reference in New Issue
Block a user