mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 12:31:52 +03:00
921bdf709b
https://github.com/hasura/graphql-engine-mono/pull/1517 Co-authored-by: Sibi Prabakaran <737477+psibi@users.noreply.github.com> Co-authored-by: Chris Done <11019+chrisdone@users.noreply.github.com> Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com> GitOrigin-RevId: e0f61664b33d8ca50f223ec7fb76c66940eabc89
27 lines
935 B
Haskell
27 lines
935 B
Haskell
module Hasura.Backends.MySQL.Connection where
|
|
|
|
|
|
import Data.Pool (createPool)
|
|
import qualified Data.Text as T
|
|
import Database.MySQL.Base
|
|
import Hasura.Backends.MySQL.Types
|
|
import Hasura.Base.Error
|
|
import Hasura.Prelude
|
|
import Hasura.RQL.Types.Common
|
|
|
|
|
|
resolveSourceConfig :: (MonadIO m) =>
|
|
SourceName -> ConnSourceConfig -> m (Either QErr SourceConfig)
|
|
resolveSourceConfig _name csc@ConnSourceConfig{..} =
|
|
let connectInfo =
|
|
defaultConnectInfo
|
|
{ connectHost = T.unpack _cscHost
|
|
, connectPort = _cscPort
|
|
, connectUser = T.unpack _cscUser
|
|
, connectPassword = T.unpack _cscPassword
|
|
, connectDatabase = T.unpack _cscDatabase
|
|
}
|
|
in runExceptT $
|
|
SourceConfig csc <$>
|
|
liftIO (createPool (connect connectInfo) close 1 (60 {-seconds-} * 60 {-minutes-}) 1)
|