Forcer l'utilisation du réseau pour les requêtes d'autorisation

This commit is contained in:
wpetit 2020-10-05 17:03:01 +02:00
parent 89a147565c
commit 7a6eedab9d
1 changed files with 6 additions and 0 deletions

View File

@ -8,10 +8,16 @@ export const QUERY_IS_AUTHORIZED = gql`
`;
export function useIsAuthorizedQuery<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
options = Object.assign({
fetchPolicy: 'cache-and-network'
}, options);
return useQuery(QUERY_IS_AUTHORIZED, options);
}
export function useIsAuthorized<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}, defaultValue = false) {
options = Object.assign({
fetchPolicy: 'cache-and-network'
}, options);
const { data, loading, error } = useGraphQLData<boolean>(
QUERY_IS_AUTHORIZED, 'isAuthorized', defaultValue, options
);