From 6845e1ce503a194e12af510d568fb1450887af3d Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 10 Sep 2020 19:25:52 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20types=20g=C3=A9n=C3=A9riques=20pour=20a?= =?UTF-8?q?utocompl=C3=A9tion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/gql/queries/authorization.tsx | 6 +++--- client/src/gql/queries/dsf.tsx | 6 +++--- client/src/gql/queries/helper.ts | 4 ++-- client/src/gql/queries/profile.tsx | 10 +++++----- client/src/gql/queries/workgroups.tsx | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/client/src/gql/queries/authorization.tsx b/client/src/gql/queries/authorization.tsx index d78a813..31293ee 100644 --- a/client/src/gql/queries/authorization.tsx +++ b/client/src/gql/queries/authorization.tsx @@ -1,4 +1,4 @@ -import { gql, useQuery } from '@apollo/client'; +import { gql, useQuery, QueryHookOptions } from '@apollo/client'; import { useGraphQLData } from './helper'; export const QUERY_IS_AUTHORIZED = gql` @@ -7,11 +7,11 @@ export const QUERY_IS_AUTHORIZED = gql` } `; -export function useIsAuthorizedQuery(options = {}) { +export function useIsAuthorizedQuery>(options: QueryHookOptions = {}) { return useQuery(QUERY_IS_AUTHORIZED, options); } -export function useIsAuthorized(options = {}, defaultValue = false) { +export function useIsAuthorized>(options: QueryHookOptions = {}, defaultValue = false) { const { data, loading, error } = useGraphQLData( QUERY_IS_AUTHORIZED, 'isAuthorized', defaultValue, options ); diff --git a/client/src/gql/queries/dsf.tsx b/client/src/gql/queries/dsf.tsx index 0afbdcb..7eab481 100644 --- a/client/src/gql/queries/dsf.tsx +++ b/client/src/gql/queries/dsf.tsx @@ -1,4 +1,4 @@ -import { gql, useQuery } from '@apollo/client'; +import { gql, useQuery, QueryHookOptions } from '@apollo/client'; import { DecisionSupportFile } from '../../types/decision'; import { useGraphQLData } from './helper'; @@ -25,11 +25,11 @@ export const QUERY_DECISION_SUPPORT_FILES = gql` } `; -export function useDecisionSupportFilesQuery(options = {}) { +export function useDecisionSupportFilesQuery>(options: QueryHookOptions = {}) { return useQuery(QUERY_DECISION_SUPPORT_FILES, options); } -export function useDecisionSupportFiles(options = {}) { +export function useDecisionSupportFiles>(options: QueryHookOptions = {}) { const { data, loading, error } = useGraphQLData( QUERY_DECISION_SUPPORT_FILES, 'decisionSupportFiles', [], options ); diff --git a/client/src/gql/queries/helper.ts b/client/src/gql/queries/helper.ts index 586791a..0a42fb4 100644 --- a/client/src/gql/queries/helper.ts +++ b/client/src/gql/queries/helper.ts @@ -1,7 +1,7 @@ -import { useQuery, DocumentNode } from "@apollo/client"; +import { useQuery, DocumentNode, QueryHookOptions } from "@apollo/client"; import { useState, useEffect } from "react"; -export function useGraphQLData(q: DocumentNode, key: string, defaultValue: T, options = {}) { +export function useGraphQLData>(q: DocumentNode, key: string, defaultValue: T, options: QueryHookOptions = {}) { const query = useQuery(q, options); const [ data, setData ] = useState(defaultValue); useEffect(() => { diff --git a/client/src/gql/queries/profile.tsx b/client/src/gql/queries/profile.tsx index 3b79d41..c00b970 100644 --- a/client/src/gql/queries/profile.tsx +++ b/client/src/gql/queries/profile.tsx @@ -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>(options: QueryHookOptions = {}) { + return useQuery(QUERY_USER_PROFILE, options); } -export function useUserProfile() { +export function useUserProfile>(options: QueryHookOptions = {}) { const { data, loading, error } = useGraphQLData( - QUERY_USER_PROFILE, 'userProfile', {id: '', email: ''} + QUERY_USER_PROFILE, 'userProfile', {id: '', email: ''}, options ); return { user: data, loading, error }; } \ No newline at end of file diff --git a/client/src/gql/queries/workgroups.tsx b/client/src/gql/queries/workgroups.tsx index 00efc69..ce4b9ba 100644 --- a/client/src/gql/queries/workgroups.tsx +++ b/client/src/gql/queries/workgroups.tsx @@ -1,4 +1,4 @@ -import { gql, useQuery } from '@apollo/client'; +import { gql, useQuery, QueryHookOptions } from '@apollo/client'; import { Workgroup } from '../../types/workgroup'; import { useGraphQLData } from './helper'; @@ -18,11 +18,11 @@ export const QUERY_WORKGROUP = gql` } `; -export function useWorkgroupsQuery(options = {}) { +export function useWorkgroupsQuery>(options: QueryHookOptions = {}) { return useQuery(QUERY_WORKGROUP, options); } -export function useWorkgroups(options = {}) { +export function useWorkgroups>(options: QueryHookOptions = {}) { const { data, loading, error } = useGraphQLData( QUERY_WORKGROUP, 'workgroups', [], options