graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.App

Synopsis

Documentation

throwErrExit :: MonadIO m => forall a. ExitCode -> String -> m a Source #

throwErrJExit :: (ToJSON a, MonadIO m) => forall b. ExitCode -> a -> m b Source #

printJSON :: (ToJSON a, MonadIO m) => a -> m () Source #

printYaml :: (ToJSON a, MonadIO m) => a -> m () Source #

data GlobalCtx Source #

Context required for all graphql-engine CLI commands

Constructors

GlobalCtx 

Fields

initGlobalCtx Source #

Arguments

:: MonadIO m 
=> Environment 
-> Maybe String

the metadata DB URL

-> PostgresConnInfo (Maybe UrlConf)

the user's DB URL

-> m GlobalCtx 

data Loggers Source #

Collection of the LoggerCtx, the regular Logger and the PGLogger TODO (from master): better naming?

Constructors

Loggers 

Fields

newtype PGMetadataStorageAppT m a Source #

An application with Postgres database as a metadata storage

Constructors

PGMetadataStorageAppT 

Fields

Instances

Instances details
MonadTrans PGMetadataStorageAppT Source # 
Instance details

Defined in Hasura.App

Methods

lift :: Monad m => m a -> PGMetadataStorageAppT m a #

MonadBaseControl b m => MonadBaseControl b (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Associated Types

type StM (PGMetadataStorageAppT m) a

MonadBase b m => MonadBase b (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Methods

liftBase :: b α -> PGMetadataStorageAppT m α

Monad m => Monad (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Functor m => Functor (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

MonadFix m => MonadFix (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Applicative m => Applicative (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

MonadIO m => MonadIO (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Methods

liftIO :: IO a -> PGMetadataStorageAppT m a #

MonadThrow m => MonadThrow (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Methods

throwM :: Exception e => e -> PGMetadataStorageAppT m a #

MonadCatch m => MonadCatch (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

MonadMask m => MonadMask (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

HasHttpManagerM m => HasHttpManagerM (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Monad m => HasReporter (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

HasServerConfigCtx m => HasServerConfigCtx (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Monad m => MonadResolveSource (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

MonadMetadataStorageQueryAPI (MetadataStorageT (PGMetadataStorageAppT CacheBuild)) Source # 
Instance details

Defined in Hasura.App

MonadIO m => MonadMetadataStorage (MetadataStorageT (PGMetadataStorageAppT m)) Source #

Each of the function in the type class is executed in a totally separate transaction.

To learn more about why the instance is derived as following, see Note [Generic MetadataStorageT transformer]

Instance details

Defined in Hasura.App

Methods

fetchMetadataResourceVersion :: MetadataStorageT (PGMetadataStorageAppT m) MetadataResourceVersion Source #

fetchMetadata :: MetadataStorageT (PGMetadataStorageAppT m) (Metadata, MetadataResourceVersion) Source #

fetchMetadataNotifications :: MetadataResourceVersion -> InstanceId -> MetadataStorageT (PGMetadataStorageAppT m) [(MetadataResourceVersion, CacheInvalidations)] Source #

setMetadata :: MetadataResourceVersion -> Metadata -> MetadataStorageT (PGMetadataStorageAppT m) MetadataResourceVersion Source #

notifySchemaCacheSync :: MetadataResourceVersion -> InstanceId -> CacheInvalidations -> MetadataStorageT (PGMetadataStorageAppT m) () Source #

getCatalogState :: MetadataStorageT (PGMetadataStorageAppT m) CatalogState Source #

setCatalogState :: CatalogStateType -> Value -> MetadataStorageT (PGMetadataStorageAppT m) () Source #

getMetadataDbUid :: MetadataStorageT (PGMetadataStorageAppT m) MetadataDbId Source #

checkMetadataStorageHealth :: MetadataStorageT (PGMetadataStorageAppT m) () Source #

getDeprivedCronTriggerStats :: [TriggerName] -> MetadataStorageT (PGMetadataStorageAppT m) [CronTriggerStats] Source #

getScheduledEventsForDelivery :: MetadataStorageT (PGMetadataStorageAppT m) ([CronEvent], [OneOffScheduledEvent]) Source #

insertCronEvents :: [CronEventSeed] -> MetadataStorageT (PGMetadataStorageAppT m) () Source #

insertOneOffScheduledEvent :: OneOffEvent -> MetadataStorageT (PGMetadataStorageAppT m) EventId Source #

insertScheduledEventInvocation :: Invocation 'ScheduledType -> ScheduledEventType -> MetadataStorageT (PGMetadataStorageAppT m) () Source #

setScheduledEventOp :: ScheduledEventId -> ScheduledEventOp -> ScheduledEventType -> MetadataStorageT (PGMetadataStorageAppT m) () Source #

unlockScheduledEvents :: ScheduledEventType -> [ScheduledEventId] -> MetadataStorageT (PGMetadataStorageAppT m) Int Source #

unlockAllLockedScheduledEvents :: MetadataStorageT (PGMetadataStorageAppT m) () Source #

clearFutureCronEvents :: ClearCronEvents -> MetadataStorageT (PGMetadataStorageAppT m) () Source #

getOneOffScheduledEvents :: ScheduledEventPagination -> [ScheduledEventStatus] -> MetadataStorageT (PGMetadataStorageAppT m) (WithTotalCount [OneOffScheduledEvent]) Source #

getCronEvents :: TriggerName -> ScheduledEventPagination -> [ScheduledEventStatus] -> MetadataStorageT (PGMetadataStorageAppT m) (WithTotalCount [CronEvent]) Source #

getInvocations :: GetInvocationsBy -> ScheduledEventPagination -> MetadataStorageT (PGMetadataStorageAppT m) (WithTotalCount [ScheduledEventInvocation]) Source #

deleteScheduledEvent :: ScheduledEventId -> ScheduledEventType -> MetadataStorageT (PGMetadataStorageAppT m) () Source #

insertAction :: ActionName -> SessionVariables -> [Header] -> Value -> MetadataStorageT (PGMetadataStorageAppT m) ActionId Source #

fetchUndeliveredActionEvents :: MetadataStorageT (PGMetadataStorageAppT m) [ActionLogItem] Source #

setActionStatus :: ActionId -> AsyncActionStatus -> MetadataStorageT (PGMetadataStorageAppT m) () Source #

fetchActionResponse :: ActionId -> MetadataStorageT (PGMetadataStorageAppT m) ActionLogResponse Source #

clearActionData :: ActionName -> MetadataStorageT (PGMetadataStorageAppT m) () Source #

setProcessingActionLogsToPending :: LockedActionIdArray -> MetadataStorageT (PGMetadataStorageAppT m) () Source #

Monad m => HasResourceLimits (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

MonadIO m => MonadQueryLog (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Monad m => MonadQueryTags (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

MonadIO m => HttpLog (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

(MonadIO m, MonadBaseControl IO m) => UserAuthentication (TraceT (PGMetadataStorageAppT m)) Source # 
Instance details

Defined in Hasura.App

Methods

resolveUserInfo :: Logger Hasura -> Manager -> [Header] -> AuthMode -> Maybe ReqsText -> TraceT (PGMetadataStorageAppT m) (Either QErr (UserInfo, Maybe UTCTime, [Header])) Source #

MonadIO m => MonadWSLog (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Monad m => MonadGQLExecutionCheck (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Monad m => MonadExecuteQuery (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Monad m => ConsoleRenderer (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Methods

renderConsole :: Text -> AuthMode -> Bool -> Maybe Text -> PGMetadataStorageAppT m (Either String Text) Source #

(MonadIO m, MonadBaseControl IO m) => MonadConfigApiHandler (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Methods

runConfigApiHandler :: ServerCtx -> Maybe Text -> SpockCtxT () (PGMetadataStorageAppT m) () Source #

Monad m => MonadMetadataApiAuthorization (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Monad m => MonadReader (PGPool, PGLogger) (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

Methods

ask :: PGMetadataStorageAppT m (PGPool, PGLogger) #

local :: ((PGPool, PGLogger) -> (PGPool, PGLogger)) -> PGMetadataStorageAppT m a -> PGMetadataStorageAppT m a #

reader :: ((PGPool, PGLogger) -> a) -> PGMetadataStorageAppT m a #

type ExtraHttpLogMetadata (PGMetadataStorageAppT m) Source # 
Instance details

Defined in Hasura.App

type StM (PGMetadataStorageAppT m) a Source # 
Instance details

Defined in Hasura.App

type StM (PGMetadataStorageAppT m) a = StM (ReaderT (PGPool, PGLogger) m) a

initialiseServeCtx :: (ForkableMonadIO m, MonadCatch m) => Environment -> GlobalCtx -> ServeOptions Hasura -> ServerMetrics -> ManagedT m ServeCtx Source #

Initializes or migrates the catalog and returns the context required to start the server.

mkLoggers :: (MonadIO m, MonadBaseControl IO m) => HashSet (EngineLogType Hasura) -> LogLevel -> ManagedT m Loggers Source #

migrateCatalogSchema :: (MonadIO m, MonadBaseControl IO m) => Environment -> Logger Hasura -> PGPool -> Maybe (SourceConnConfiguration ('Postgres 'Vanilla)) -> Manager -> ServerConfigCtx -> SourceResolver ('Postgres 'Vanilla) -> SourceResolver 'MSSQL -> ExtensionsSchema -> m RebuildableSchemaCache Source #

helper function to initialize or migrate the hdb_catalog schema (used by pro as well)

newtype ShutdownLatch Source #

A latch for the graceful shutdown of a server process.

Constructors

ShutdownLatch 

Fields

data ShutdownAction Source #

Event triggers live in the user's DB and other events (cron, one-off and async actions) live in the metadata DB, so we need a way to differentiate the type of shutdown action

waitForShutdown :: ShutdownLatch -> IO () Source #

Block the current thread, waiting on the latch.

shutdownGracefully :: ShutdownLatch -> IO () Source #

Initiate a graceful shutdown of the server associated with the provided latch.

shuttingDown :: ShutdownLatch -> IO Bool Source #

Returns True if the latch is set for shutdown and vice-versa

flushLogger :: MonadIO m => LoggerCtx impl -> m () Source #

If an exception is encountered , flush the log buffer and rethrow If we do not flush the log buffer on exception, then log lines may be missed See: https://github.com/hasura/graphql-engine/issues/4772

runHGEServer Source #

Arguments

:: forall m impl. (MonadIO m, MonadFix m, MonadMask m, MonadStateless IO m, Forall (Pure m), UserAuthentication (TraceT m), HttpLog m, ConsoleRenderer m, MonadMetadataApiAuthorization m, MonadGQLExecutionCheck m, MonadConfigApiHandler m, MonadQueryLog m, MonadWSLog m, MonadExecuteQuery m, HasReporter m, HasResourceLimits m, MonadMetadataStorage (MetadataStorageT m), MonadResolveSource m, MonadQueryTags m) 
=> (ServerCtx -> SpockT m ()) 
-> Environment 
-> ServeOptions impl 
-> ServeCtx 
-> UTCTime

start time

-> Maybe SubscriptionPostPollHook 
-> ServerMetrics 
-> Store EmptyMetrics 
-> Maybe (IO ())

A hook which can be called to indicate when the server is started succesfully

-> PrometheusMetrics 
-> ManagedT m () 

This function acts as the entrypoint for the graphql-engine webserver.

Note: at the exit of this function, or in case of a graceful server shutdown (SIGTERM, or more generally, whenever the shutdown latch is set), we need to make absolutely sure that we clean up any resources which were allocated during server setup. In the case of a multitenant process, failure to do so can lead to resource leaks.

To track these resources, we use the ManagedT monad, and attach finalizers at the same point in the code where we allocate resources. If you fork a new long-lived thread, or create a connection pool, or allocate any other long-lived resource, make sure to pair the allocator with its finalizer. There are plenty of examples throughout the code. For example, see forkManagedT.

Note also: the order in which the finalizers run can be important. Specifically, we want the finalizers for the logger threads to run last, so that we retain as many "thread stopping" log messages as possible. The order in which the finalizers is run is determined by the order in which they are introduced in the code.

mkHGEServer Source #

Part of a factorization of runHGEServer to expose the constructed WAI application for testing purposes. See runHGEServer for documentation.

mkConsoleHTML :: Text -> AuthMode -> Bool -> Maybe Text -> Either String Text Source #