Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ServerCtx = ServerCtx {
- scLogger :: !(Logger Hasura)
- scCacheRef :: !SchemaCacheRef
- scAuthMode :: !AuthMode
- scManager :: !Manager
- scSQLGenCtx :: !SQLGenCtx
- scEnabledAPIs :: !(HashSet API)
- scInstanceId :: !InstanceId
- scSubscriptionState :: !SubscriptionsState
- scEnableAllowlist :: !Bool
- scEkgStore :: !(Store EmptyMetrics)
- scResponseInternalErrorsConfig :: !ResponseInternalErrorsConfig
- scEnvironment :: !Environment
- scRemoteSchemaPermsCtx :: !RemoteSchemaPermissions
- scFunctionPermsCtx :: !InferFunctionPermissions
- scEnableMaintenanceMode :: !(MaintenanceMode ())
- scExperimentalFeatures :: !(HashSet ExperimentalFeature)
- scLoggingSettings :: !LoggingSettings
- scEventingMode :: !EventingMode
- scEnableReadOnlyMode :: !ReadOnlyMode
- scDefaultNamingConvention :: !(Maybe NamingCase)
- scPrometheusMetrics :: !PrometheusMetrics
- data HandlerCtx = HandlerCtx {
- hcServerCtx :: !ServerCtx
- hcUser :: !UserInfo
- hcReqHeaders :: ![Header]
- hcRequestId :: !RequestId
- hcSourceIpAddress :: !IpAddress
- type Handler m = ReaderT HandlerCtx (MetadataStorageT m)
- data APIResp
- = JSONResp !(HttpResponse EncJSON)
- | RawResp !(HttpResponse ByteString)
- data APIHandler m a where
- AHGet :: !(Handler m (HttpLogMetadata m, APIResp)) -> APIHandler m void
- AHPost :: !(a -> Handler m (HttpLogMetadata m, APIResp)) -> APIHandler m a
- AHGraphQLRequest :: !(ReqsText -> Handler m (HttpLogMetadata m, APIResp)) -> APIHandler m ReqsText
- boolToText :: Bool -> Text
- isAdminSecretSet :: AuthMode -> Text
- mkGetHandler :: Handler m (HttpLogMetadata m, APIResp) -> APIHandler m ()
- mkPostHandler :: (a -> Handler m (HttpLogMetadata m, APIResp)) -> APIHandler m a
- mkGQLRequestHandler :: (ReqsText -> Handler m (HttpLogMetadata m, APIResp)) -> APIHandler m ReqsText
- mkAPIRespHandler :: Functor m => (a -> Handler m (HttpResponse EncJSON)) -> a -> Handler m APIResp
- mkGQLAPIRespHandler :: Functor m => (a -> Handler m (b, HttpResponse EncJSON)) -> a -> Handler m (b, APIResp)
- isMetadataEnabled :: ServerCtx -> Bool
- isGraphQLEnabled :: ServerCtx -> Bool
- isPGDumpEnabled :: ServerCtx -> Bool
- isConfigEnabled :: ServerCtx -> Bool
- isDeveloperAPIEnabled :: ServerCtx -> Bool
- parseBody :: (FromJSON a, MonadError QErr m) => ByteString -> m (Value, a)
- onlyAdmin :: (MonadError QErr m, MonadReader HandlerCtx m) => m ()
- setHeader :: MonadIO m => Header -> ActionT m ()
- class Monad m => MonadMetadataApiAuthorization m where
- authorizeV1QueryApi :: RQLQuery -> HandlerCtx -> m (Either QErr ())
- authorizeV1MetadataApi :: RQLMetadata -> HandlerCtx -> m (Either QErr ())
- authorizeV2QueryApi :: RQLQuery -> HandlerCtx -> m (Either QErr ())
- class Monad m => MonadConfigApiHandler m where
- runConfigApiHandler :: ServerCtx -> Maybe Text -> SpockCtxT () m ()
- mapActionT :: (Monad m, Monad n) => (m (StT (ActionCtxT ()) a) -> n (StT (ActionCtxT ()) a)) -> ActionT m a -> ActionT n a
- mkSpockAction :: (MonadIO m, MonadBaseControl IO m, FromJSON a, UserAuthentication (TraceT m), HttpLog m, HasReporter m, HasResourceLimits m) => ServerCtx -> (Bool -> QErr -> Value) -> (QErr -> QErr) -> APIHandler (TraceT m) a -> ActionT m ()
- v1QueryHandler :: (MonadIO m, MonadBaseControl IO m, MonadMetadataApiAuthorization m, MonadTrace m, MonadReader HandlerCtx m, MonadMetadataStorage m, MonadResolveSource m, MonadQueryTags m) => RQLQuery -> m (HttpResponse EncJSON)
- v1MetadataHandler :: (MonadIO m, MonadBaseControl IO m, MonadReader HandlerCtx m, MonadTrace m, MonadMetadataStorage m, MonadResolveSource m, MonadMetadataApiAuthorization m) => RQLMetadata -> m (HttpResponse EncJSON)
- v2QueryHandler :: (MonadIO m, MonadBaseControl IO m, MonadMetadataApiAuthorization m, MonadTrace m, MonadReader HandlerCtx m, MonadMetadataStorage m, MonadResolveSource m, MonadQueryTags m) => RQLQuery -> m (HttpResponse EncJSON)
- v1Alpha1GQHandler :: (MonadIO m, MonadBaseControl IO m, MonadGQLExecutionCheck m, MonadQueryLog m, MonadTrace m, MonadExecuteQuery m, MonadError QErr m, MonadReader HandlerCtx m, HttpLog m, MonadMetadataStorage (MetadataStorageT m), MonadQueryTags m, HasResourceLimits m) => GraphQLQueryType -> GQLBatchedReqs (GQLReq GQLQueryText) -> m (HttpLogMetadata m, HttpResponse EncJSON)
- mkExecutionContext :: (MonadIO m, MonadReader HandlerCtx m) => m ExecutionCtx
- v1GQHandler :: (MonadIO m, MonadBaseControl IO m, MonadGQLExecutionCheck m, MonadQueryLog m, MonadTrace m, MonadExecuteQuery m, HttpLog m, MonadError QErr m, MonadReader HandlerCtx m, MonadMetadataStorage (MetadataStorageT m), MonadQueryTags m, HasResourceLimits m) => GQLBatchedReqs (GQLReq GQLQueryText) -> m (HttpLogMetadata m, HttpResponse EncJSON)
- v1GQRelayHandler :: (MonadIO m, MonadBaseControl IO m, MonadGQLExecutionCheck m, MonadQueryLog m, MonadTrace m, HttpLog m, MonadExecuteQuery m, MonadError QErr m, MonadReader HandlerCtx m, MonadMetadataStorage (MetadataStorageT m), MonadQueryTags m, HasResourceLimits m) => GQLBatchedReqs (GQLReq GQLQueryText) -> m (HttpLogMetadata m, HttpResponse EncJSON)
- gqlExplainHandler :: forall m. (MonadIO m, MonadBaseControl IO m, MonadError QErr m, MonadReader HandlerCtx m, MonadMetadataStorage (MetadataStorageT m), MonadQueryTags m) => GQLExplain -> m (HttpResponse EncJSON)
- v1Alpha1PGDumpHandler :: (MonadIO m, MonadError QErr m, MonadReader HandlerCtx m) => PGDumpReqBody -> m APIResp
- consoleAssetsHandler :: (MonadIO m, HttpLog m) => Logger Hasura -> LoggingSettings -> Text -> FilePath -> ActionT m ()
- class Monad m => ConsoleRenderer m where
- renderHtmlTemplate :: Template -> Value -> Either String Text
- configApiGetHandler :: forall m. (MonadIO m, MonadBaseControl IO m, UserAuthentication (TraceT m), HttpLog m, HasReporter m, HasResourceLimits m) => ServerCtx -> Maybe Text -> SpockCtxT () m ()
- data HasuraApp = HasuraApp {
- _hapApplication :: !Application
- _hapSchemaRef :: !SchemaCacheRef
- _hapAsyncActionSubscriptionState :: !AsyncActionSubscriptionState
- _hapShutdownWsServer :: !(IO ())
- mkWaiApp :: forall m. (MonadIO m, MonadFix m, MonadStateless IO m, Forall (Pure m), ConsoleRenderer m, HttpLog m, UserAuthentication (TraceT m), MonadMetadataApiAuthorization m, MonadGQLExecutionCheck m, MonadConfigApiHandler m, MonadQueryLog m, MonadWSLog m, HasReporter m, MonadExecuteQuery m, HasResourceLimits m, MonadMetadataStorage (MetadataStorageT m), MonadResolveSource m, MonadQueryTags m) => (ServerCtx -> SpockT m ()) -> Environment -> Logger Hasura -> SQLGenCtx -> Bool -> Manager -> AuthMode -> CorsConfig -> Bool -> Maybe Text -> Bool -> InstanceId -> HashSet API -> LiveQueriesOptions -> StreamQueriesOptions -> ResponseInternalErrorsConfig -> Maybe SubscriptionPostPollHook -> SchemaCacheRef -> Store EmptyMetrics -> ServerMetrics -> PrometheusMetrics -> RemoteSchemaPermissions -> InferFunctionPermissions -> ConnectionOptions -> KeepAliveDelay -> MaintenanceMode () -> EventingMode -> ReadOnlyMode -> HashSet ExperimentalFeature -> HashSet (EngineLogType Hasura) -> WSConnectionInitTimeout -> MetadataQueryLoggingMode -> Maybe NamingCase -> m HasuraApp
- httpApp :: forall m. (MonadIO m, MonadFix m, MonadBaseControl IO m, ConsoleRenderer m, HttpLog m, UserAuthentication (TraceT m), MonadMetadataApiAuthorization m, MonadGQLExecutionCheck m, MonadConfigApiHandler m, MonadQueryLog m, HasReporter m, MonadExecuteQuery m, MonadMetadataStorage (MetadataStorageT m), HasResourceLimits m, MonadResolveSource m, MonadQueryTags m) => (ServerCtx -> SpockT m ()) -> CorsConfig -> ServerCtx -> Bool -> Maybe Text -> Bool -> SpockT m ()
- raiseGenericApiError :: (MonadIO m, HttpLog m) => Logger Hasura -> LoggingSettings -> [Header] -> QErr -> ActionT m ()
Documentation
ServerCtx | |
|
data HandlerCtx Source #
HandlerCtx | |
|
type Handler m = ReaderT HandlerCtx (MetadataStorageT m) Source #
data APIHandler m a where Source #
API request handlers for different endpoints
AHGet :: !(Handler m (HttpLogMetadata m, APIResp)) -> APIHandler m void | A simple GET request |
AHPost :: !(a -> Handler m (HttpLogMetadata m, APIResp)) -> APIHandler m a | A simple POST request that expects a request body from which an |
AHGraphQLRequest :: !(ReqsText -> Handler m (HttpLogMetadata m, APIResp)) -> APIHandler m ReqsText | A general GraphQL request (query or mutation) for which the content of the query
is made available to the handler for authentication.
This is a more specific version of the |
boolToText :: Bool -> Text Source #
isAdminSecretSet :: AuthMode -> Text Source #
mkGetHandler :: Handler m (HttpLogMetadata m, APIResp) -> APIHandler m () Source #
mkPostHandler :: (a -> Handler m (HttpLogMetadata m, APIResp)) -> APIHandler m a Source #
mkGQLRequestHandler :: (ReqsText -> Handler m (HttpLogMetadata m, APIResp)) -> APIHandler m ReqsText Source #
mkAPIRespHandler :: Functor m => (a -> Handler m (HttpResponse EncJSON)) -> a -> Handler m APIResp Source #
mkGQLAPIRespHandler :: Functor m => (a -> Handler m (b, HttpResponse EncJSON)) -> a -> Handler m (b, APIResp) Source #
isMetadataEnabled :: ServerCtx -> Bool Source #
isGraphQLEnabled :: ServerCtx -> Bool Source #
isPGDumpEnabled :: ServerCtx -> Bool Source #
isConfigEnabled :: ServerCtx -> Bool Source #
parseBody :: (FromJSON a, MonadError QErr m) => ByteString -> m (Value, a) Source #
onlyAdmin :: (MonadError QErr m, MonadReader HandlerCtx m) => m () Source #
class Monad m => MonadMetadataApiAuthorization m where Source #
Typeclass representing the metadata API authorization effect
authorizeV1QueryApi :: RQLQuery -> HandlerCtx -> m (Either QErr ()) Source #
authorizeV1MetadataApi :: RQLMetadata -> HandlerCtx -> m (Either QErr ()) Source #
authorizeV2QueryApi :: RQLQuery -> HandlerCtx -> m (Either QErr ()) Source #
Instances
class Monad m => MonadConfigApiHandler m where Source #
The config API (v1alpha1config) handler
Instances
(MonadIO m, MonadBaseControl IO m) => MonadConfigApiHandler (PGMetadataStorageAppT m) Source # | |
Defined in Hasura.App runConfigApiHandler :: ServerCtx -> Maybe Text -> SpockCtxT () (PGMetadataStorageAppT m) () Source # |
mapActionT :: (Monad m, Monad n) => (m (StT (ActionCtxT ()) a) -> n (StT (ActionCtxT ()) a)) -> ActionT m a -> ActionT n a Source #
:: (MonadIO m, MonadBaseControl IO m, FromJSON a, UserAuthentication (TraceT m), HttpLog m, HasReporter m, HasResourceLimits m) | |
=> ServerCtx | |
-> (Bool -> QErr -> Value) |
|
-> (QErr -> QErr) |
|
-> APIHandler (TraceT m) a | |
-> ActionT m () |
v1QueryHandler :: (MonadIO m, MonadBaseControl IO m, MonadMetadataApiAuthorization m, MonadTrace m, MonadReader HandlerCtx m, MonadMetadataStorage m, MonadResolveSource m, MonadQueryTags m) => RQLQuery -> m (HttpResponse EncJSON) Source #
v1MetadataHandler :: (MonadIO m, MonadBaseControl IO m, MonadReader HandlerCtx m, MonadTrace m, MonadMetadataStorage m, MonadResolveSource m, MonadMetadataApiAuthorization m) => RQLMetadata -> m (HttpResponse EncJSON) Source #
v2QueryHandler :: (MonadIO m, MonadBaseControl IO m, MonadMetadataApiAuthorization m, MonadTrace m, MonadReader HandlerCtx m, MonadMetadataStorage m, MonadResolveSource m, MonadQueryTags m) => RQLQuery -> m (HttpResponse EncJSON) Source #
v1Alpha1GQHandler :: (MonadIO m, MonadBaseControl IO m, MonadGQLExecutionCheck m, MonadQueryLog m, MonadTrace m, MonadExecuteQuery m, MonadError QErr m, MonadReader HandlerCtx m, HttpLog m, MonadMetadataStorage (MetadataStorageT m), MonadQueryTags m, HasResourceLimits m) => GraphQLQueryType -> GQLBatchedReqs (GQLReq GQLQueryText) -> m (HttpLogMetadata m, HttpResponse EncJSON) Source #
mkExecutionContext :: (MonadIO m, MonadReader HandlerCtx m) => m ExecutionCtx Source #
v1GQHandler :: (MonadIO m, MonadBaseControl IO m, MonadGQLExecutionCheck m, MonadQueryLog m, MonadTrace m, MonadExecuteQuery m, HttpLog m, MonadError QErr m, MonadReader HandlerCtx m, MonadMetadataStorage (MetadataStorageT m), MonadQueryTags m, HasResourceLimits m) => GQLBatchedReqs (GQLReq GQLQueryText) -> m (HttpLogMetadata m, HttpResponse EncJSON) Source #
v1GQRelayHandler :: (MonadIO m, MonadBaseControl IO m, MonadGQLExecutionCheck m, MonadQueryLog m, MonadTrace m, HttpLog m, MonadExecuteQuery m, MonadError QErr m, MonadReader HandlerCtx m, MonadMetadataStorage (MetadataStorageT m), MonadQueryTags m, HasResourceLimits m) => GQLBatchedReqs (GQLReq GQLQueryText) -> m (HttpLogMetadata m, HttpResponse EncJSON) Source #
gqlExplainHandler :: forall m. (MonadIO m, MonadBaseControl IO m, MonadError QErr m, MonadReader HandlerCtx m, MonadMetadataStorage (MetadataStorageT m), MonadQueryTags m) => GQLExplain -> m (HttpResponse EncJSON) Source #
v1Alpha1PGDumpHandler :: (MonadIO m, MonadError QErr m, MonadReader HandlerCtx m) => PGDumpReqBody -> m APIResp Source #
consoleAssetsHandler :: (MonadIO m, HttpLog m) => Logger Hasura -> LoggingSettings -> Text -> FilePath -> ActionT m () Source #
class Monad m => ConsoleRenderer m where Source #
Instances
ConsoleRenderer m => ConsoleRenderer (TraceT m) Source # | |
Defined in Hasura.Server.App | |
Monad m => ConsoleRenderer (PGMetadataStorageAppT m) Source # | |
Defined in Hasura.App renderConsole :: Text -> AuthMode -> Bool -> Maybe Text -> PGMetadataStorageAppT m (Either String Text) Source # |
renderHtmlTemplate :: Template -> Value -> Either String Text Source #
configApiGetHandler :: forall m. (MonadIO m, MonadBaseControl IO m, UserAuthentication (TraceT m), HttpLog m, HasReporter m, HasResourceLimits m) => ServerCtx -> Maybe Text -> SpockCtxT () m () Source #
Default implementation of the MonadConfigApiHandler
HasuraApp | |
|
:: forall m. (MonadIO m, MonadFix m, MonadStateless IO m, Forall (Pure m), ConsoleRenderer m, HttpLog m, UserAuthentication (TraceT m), MonadMetadataApiAuthorization m, MonadGQLExecutionCheck m, MonadConfigApiHandler m, MonadQueryLog m, MonadWSLog m, HasReporter m, MonadExecuteQuery m, HasResourceLimits m, MonadMetadataStorage (MetadataStorageT m), MonadResolveSource m, MonadQueryTags m) | |
=> (ServerCtx -> SpockT m ()) | |
-> Environment | Set of environment variables for reference in UIs |
-> Logger Hasura | a |
-> SQLGenCtx | |
-> Bool | is AllowList enabled - TODO: change this boolean to sumtype |
-> Manager | HTTP manager so that we can re-use sessions |
-> AuthMode |
|
-> CorsConfig | |
-> Bool | is console enabled - TODO: better type |
-> Maybe Text | filepath to the console static assets directory - TODO: better type |
-> Bool | is telemetry enabled |
-> InstanceId | each application, when run, gets an |
-> HashSet API | set of the enabled |
-> LiveQueriesOptions | |
-> StreamQueriesOptions | |
-> ResponseInternalErrorsConfig | |
-> Maybe SubscriptionPostPollHook | |
-> SchemaCacheRef | |
-> Store EmptyMetrics | |
-> ServerMetrics | |
-> PrometheusMetrics | |
-> RemoteSchemaPermissions | |
-> InferFunctionPermissions | |
-> ConnectionOptions | |
-> KeepAliveDelay | |
-> MaintenanceMode () | |
-> EventingMode | |
-> ReadOnlyMode | |
-> HashSet ExperimentalFeature | Set of the enabled experimental features |
-> HashSet (EngineLogType Hasura) | |
-> WSConnectionInitTimeout | |
-> MetadataQueryLoggingMode | is metadata query logging in http-log enabled |
-> Maybe NamingCase | default naming convention |
-> m HasuraApp |
httpApp :: forall m. (MonadIO m, MonadFix m, MonadBaseControl IO m, ConsoleRenderer m, HttpLog m, UserAuthentication (TraceT m), MonadMetadataApiAuthorization m, MonadGQLExecutionCheck m, MonadConfigApiHandler m, MonadQueryLog m, HasReporter m, MonadExecuteQuery m, MonadMetadataStorage (MetadataStorageT m), HasResourceLimits m, MonadResolveSource m, MonadQueryTags m) => (ServerCtx -> SpockT m ()) -> CorsConfig -> ServerCtx -> Bool -> Maybe Text -> Bool -> SpockT m () Source #
raiseGenericApiError :: (MonadIO m, HttpLog m) => Logger Hasura -> LoggingSettings -> [Header] -> QErr -> ActionT m () Source #