d2ddd6f473
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.
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { useQuery, WatchQueryFetchPolicy } from '@apollo/client';
|
|
|
|
import { GET_MANY_REMOTE_TABLES } from '@/databases/graphql/queries/findManyRemoteTables';
|
|
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
|
import {
|
|
GetManyRemoteTablesQuery,
|
|
GetManyRemoteTablesQueryVariables,
|
|
} from '~/generated-metadata/graphql';
|
|
|
|
type UseGetDatabaseConnectionTablesParams = {
|
|
connectionId: string;
|
|
skip?: boolean;
|
|
shouldFetchPendingSchemaUpdates?: boolean;
|
|
fetchPolicy?: WatchQueryFetchPolicy;
|
|
};
|
|
|
|
export const useGetDatabaseConnectionTables = ({
|
|
connectionId,
|
|
skip,
|
|
shouldFetchPendingSchemaUpdates,
|
|
fetchPolicy,
|
|
}: UseGetDatabaseConnectionTablesParams) => {
|
|
const apolloMetadataClient = useApolloCoreClient();
|
|
|
|
const fetchPolicyOption = fetchPolicy ? { fetchPolicy: fetchPolicy } : {};
|
|
|
|
const { data, error } = useQuery<
|
|
GetManyRemoteTablesQuery,
|
|
GetManyRemoteTablesQueryVariables
|
|
>(GET_MANY_REMOTE_TABLES, {
|
|
client: apolloMetadataClient ?? undefined,
|
|
skip: skip || !apolloMetadataClient,
|
|
variables: {
|
|
input: {
|
|
id: connectionId,
|
|
shouldFetchPendingSchemaUpdates,
|
|
},
|
|
},
|
|
...fetchPolicyOption,
|
|
});
|
|
|
|
return {
|
|
tables: data?.findDistantTablesWithStatus || [],
|
|
error,
|
|
};
|
|
};
|