Files
twenty_crm/packages/twenty-front/src/modules/databases/hooks/useUpdateOneDatabaseConnection.ts
Marie 1b2ed80c1c [feat][Remote objects] Edit a connection (for pg) (#5210)
## Context
#4774 

## How was it tested
Locally

## In further PRs
- Update connection status upon page change
- Adapt Info banner to dark mode
- placeholders for form
2024-04-30 17:46:30 +02:00

35 lines
932 B
TypeScript

import { ApolloClient, useMutation } from '@apollo/client';
import { UPDATE_ONE_DATABASE_CONNECTION } from '@/databases/graphql/mutations/updateOneDatabaseConnection';
import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';
import {
UpdateRemoteServerInput,
UpdateServerMutation,
UpdateServerMutationVariables,
} from '~/generated-metadata/graphql';
export const useUpdateOneDatabaseConnection = () => {
const apolloMetadataClient = useApolloMetadataClient();
const [mutate] = useMutation<
UpdateServerMutation,
UpdateServerMutationVariables
>(UPDATE_ONE_DATABASE_CONNECTION, {
client: apolloMetadataClient ?? ({} as ApolloClient<any>),
});
const updateOneDatabaseConnection = async (
input: UpdateRemoteServerInput,
) => {
return await mutate({
variables: {
input,
},
});
};
return {
updateOneDatabaseConnection,
};
};