graphql-engine/server/src-lib/Data/Environment.hs
Vamshi Surabhi 96104ec1a8 Revert "remote schema typename customisation"
This reverts the remote schema type customisation and namespacing feature temporarily as we test for certain conditions.

GitOrigin-RevId: f8ee97233da4597f703970c3998664c03582d8e7
2021-06-10 09:57:16 +00:00

42 lines
1.1 KiB
Haskell

module Data.Environment
( Environment()
, getEnvironment
, mkEnvironment
, emptyEnvironment
, maybeEnvironment
, lookupEnv
, redactEnv
, Data.Environment.toList
) where
import Data.Aeson
import Hasura.Prelude
import qualified Data.Map as M
import qualified System.Environment
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
toList :: Environment -> [(String, String)]
toList (Environment e) = M.toList e
redactEnv :: Environment -> Environment
redactEnv (Environment e) = Environment $ fmap (const "******") e