Separate system operations from core objects in GraphQL endpoints (#12977)

Moves system-level operations (auth, billing, admin) to use the
/metadata endpoint instead of /graphql.

This cleans up the endpoint separation so /graphql is purely for core
objects (Company, People, etc.) and /metadata handles all system
operations.

Part of prep work for webhook/API key core migration.
This commit is contained in:
nitin
2025-07-01 21:59:32 +05:30
committed by GitHub
parent 76c517aa29
commit d2ddd6f473
229 changed files with 9425 additions and 8804 deletions
@@ -1,3 +1,4 @@
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
@@ -6,16 +7,16 @@ import { updateRecordFromCache } from '@/object-record/cache/utils/updateRecordF
import { useObjectPermissions } from '@/object-record/hooks/useObjectPermissions';
import { CREATE_WORKFLOW_VERSION_STEP } from '@/workflow/graphql/mutations/createWorkflowVersionStep';
import { WorkflowVersion } from '@/workflow/types/Workflow';
import { useApolloClient, useMutation } from '@apollo/client';
import { useMutation } from '@apollo/client';
import { isDefined } from 'twenty-shared/utils';
import {
CreateWorkflowVersionStepInput,
CreateWorkflowVersionStepMutation,
CreateWorkflowVersionStepMutationVariables,
} from '~/generated/graphql';
} from '~/generated-metadata/graphql';
export const useCreateWorkflowVersionStep = () => {
const apolloClient = useApolloClient();
const apolloCoreClient = useApolloCoreClient();
const { objectMetadataItems } = useObjectMetadataItems();
const { objectPermissionsByObjectMetadataId } = useObjectPermissions();
const { objectMetadataItem } = useObjectMetadataItem({
@@ -28,7 +29,7 @@ export const useCreateWorkflowVersionStep = () => {
CreateWorkflowVersionStepMutation,
CreateWorkflowVersionStepMutationVariables
>(CREATE_WORKFLOW_VERSION_STEP, {
client: apolloClient,
client: apolloCoreClient,
});
const createWorkflowVersionStep = async (
input: CreateWorkflowVersionStepInput,
@@ -83,7 +84,7 @@ export const useCreateWorkflowVersionStep = () => {
updateRecordFromCache({
objectMetadataItems,
objectMetadataItem,
cache: apolloClient.cache,
cache: apolloCoreClient.cache,
record: newCachedRecord,
recordGqlFields,
objectPermissionsByObjectMetadataId,
@@ -1,3 +1,4 @@
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
@@ -6,17 +7,17 @@ import { updateRecordFromCache } from '@/object-record/cache/utils/updateRecordF
import { useObjectPermissions } from '@/object-record/hooks/useObjectPermissions';
import { UPDATE_WORKFLOW_RUN_STEP } from '@/workflow/graphql/mutations/updateWorkflowRunStep';
import { WorkflowRun } from '@/workflow/types/Workflow';
import { useApolloClient, useMutation } from '@apollo/client';
import { useMutation } from '@apollo/client';
import { isDefined } from 'twenty-shared/utils';
import {
UpdateWorkflowRunStepInput,
UpdateWorkflowRunStepMutation,
UpdateWorkflowRunStepMutationVariables,
WorkflowAction,
} from '~/generated/graphql';
} from '~/generated-metadata/graphql';
export const useUpdateWorkflowRunStep = () => {
const apolloClient = useApolloClient();
const apolloCoreClient = useApolloCoreClient();
const { objectMetadataItems } = useObjectMetadataItems();
const { objectMetadataItem } = useObjectMetadataItem({
objectNameSingular: CoreObjectNameSingular.WorkflowRun,
@@ -26,7 +27,7 @@ export const useUpdateWorkflowRunStep = () => {
UpdateWorkflowRunStepMutation,
UpdateWorkflowRunStepMutationVariables
>(UPDATE_WORKFLOW_RUN_STEP, {
client: apolloClient,
client: apolloCoreClient,
});
const getRecordFromCache = useGetRecordFromCache({
@@ -75,7 +76,7 @@ export const useUpdateWorkflowRunStep = () => {
updateRecordFromCache({
objectMetadataItems,
objectMetadataItem,
cache: apolloClient.cache,
cache: apolloCoreClient.cache,
record: newCachedRecord,
recordGqlFields,
objectPermissionsByObjectMetadataId,
@@ -1,3 +1,4 @@
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
@@ -6,17 +7,17 @@ import { updateRecordFromCache } from '@/object-record/cache/utils/updateRecordF
import { useObjectPermissions } from '@/object-record/hooks/useObjectPermissions';
import { UPDATE_WORKFLOW_VERSION_STEP } from '@/workflow/graphql/mutations/updateWorkflowVersionStep';
import { WorkflowVersion } from '@/workflow/types/Workflow';
import { useApolloClient, useMutation } from '@apollo/client';
import { useMutation } from '@apollo/client';
import { isDefined } from 'twenty-shared/utils';
import {
UpdateWorkflowVersionStepInput,
UpdateWorkflowVersionStepMutation,
UpdateWorkflowVersionStepMutationVariables,
WorkflowAction,
} from '~/generated/graphql';
} from '~/generated-metadata/graphql';
export const useUpdateWorkflowVersionStep = () => {
const apolloClient = useApolloClient();
const apolloCoreClient = useApolloCoreClient();
const { objectMetadataItems } = useObjectMetadataItems();
const { objectPermissionsByObjectMetadataId } = useObjectPermissions();
@@ -30,7 +31,7 @@ export const useUpdateWorkflowVersionStep = () => {
UpdateWorkflowVersionStepMutation,
UpdateWorkflowVersionStepMutationVariables
>(UPDATE_WORKFLOW_VERSION_STEP, {
client: apolloClient,
client: apolloCoreClient,
});
const updateWorkflowVersionStep = async (
@@ -65,7 +66,7 @@ export const useUpdateWorkflowVersionStep = () => {
updateRecordFromCache({
objectMetadataItems,
objectMetadataItem,
cache: apolloClient.cache,
cache: apolloCoreClient.cache,
record: newCachedRecord,
recordGqlFields,
objectPermissionsByObjectMetadataId,
@@ -5,7 +5,7 @@ import {
useFindOneAgentQuery,
useGetRolesQuery,
useRemoveRoleFromAgentMutation,
} from '~/generated/graphql';
} from '~/generated-metadata/graphql';
export const useAgentRoleAssignment = (agentId: string) => {
const [workflowAiAgentSelectedRole, setWorkflowAiAgentSelectedRole] =
@@ -2,7 +2,7 @@ import { useMutation } from '@apollo/client';
import { useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
import { useDebouncedCallback } from 'use-debounce';
import { useFindOneAgentQuery } from '~/generated/graphql';
import { useFindOneAgentQuery } from '~/generated-metadata/graphql';
import { UPDATE_ONE_AGENT } from '../graphql/mutations/updateOneAgent';
type AgentFormValues = {
@@ -1,20 +1,21 @@
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useFindOneRecordQuery } from '@/object-record/hooks/useFindOneRecordQuery';
import { SUBMIT_FORM_STEP } from '@/workflow/workflow-steps/workflow-actions/form-action/graphql/mutations/submitFormStep';
import { useApolloClient, useMutation } from '@apollo/client';
import { useMutation } from '@apollo/client';
import {
SubmitFormStepInput,
SubmitFormStepMutation,
SubmitFormStepMutationVariables,
} from '~/generated/graphql';
} from '~/generated-metadata/graphql';
export const useSubmitFormStep = () => {
const apolloClient = useApolloClient();
const apolloCoreClient = useApolloCoreClient();
const [mutate] = useMutation<
SubmitFormStepMutation,
SubmitFormStepMutationVariables
>(SUBMIT_FORM_STEP, {
client: apolloClient,
client: apolloCoreClient,
});
const { findOneRecordQuery: findOneWorkflowRunQuery } = useFindOneRecordQuery(
@@ -1,7 +1,7 @@
import { CustomError } from '@/error-handler/CustomError';
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { WorkflowActionType } from '@/workflow/types/Workflow';
import { FieldMetadataType } from '~/generated/graphql';
import { FieldMetadataType } from '~/generated-metadata/graphql';
const COMMON_DISPLAYABLE_FIELD_TYPES = [
FieldMetadataType.TEXT,