mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 04:51:35 +03:00
24592a516b
* Pass environment variables around as a data structure, via @sordina * Resolving build error * Adding Environment passing note to changelog * Removing references to ILTPollerLog as this seems to have been reintroduced from a bad merge * removing commented-out imports * Language pragmas already set by project * Linking async thread * Apply suggestions from code review Use `runQueryTx` instead of `runLazyTx` for queries. * remove the non-user facing entry in the changelog Co-authored-by: Phil Freeman <paf31@cantab.net> Co-authored-by: Phil Freeman <phil@hasura.io> Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
36 lines
877 B
Haskell
36 lines
877 B
Haskell
{-# LANGUAGE DeriveGeneric #-}
|
|
|
|
module Data.Environment
|
|
( Environment()
|
|
, getEnvironment
|
|
, mkEnvironment
|
|
, emptyEnvironment
|
|
, maybeEnvironment
|
|
, lookupEnv)
|
|
where
|
|
|
|
import Hasura.Prelude
|
|
import Data.Aeson
|
|
|
|
import qualified System.Environment
|
|
import qualified Data.Map as M
|
|
|
|
newtype Environment = Environment (M.Map String String) deriving (Eq, Show, Generic)
|
|
|
|
instance FromJSON Environment
|
|
|
|
getEnvironment :: IO Environment
|
|
getEnvironment = mkEnvironment <$> System.Environment.getEnvironment
|
|
|
|
maybeEnvironment :: Maybe Environment -> Environment
|
|
maybeEnvironment = fromMaybe emptyEnvironment
|
|
|
|
mkEnvironment :: [(String, String)] -> Environment
|
|
mkEnvironment = Environment . M.fromList
|
|
|
|
emptyEnvironment :: Environment
|
|
emptyEnvironment = Environment M.empty
|
|
|
|
lookupEnv :: Environment -> String -> Maybe String
|
|
lookupEnv (Environment es) k = M.lookup k es
|