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,24 +1,25 @@
import { useApolloClient, useMutation } from '@apollo/client';
import { useMutation } from '@apollo/client';
import { triggerUpdateRecordOptimisticEffect } from '@/apollo/optimistic-effect/utils/triggerUpdateRecordOptimisticEffect';
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { modifyRecordFromCache } from '@/object-record/cache/utils/modifyRecordFromCache';
import { ACTIVATE_WORKFLOW_VERSION } from '@/workflow/graphql/mutations/activateWorkflowVersion';
import { WorkflowVersion } from '@/workflow/types/Workflow';
import { isDefined } from 'twenty-shared/utils';
import {
ActivateWorkflowVersionMutation,
ActivateWorkflowVersionMutationVariables,
} from '~/generated/graphql';
import { isDefined } from 'twenty-shared/utils';
} from '~/generated-metadata/graphql';
export const useActivateWorkflowVersion = () => {
const apolloClient = useApolloClient();
const apolloCoreClient = useApolloCoreClient();
const [mutate] = useMutation<
ActivateWorkflowVersionMutation,
ActivateWorkflowVersionMutationVariables
>(ACTIVATE_WORKFLOW_VERSION, {
client: apolloClient,
client: apolloCoreClient,
});
const { objectMetadataItem: objectMetadataItemWorkflowVersion } =
@@ -39,7 +40,7 @@ export const useActivateWorkflowVersion = () => {
},
update: () => {
modifyRecordFromCache({
cache: apolloClient.cache,
cache: apolloCoreClient.cache,
recordId: workflowVersionId,
objectMetadataItem: objectMetadataItemWorkflowVersion,
fieldModifiers: {
@@ -47,7 +48,7 @@ export const useActivateWorkflowVersion = () => {
},
});
const cacheSnapshot = apolloClient.cache.extract();
const cacheSnapshot = apolloCoreClient.cache.extract();
const allWorkflowVersions: Array<WorkflowVersion> = Object.values(
cacheSnapshot,
).filter(
@@ -67,7 +68,7 @@ export const useActivateWorkflowVersion = () => {
if (isDefined(newlyActiveWorkflowVersion)) {
triggerUpdateRecordOptimisticEffect({
cache: apolloClient.cache,
cache: apolloCoreClient.cache,
objectMetadataItem: objectMetadataItemWorkflowVersion,
currentRecord: newlyActiveWorkflowVersion,
updatedRecord: {
@@ -79,8 +80,8 @@ export const useActivateWorkflowVersion = () => {
}
for (const workflowVersion of previousActiveWorkflowVersions) {
apolloClient.cache.modify({
id: apolloClient.cache.identify(workflowVersion),
apolloCoreClient.cache.modify({
id: apolloCoreClient.cache.identify(workflowVersion),
fields: {
status: () => {
return workflowVersion.id !== workflowVersionId &&
@@ -92,7 +93,7 @@ export const useActivateWorkflowVersion = () => {
});
triggerUpdateRecordOptimisticEffect({
cache: apolloClient.cache,
cache: apolloCoreClient.cache,
objectMetadataItem: objectMetadataItemWorkflowVersion,
currentRecord: workflowVersion,
updatedRecord: {