mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-19 21:41:44 +03:00
49f40a44f0
## Description This PR fixes an oversight in the implementation of the resolvers of different backends. To implement resolution from environment variables, both MSSQL and BigQuery were directly fetching the process' environment variables, instead of using the careful curated set we thread from main. It was working just fine on OSS, but is failing on Cloud. This PR fixes this by adding an additional argument to `resolveSourceConfig`, to ensure that backends always use the correct set of variables. https://github.com/hasura/graphql-engine-mono/pull/1891 GitOrigin-RevId: 58644cab7d041a8bf4235e2acfe9cf71533a92a1
46 lines
1.3 KiB
Haskell
46 lines
1.3 KiB
Haskell
module Hasura.Backends.MSSQL.DDL.Source
|
|
( resolveSourceConfig
|
|
, resolveDatabaseMetadata
|
|
, postDropSourceHook
|
|
)
|
|
where
|
|
|
|
import Hasura.Prelude
|
|
|
|
import qualified Data.Environment as Env
|
|
|
|
import Hasura.Backends.MSSQL.Connection
|
|
import Hasura.Backends.MSSQL.Meta
|
|
import Hasura.Base.Error
|
|
import Hasura.RQL.Types.Common
|
|
import Hasura.RQL.Types.Source
|
|
import Hasura.SQL.Backend
|
|
|
|
|
|
resolveSourceConfig
|
|
:: (MonadIO m)
|
|
=> SourceName
|
|
-> MSSQLConnConfiguration
|
|
-> Env.Environment
|
|
-> m (Either QErr MSSQLSourceConfig)
|
|
resolveSourceConfig _name (MSSQLConnConfiguration connInfo) env = runExceptT do
|
|
(connString, mssqlPool) <- createMSSQLPool connInfo env
|
|
pure $ MSSQLSourceConfig connString mssqlPool
|
|
|
|
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
|