server: add more info about server to config api (#3412)

Co-authored-by: Toan Nguyen <hgiasac@gmail.com>
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
This commit is contained in:
Shahidh K Muhammed 2020-04-06 10:23:58 +05:30 committed by GitHub
parent 74b32fc9b8
commit b2461c5899
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 17 deletions

View File

@ -49,6 +49,11 @@ Sample response
"jwt": {
"claims_namespace": "https://hasura.io/jwt/claims",
"claims_format": "json"
},
"is_allow_list_enabled": false,
"live_queries": {
"batch_size": 100,
"refetch_delay": 1
}
}

View File

@ -96,7 +96,7 @@ module Hasura.GraphQL.Execute.LiveQuery
, LiveQueryPlanExplanation
, explainLiveQueryPlan
, LiveQueriesState
, LiveQueriesState(..)
, initLiveQueriesState
, dumpLiveQueriesState

View File

@ -2,7 +2,7 @@
-- in "Hasura.GraphQL.Execute.LiveQuery.Poll". See "Hasura.GraphQL.Execute.LiveQuery" for high-level
-- details.
module Hasura.GraphQL.Execute.LiveQuery.State
( LiveQueriesState
( LiveQueriesState(..)
, initLiveQueriesState
, dumpLiveQueriesState

View File

@ -580,7 +580,11 @@ httpApp corsCfg serverCtx enableConsole consoleAssetsDir enableTelemetry = do
Spock.get "v1alpha1/config" $ spockAction encodeQErr id $
mkGetHandler $ do
onlyAdmin
let res = encJFromJValue $ runGetConfig (scAuthMode serverCtx)
let res = encJFromJValue $ runGetConfig
(scAuthMode serverCtx)
(scEnableAllowlist serverCtx)
(EL._lqsOptions $ scLQState serverCtx)
return $ JSONResp $ HttpResponse res []
when enableGraphQL $ do

View File

@ -9,7 +9,9 @@ import Data.Aeson.TH
import Hasura.Prelude
import Hasura.Server.Auth
import Hasura.Server.Auth.JWT
import Hasura.Server.Version (HasVersion, Version, currentVersion)
import Hasura.Server.Version (HasVersion, Version, currentVersion)
import qualified Hasura.GraphQL.Execute.LiveQuery.Options as LQ
data JWTInfo
= JWTInfo
@ -21,22 +23,27 @@ $(deriveToJSON (aesonDrop 4 snakeCase) ''JWTInfo)
data ServerConfig
= ServerConfig
{ scfgVersion :: !Version
, scfgIsAdminSecretSet :: !Bool
, scfgIsAuthHookSet :: !Bool
, scfgIsJwtSet :: !Bool
, scfgJwt :: !(Maybe JWTInfo)
} deriving (Show)
{ scfgVersion :: !Version
, scfgIsAdminSecretSet :: !Bool
, scfgIsAuthHookSet :: !Bool
, scfgIsJwtSet :: !Bool
, scfgJwt :: !(Maybe JWTInfo)
, scfgIsAllowListEnabled :: !Bool
, scfgLiveQueries :: !LQ.LiveQueriesOptions
} deriving (Show, Eq)
$(deriveToJSON (aesonDrop 4 snakeCase) ''ServerConfig)
runGetConfig :: HasVersion => AuthMode -> ServerConfig
runGetConfig am = ServerConfig
currentVersion
(isAdminSecretSet am)
(isAuthHookSet am)
(isJWTSet am)
(getJWTInfo am)
runGetConfig :: HasVersion => AuthMode -> Bool -> LQ.LiveQueriesOptions -> ServerConfig
runGetConfig am isAllowListEnabled liveQueryOpts = ServerConfig
currentVersion
(isAdminSecretSet am)
(isAuthHookSet am)
(isJWTSet am)
(getJWTInfo am)
isAllowListEnabled
liveQueryOpts
isAdminSecretSet :: AuthMode -> Bool
isAdminSecretSet = \case