Use main apollo client for workflows (#9675)
We were using metadata client by legacy. Architecture is not great for Core engine: workflows are available both in data and metadata client. It makes more sense to use the data client since workflows are part of standard objects
This commit is contained in:
@ -6,10 +6,7 @@ import { useComputeStepOutputSchema } from '../useComputeStepOutputSchema';
|
|||||||
jest.mock('@apollo/client', () => ({
|
jest.mock('@apollo/client', () => ({
|
||||||
...jest.requireActual('@apollo/client'),
|
...jest.requireActual('@apollo/client'),
|
||||||
useMutation: jest.fn(),
|
useMutation: jest.fn(),
|
||||||
}));
|
useApolloClient: () => ({}),
|
||||||
|
|
||||||
jest.mock('@/object-metadata/hooks/useApolloMetadataClient', () => ({
|
|
||||||
useApolloMetadataClient: () => ({}),
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('useComputeStepOutputSchema', () => {
|
describe('useComputeStepOutputSchema', () => {
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
|
||||||
import { useApolloClient, useMutation } from '@apollo/client';
|
import { useApolloClient, useMutation } from '@apollo/client';
|
||||||
|
|
||||||
import { triggerUpdateRecordOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffect';
|
import { triggerUpdateRecordOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffect';
|
||||||
@ -13,13 +12,12 @@ import {
|
|||||||
} from '~/generated/graphql';
|
} from '~/generated/graphql';
|
||||||
|
|
||||||
export const useActivateWorkflowVersion = () => {
|
export const useActivateWorkflowVersion = () => {
|
||||||
const apolloMetadataClient = useApolloMetadataClient();
|
|
||||||
const apolloClient = useApolloClient();
|
const apolloClient = useApolloClient();
|
||||||
const [mutate] = useMutation<
|
const [mutate] = useMutation<
|
||||||
ActivateWorkflowVersionMutation,
|
ActivateWorkflowVersionMutation,
|
||||||
ActivateWorkflowVersionMutationVariables
|
ActivateWorkflowVersionMutationVariables
|
||||||
>(ACTIVATE_WORKFLOW_VERSION, {
|
>(ACTIVATE_WORKFLOW_VERSION, {
|
||||||
client: apolloMetadataClient,
|
client: apolloClient,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { objectMetadataItem: objectMetadataItemWorkflowVersion } =
|
const { objectMetadataItem: objectMetadataItemWorkflowVersion } =
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
|
||||||
import { COMPUTE_STEP_OUTPUT_SCHEMA } from '@/workflow/graphql/mutations/computeStepOutputSchema';
|
import { COMPUTE_STEP_OUTPUT_SCHEMA } from '@/workflow/graphql/mutations/computeStepOutputSchema';
|
||||||
import { useMutation } from '@apollo/client';
|
import { useApolloClient, useMutation } from '@apollo/client';
|
||||||
import {
|
import {
|
||||||
ComputeStepOutputSchemaInput,
|
ComputeStepOutputSchemaInput,
|
||||||
ComputeStepOutputSchemaMutation,
|
ComputeStepOutputSchemaMutation,
|
||||||
@ -8,12 +7,12 @@ import {
|
|||||||
} from '~/generated/graphql';
|
} from '~/generated/graphql';
|
||||||
|
|
||||||
export const useComputeStepOutputSchema = () => {
|
export const useComputeStepOutputSchema = () => {
|
||||||
const apolloMetadataClient = useApolloMetadataClient();
|
const apolloClient = useApolloClient();
|
||||||
const [mutate] = useMutation<
|
const [mutate] = useMutation<
|
||||||
ComputeStepOutputSchemaMutation,
|
ComputeStepOutputSchemaMutation,
|
||||||
ComputeStepOutputSchemaMutationVariables
|
ComputeStepOutputSchemaMutationVariables
|
||||||
>(COMPUTE_STEP_OUTPUT_SCHEMA, {
|
>(COMPUTE_STEP_OUTPUT_SCHEMA, {
|
||||||
client: apolloMetadataClient,
|
client: apolloClient,
|
||||||
});
|
});
|
||||||
|
|
||||||
const computeStepOutputSchema = async (
|
const computeStepOutputSchema = async (
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
|
||||||
import { useApolloClient, useMutation } from '@apollo/client';
|
import { useApolloClient, useMutation } from '@apollo/client';
|
||||||
|
|
||||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||||
@ -11,13 +10,12 @@ import {
|
|||||||
} from '~/generated/graphql';
|
} from '~/generated/graphql';
|
||||||
|
|
||||||
export const useDeactivateWorkflowVersion = () => {
|
export const useDeactivateWorkflowVersion = () => {
|
||||||
const apolloMetadataClient = useApolloMetadataClient();
|
|
||||||
const apolloClient = useApolloClient();
|
const apolloClient = useApolloClient();
|
||||||
const [mutate] = useMutation<
|
const [mutate] = useMutation<
|
||||||
ActivateWorkflowVersionMutation,
|
ActivateWorkflowVersionMutation,
|
||||||
ActivateWorkflowVersionMutationVariables
|
ActivateWorkflowVersionMutationVariables
|
||||||
>(DEACTIVATE_WORKFLOW_VERSION, {
|
>(DEACTIVATE_WORKFLOW_VERSION, {
|
||||||
client: apolloMetadataClient,
|
client: apolloClient,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { objectMetadataItem: objectMetadataItemWorkflowVersion } =
|
const { objectMetadataItem: objectMetadataItemWorkflowVersion } =
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
|
|
||||||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
import { RUN_WORKFLOW_VERSION } from '@/workflow/graphql/mutations/runWorkflowVersion';
|
import { RUN_WORKFLOW_VERSION } from '@/workflow/graphql/mutations/runWorkflowVersion';
|
||||||
import { useMutation } from '@apollo/client';
|
import { useApolloClient, useMutation } from '@apollo/client';
|
||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
import { capitalize } from 'twenty-shared';
|
import { capitalize } from 'twenty-shared';
|
||||||
import { IconSettingsAutomation } from 'twenty-ui';
|
import { IconSettingsAutomation } from 'twenty-ui';
|
||||||
@ -12,12 +11,12 @@ import {
|
|||||||
} from '~/generated/graphql';
|
} from '~/generated/graphql';
|
||||||
|
|
||||||
export const useRunWorkflowVersion = () => {
|
export const useRunWorkflowVersion = () => {
|
||||||
const apolloMetadataClient = useApolloMetadataClient();
|
const apolloClient = useApolloClient();
|
||||||
const [mutate] = useMutation<
|
const [mutate] = useMutation<
|
||||||
RunWorkflowVersionMutation,
|
RunWorkflowVersionMutation,
|
||||||
RunWorkflowVersionMutationVariables
|
RunWorkflowVersionMutationVariables
|
||||||
>(RUN_WORKFLOW_VERSION, {
|
>(RUN_WORKFLOW_VERSION, {
|
||||||
client: apolloMetadataClient,
|
client: apolloClient,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { enqueueSnackBar } = useSnackBar();
|
const { enqueueSnackBar } = useSnackBar();
|
||||||
|
|||||||
Reference in New Issue
Block a user