mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-20 05:51:54 +03:00
08f1725698
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3286 GitOrigin-RevId: 0b37767e271dfa43d36fa7f7cc9928ba6a22964d
55 lines
1.7 KiB
Haskell
55 lines
1.7 KiB
Haskell
-- | MSSQL Source
|
|
--
|
|
-- Implements the Source related methods of the
|
|
-- 'Hasura.RQL.Types.Metadata.Backend.BackendMetadata' type class
|
|
-- for the MSSQL backend, which provides an interface for identifying the
|
|
-- MSSQL database instance (source) and manipulate it.
|
|
--
|
|
-- The actual instance is defined in "Hasura.Backends.MSSQL.Instances.Metadata".
|
|
module Hasura.Backends.MSSQL.DDL.Source
|
|
( resolveSourceConfig,
|
|
resolveDatabaseMetadata,
|
|
postDropSourceHook,
|
|
)
|
|
where
|
|
|
|
import Control.Monad.Trans.Control (MonadBaseControl)
|
|
import Data.Environment qualified as Env
|
|
import Hasura.Backends.MSSQL.Connection
|
|
import Hasura.Backends.MSSQL.Meta
|
|
import Hasura.Base.Error
|
|
import Hasura.Prelude
|
|
import Hasura.RQL.Types.Common
|
|
import Hasura.RQL.Types.Source
|
|
import Hasura.RQL.Types.SourceCustomization
|
|
import Hasura.SQL.Backend
|
|
|
|
resolveSourceConfig ::
|
|
(MonadIO m, MonadResolveSource m) =>
|
|
SourceName ->
|
|
MSSQLConnConfiguration ->
|
|
Env.Environment ->
|
|
m (Either QErr MSSQLSourceConfig)
|
|
resolveSourceConfig name config _env = runExceptT do
|
|
sourceResolver <- getMSSQLSourceResolver
|
|
liftEitherM $ liftIO $ sourceResolver name config
|
|
|
|
resolveDatabaseMetadata ::
|
|
(MonadIO m, MonadBaseControl IO m) =>
|
|
MSSQLSourceConfig ->
|
|
SourceTypeCustomization ->
|
|
m (Either QErr (ResolvedSource 'MSSQL))
|
|
resolveDatabaseMetadata config customization = runExceptT do
|
|
dbTablesMetadata <- mssqlRunReadOnly mssqlExecCtx $ loadDBMetadata
|
|
pure $ ResolvedSource config customization dbTablesMetadata mempty mempty
|
|
where
|
|
MSSQLSourceConfig _connString mssqlExecCtx = config
|
|
|
|
postDropSourceHook ::
|
|
(MonadIO m) =>
|
|
MSSQLSourceConfig ->
|
|
m ()
|
|
postDropSourceHook (MSSQLSourceConfig _ mssqlExecCtx) = do
|
|
-- Close the connection
|
|
liftIO $ mssqlDestroyConn mssqlExecCtx
|