Files
twenty/packages/twenty-front/src/modules/databases/hooks/useDeleteOneDatabaseConnection.ts
T
nitin d2ddd6f473 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.
2025-07-01 18:29:32 +02:00

37 lines
1.1 KiB
TypeScript

import { useMutation } from '@apollo/client';
import { getOperationName } from '@apollo/client/utilities';
import { DELETE_ONE_DATABASE_CONNECTION } from '@/databases/graphql/mutations/deleteOneDatabaseConnection';
import { GET_MANY_DATABASE_CONNECTIONS } from '@/databases/graphql/queries/findManyDatabaseConnections';
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
import {
DeleteServerMutation,
DeleteServerMutationVariables,
RemoteServerIdInput,
} from '~/generated-metadata/graphql';
export const useDeleteOneDatabaseConnection = () => {
const apolloMetadataClient = useApolloCoreClient();
const [mutate] = useMutation<
DeleteServerMutation,
DeleteServerMutationVariables
>(DELETE_ONE_DATABASE_CONNECTION, {
client: apolloMetadataClient,
});
const deleteOneDatabaseConnection = async (input: RemoteServerIdInput) => {
return await mutate({
variables: {
input,
},
awaitRefetchQueries: true,
refetchQueries: [getOperationName(GET_MANY_DATABASE_CONNECTIONS) ?? ''],
});
};
return {
deleteOneDatabaseConnection,
};
};