mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 20:41:49 +03:00
e9f85ce6e6
GitOrigin-RevId: c1a6509f19a903724ce2b770ae23cbd925b537f8
44 lines
1.2 KiB
Haskell
44 lines
1.2 KiB
Haskell
module Hasura.Backends.MSSQL.DDL.Source
|
|
( resolveSourceConfig
|
|
, resolveDatabaseMetadata
|
|
, postDropSourceHook
|
|
)
|
|
where
|
|
|
|
import Hasura.Prelude
|
|
|
|
import Hasura.Backends.MSSQL.Connection
|
|
import Hasura.Backends.MSSQL.Meta
|
|
import Hasura.RQL.Types.Common
|
|
import Hasura.RQL.Types.Error
|
|
import Hasura.RQL.Types.Source
|
|
import Hasura.SQL.Backend
|
|
|
|
resolveSourceConfig
|
|
:: (MonadIO m)
|
|
=> SourceName
|
|
-> MSSQLConnConfiguration
|
|
-> m (Either QErr MSSQLSourceConfig)
|
|
resolveSourceConfig _name (MSSQLConnConfiguration connInfo) = do
|
|
mssqlPool <- liftIO $ createMSSQLPool connInfo
|
|
pure $ Right $ MSSQLSourceConfig connString mssqlPool
|
|
where
|
|
connString = _mciConnectionString connInfo
|
|
|
|
resolveDatabaseMetadata
|
|
:: (MonadIO m)
|
|
=> MSSQLSourceConfig
|
|
-> m (Either QErr (ResolvedSource 'MSSQL))
|
|
resolveDatabaseMetadata config = runExceptT do
|
|
dbTablesMetadata <- loadDBMetadata pool
|
|
pure $ ResolvedSource config dbTablesMetadata mempty mempty
|
|
where
|
|
MSSQLSourceConfig _connString pool = config
|
|
|
|
postDropSourceHook
|
|
:: (MonadIO m)
|
|
=> MSSQLSourceConfig -> m ()
|
|
postDropSourceHook (MSSQLSourceConfig _ pool) =
|
|
-- Close the connection
|
|
liftIO $ drainMSSQLPool pool
|