Logic function refactorization (#17861)

As title
This commit is contained in:
martmull
2026-02-12 11:40:49 +01:00
committed by GitHub
parent b456f79167
commit a4ed043d43
122 changed files with 1441 additions and 1897 deletions
@@ -1,7 +1,5 @@
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
import { GET_LOGIC_FUNCTION_SOURCE_CODE } from '@/logic-functions/graphql/queries/getLogicFunctionSourceCode';
import { useQuery } from '@apollo/client';
import { type Sources } from 'twenty-shared/types';
import {
type GetLogicFunctionSourceCodeQuery,
type GetLogicFunctionSourceCodeQueryVariables,
@@ -11,24 +9,16 @@ export const useGetLogicFunctionSourceCode = ({
logicFunctionId,
}: {
logicFunctionId: string;
}): { code: Sources | null; loading: boolean } => {
const apolloMetadataClient = useApolloCoreClient();
}) => {
const { data, loading } = useQuery<
GetLogicFunctionSourceCodeQuery,
GetLogicFunctionSourceCodeQueryVariables
>(GET_LOGIC_FUNCTION_SOURCE_CODE, {
client: apolloMetadataClient ?? undefined,
variables: {
input: { id: logicFunctionId },
},
skip: !logicFunctionId,
});
const raw = data?.getLogicFunctionSourceCode;
const code =
raw != null && typeof raw === 'object' && !Array.isArray(raw)
? (raw as Sources)
: null;
return { code, loading };
return { code: data?.getLogicFunctionSourceCode, loading };
};