Repository: hasura/graphql-engine
File: server/src-lib/Hasura/Server/Init/Config.hs (Haskell)

Code before:
  , rsoConnParams            :: !RawConnParams
  , rsoTxIso                 :: !(Maybe Q.TxIsolation)
  , rsoAdminSecret           :: !(Maybe AdminSecretHash)
  , rsoAuthHook              :: !RawAuthHook
  , rsoJwtSecret             :: !(Maybe JWTConfig)
  , rsoUnAuthRole            :: !(Maybe RoleName)
  , rsoCorsConfig            :: !(Maybe CorsConfig)
  , rsoEnableConsole         :: !Bool
  , rsoConsoleAssetsDir      :: !(Maybe Text)
  , rsoEnableTelemetry       :: !(Maybe Bool)
  , rsoWsReadCookie          :: !Bool
  , rsoStringifyNum          :: !Bool
  , rsoEnabledAPIs           :: !(Maybe [API])
  , rsoMxRefetchInt          :: !(Maybe LQ.RefetchInterval)
  , rsoMxBatchSize           :: !(Maybe LQ.BatchSize)
  , rsoEnableAllowlist       :: !Bool
  , rsoEnabledLogTypes       :: !(Maybe [L.EngineLogType impl])
  , rsoLogLevel              :: !(Maybe L.LogLevel)
  , rsoPlanCacheSize         :: !(Maybe Cache.CacheSize)
  , rsoDevMode               :: !Bool
  , rsoAdminInternalErrors   :: !(Maybe Bool)
  , rsoEventsHttpPoolSize    :: !(Maybe Int)
  , rsoEventsFetchInterval   :: !(Maybe Milliseconds)
  , rsoLogHeadersFromEnv     :: !Bool
  , rsoWebSocketCompression  :: !Bool
  , rsoWebSocketKeepAlive    :: !(Maybe Integer)
  }

-- | @'ResponseInternalErrorsConfig' represents the encoding of the internal
-- errors in the response to the client.
-- See the github comment https://github.com/hasura/graphql-engine/issues/4031#issuecomment-609747705 for more details.
data ResponseInternalErrorsConfig
  = InternalErrorsAllRequests
  | InternalErrorsAdminOnly
  | InternalErrorsDisabled
  deriving (Show, Eq)

shouldIncludeInternal :: RoleName -> ResponseInternalErrorsConfig -> Bool
shouldIncludeInternal role = \case
  InternalErrorsAllRequests -> True
  InternalErrorsAdminOnly   -> isAdmin role
  InternalErrorsDisabled    -> False

newtype KeepAliveDelay
  = KeepAliveDelay
      { unKeepAliveDelay :: Seconds
      } deriving (Eq, Show)

data ServeOptions impl
  = ServeOptions
  { soPort                         :: !Int

Review comment (suggestion):
`Int` probably suffices :) 
```suggestion
  , rsoWebSocketKeepAlive    :: !(Maybe Int)
```
(That way we also avoid adding a new `FromENV` instance.)

Code after:
  , rsoConnParams            :: !RawConnParams
  , rsoTxIso                 :: !(Maybe Q.TxIsolation)
  , rsoAdminSecret           :: !(Maybe AdminSecretHash)
  , rsoAuthHook              :: !RawAuthHook
  , rsoJwtSecret             :: !(Maybe JWTConfig)
  , rsoUnAuthRole            :: !(Maybe RoleName)
  , rsoCorsConfig            :: !(Maybe CorsConfig)
  , rsoEnableConsole         :: !Bool
  , rsoConsoleAssetsDir      :: !(Maybe Text)
  , rsoEnableTelemetry       :: !(Maybe Bool)
  , rsoWsReadCookie          :: !Bool
  , rsoStringifyNum          :: !Bool
  , rsoEnabledAPIs           :: !(Maybe [API])
  , rsoMxRefetchInt          :: !(Maybe LQ.RefetchInterval)
  , rsoMxBatchSize           :: !(Maybe LQ.BatchSize)
  , rsoEnableAllowlist       :: !Bool
  , rsoEnabledLogTypes       :: !(Maybe [L.EngineLogType impl])
  , rsoLogLevel              :: !(Maybe L.LogLevel)
  , rsoPlanCacheSize         :: !(Maybe Cache.CacheSize)
  , rsoDevMode               :: !Bool
  , rsoAdminInternalErrors   :: !(Maybe Bool)
  , rsoEventsHttpPoolSize    :: !(Maybe Int)
  , rsoEventsFetchInterval   :: !(Maybe Milliseconds)
  , rsoLogHeadersFromEnv     :: !Bool
  , rsoWebSocketCompression  :: !Bool
  , rsoWebSocketKeepAlive    :: !(Maybe Int)
  }

-- | @'ResponseInternalErrorsConfig' represents the encoding of the internal
-- errors in the response to the client.
-- See the github comment https://github.com/hasura/graphql-engine/issues/4031#issuecomment-609747705 for more details.
data ResponseInternalErrorsConfig
  = InternalErrorsAllRequests
  | InternalErrorsAdminOnly
  | InternalErrorsDisabled
  deriving (Show, Eq)

shouldIncludeInternal :: RoleName -> ResponseInternalErrorsConfig -> Bool
shouldIncludeInternal role = \case
  InternalErrorsAllRequests -> True
  InternalErrorsAdminOnly   -> isAdmin role
  InternalErrorsDisabled    -> False

newtype KeepAliveDelay
  = KeepAliveDelay
      { unKeepAliveDelay :: Seconds
      } deriving (Eq, Show)

data ServeOptions impl
  = ServeOptions
  { soPort                         :: !Int