[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
This commit is contained in:
@ -7,6 +7,10 @@ export const DATABASE_CONNECTION_FRAGMENT = gql`
|
||||
foreignDataWrapperId
|
||||
foreignDataWrapperOptions
|
||||
foreignDataWrapperType
|
||||
userMappingOptions {
|
||||
username
|
||||
}
|
||||
updatedAt
|
||||
schema
|
||||
}
|
||||
`;
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
import { DATABASE_CONNECTION_FRAGMENT } from '@/databases/graphql/fragments/databaseConnectionFragment';
|
||||
|
||||
export const UPDATE_ONE_DATABASE_CONNECTION = gql`
|
||||
${DATABASE_CONNECTION_FRAGMENT}
|
||||
mutation updateServer($input: UpdateRemoteServerInput!) {
|
||||
updateOneRemoteServer(input: $input) {
|
||||
...RemoteServerFields
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -0,0 +1,34 @@
|
||||
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,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user