Files
automatisch/packages/web/src/hooks/useApps.ts
2023-09-29 17:03:36 +02:00

27 lines
514 B
TypeScript

import { useQuery } from '@apollo/client';
import { IApp } from '@automatisch/types';
import { GET_APPS } from 'graphql/queries/get-apps';
type QueryResponse = {
getApps: IApp[];
};
type UseAppsVariables = {
name?: string;
onlyWithTriggers?: boolean;
onlyWithActions?: boolean;
};
export default function useApps(variables?: UseAppsVariables) {
const { data, loading } = useQuery<QueryResponse>(GET_APPS, {
variables,
});
const apps = data?.getApps;
return {
apps,
loading,
};
}