graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hasura.RQL.Types.SchemaCache

Synopsis

Documentation

newtype MetadataResourceVersion Source #

Instances

Instances details
FromJSON MetadataResourceVersion Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

ToJSON MetadataResourceVersion Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Num MetadataResourceVersion Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Show MetadataResourceVersion Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Eq MetadataResourceVersion Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

mkLogicalModelParentDep :: forall b. Backend b => SourceName -> LogicalModelName -> SchemaDependency Source #

When we depend on anything to do with logical models, we also declare that we depend on the logical model as a whole. This is the "parent" dependency in the dependency tree for a given logical model.

mkLogicalModelColDep :: forall b. Backend b => DependencyReason -> SourceName -> LogicalModelName -> Column b -> SchemaDependency Source #

Declare a dependency on a particular column of a logical model

data CronTriggerInfo Source #

Instances

Instances details
ToJSON CronTriggerInfo Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Generic CronTriggerInfo Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Associated Types

type Rep CronTriggerInfo :: Type -> Type #

Show CronTriggerInfo Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Eq CronTriggerInfo Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

type Rep CronTriggerInfo Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

askSourceInfo :: forall b m. (CacheRM m, MetadataM m, MonadError QErr m, Backend b) => SourceName -> m (SourceInfo b) Source #

Retrieves the source info for a given source name.

This function retrieves the schema cache from the monadic context, and attempts to look the corresponding source up in the source cache. This function must be used with a _type annotation_, such as `askSourceInfo @('Postgres 'Vanilla)`. It throws an error if: 1. The function fails to find the named source at all 2. The named source exists but does not match the expected type 3. The named source exists, and is of the expected type, but is inconsistent

askSourceInfoMaybe :: forall b m. (CacheRM m, Backend b) => SourceName -> m (Maybe (SourceInfo b)) Source #

askSourceConfig :: forall b m. (CacheRM m, MonadError QErr m, Backend b, MetadataM m) => SourceName -> m (SourceConfig b) Source #

Retrieves the source config for a given source name.

This function relies on askSourceInfo and similarly throws an error if the source isn't found.

unsafeTableCache :: forall b. Backend b => SourceName -> SourceCache -> Maybe (TableCache b) Source #

Retrieves the table cache for a given source cache and source name.

This function must be used with a _type annotation_, such as `unsafeTableCache ('Postgres 'Vanilla)`. It returns Nothing@ if it fails to find that source or if the kind of the source does not match the type annotation, and does not distinguish between the two cases.

askTableCache :: forall b m. (Backend b, CacheRM m) => SourceName -> m (Maybe (TableCache b)) Source #

Retrieves the table cache for a given source name.

This function retrieves the schema cache from the monadic context, and attempts to look the corresponding source up in the source cache. It must be used with a _type annotation_, such as `unsafeTableCache ('Postgres 'Vanilla)`. It returns Nothing@ if it fails to find that source or if the kind of the source does not match the type annotation, and does not distinguish between the two cases.

unsafeTableInfo :: forall b. Backend b => SourceName -> TableName b -> SourceCache -> Maybe (TableInfo b) Source #

Retrieves the information about a table from the source cache, the source name, and the table name.

This function returns Nothing if it fails to find that source or if the kind of the source does not match the type annotation, and does not distinguish between the two cases.

askTableInfo :: forall b m. (QErrM m, CacheRM m, Backend b) => SourceName -> TableName b -> m (TableInfo b) Source #

Retrieves the information about a table for a given source name and table name.

This function retrieves the schema cache from the monadic context, and attempts to look the corresponding source up in the source cache. it throws an error if it fails to find that source, in which case it looks that source up in the metadata, to differentiate between the source not existing or the type of the source not matching.

askTableCoreInfo :: forall b m. (QErrM m, CacheRM m, Backend b) => SourceName -> TableName b -> m (TableCoreInfo b) Source #

Similar to askTableInfo, but drills further down to extract the underlying core info.

askTableFieldInfoMap :: forall b m. (QErrM m, CacheRM m, Backend b) => SourceName -> TableName b -> m (FieldInfoMap (FieldInfo b)) Source #

Similar to askTableCoreInfo, but drills further down to extract the underlying field info map.

askTableMetadata :: forall b m. (QErrM m, MetadataM m, Backend b) => SourceName -> TableName b -> m (TableMetadata b) Source #

Retrieves the metadata information about a table for a given source name and table name.

Unlike most other ask functions in this module, this function does not drill through the schema cache, and instead inspects the metadata. Like most others, it throws an error if it fails to find that source, in which case it looks that source up in the metadata, to differentiate between the source not existing or the type of the source not matching.

unsafeFunctionCache :: forall b. Backend b => SourceName -> SourceCache -> Maybe (FunctionCache b) Source #

Retrieves the function cache for a given source cache and source name.

This function must be used with a _type annotation_, such as `unsafeFunctionCache ('Postgres 'Vanilla)`. It returns Nothing@ if it fails to find that source or if the kind of the source does not match the type annotation, and does not distinguish between the two cases.

unsafeFunctionInfo :: forall b. Backend b => SourceName -> FunctionName b -> SourceCache -> Maybe (FunctionInfo b) Source #

Retrieves the information about a function from the source cache, the source name, and the function name.

This function returns Nothing if it fails to find that source or if the kind of the source does not match the type annotation, and does not distinguish between the two cases.

askFunctionInfo :: forall b m. (QErrM m, CacheRM m, Backend b) => SourceName -> FunctionName b -> m (FunctionInfo b) Source #

Retrieves the information about a function cache for a given source name and function name.

This function retrieves the schema cache from the monadic context, and attempts to look the corresponding source up in the source cache. It throws an error if it fails to find that source, in which case it looks that source up in the metadata, to differentiate between the source not existing or the type of the source not matching.

getBackendInfo :: forall b m. (CacheRM m, HasTag b) => m (Maybe (BackendInfo b)) Source #

class Monad m => TableCoreInfoRM b m where Source #

A more limited version of CacheRM that is used when building the schema cache, since the entire schema cache has not been built yet.

Instances

Instances details
TableCoreInfoRM b m => TableCoreInfoRM b (MetadataT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

TableCoreInfoRM b m => TableCoreInfoRM b (TraceT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

(Monad m, Backend b) => TableCoreInfoRM b (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

(Monad m, Backend b) => TableCoreInfoRM b (TableCoreCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

TableCoreInfoRM b m => TableCoreInfoRM b (ReaderT r m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

TableCoreInfoRM b m => TableCoreInfoRM b (StateT s m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

(Monoid w, TableCoreInfoRM b m) => TableCoreInfoRM b (WriterT w m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

newtype TableCoreCacheRT b m a Source #

Constructors

TableCoreCacheRT 

Instances

Instances details
(Monad m, Backend b) => TableCoreInfoRM b (TableCoreCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

MonadError e m => MonadError e (TableCoreCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

throwError :: e -> TableCoreCacheRT b m a #

catchError :: TableCoreCacheRT b m a -> (e -> TableCoreCacheRT b m a) -> TableCoreCacheRT b m a #

MonadReader r m => MonadReader r (TableCoreCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

ask :: TableCoreCacheRT b m r #

local :: (r -> r) -> TableCoreCacheRT b m a -> TableCoreCacheRT b m a #

reader :: (r -> a) -> TableCoreCacheRT b m a #

MonadState s m => MonadState s (TableCoreCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

get :: TableCoreCacheRT b m s #

put :: s -> TableCoreCacheRT b m () #

state :: (s -> (a, s)) -> TableCoreCacheRT b m a #

MonadWriter w m => MonadWriter w (TableCoreCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

writer :: (a, w) -> TableCoreCacheRT b m a #

tell :: w -> TableCoreCacheRT b m () #

listen :: TableCoreCacheRT b m a -> TableCoreCacheRT b m (a, w) #

pass :: TableCoreCacheRT b m (a, w -> w) -> TableCoreCacheRT b m a #

MonadTrans (TableCoreCacheRT b) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

lift :: Monad m => m a -> TableCoreCacheRT b m a #

MonadIO m => MonadIO (TableCoreCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

liftIO :: IO a -> TableCoreCacheRT b m a #

Applicative m => Applicative (TableCoreCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

pure :: a -> TableCoreCacheRT b m a #

(<*>) :: TableCoreCacheRT b m (a -> b0) -> TableCoreCacheRT b m a -> TableCoreCacheRT b m b0 #

liftA2 :: (a -> b0 -> c) -> TableCoreCacheRT b m a -> TableCoreCacheRT b m b0 -> TableCoreCacheRT b m c #

(*>) :: TableCoreCacheRT b m a -> TableCoreCacheRT b m b0 -> TableCoreCacheRT b m b0 #

(<*) :: TableCoreCacheRT b m a -> TableCoreCacheRT b m b0 -> TableCoreCacheRT b m a #

Functor m => Functor (TableCoreCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

fmap :: (a -> b0) -> TableCoreCacheRT b m a -> TableCoreCacheRT b m b0 #

(<$) :: a -> TableCoreCacheRT b m b0 -> TableCoreCacheRT b m a #

Monad m => Monad (TableCoreCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

(>>=) :: TableCoreCacheRT b m a -> (a -> TableCoreCacheRT b m b0) -> TableCoreCacheRT b m b0 #

(>>) :: TableCoreCacheRT b m a -> TableCoreCacheRT b m b0 -> TableCoreCacheRT b m b0 #

return :: a -> TableCoreCacheRT b m a #

MonadTx m => MonadTx (TableCoreCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

liftTx :: TxE QErr a -> TableCoreCacheRT b m a Source #

class TableCoreInfoRM b m => TableInfoRM b m where Source #

All our RQL DML queries operate over a single source. This typeclass facilitates that.

Instances

Instances details
TableInfoRM b m => TableInfoRM b (TraceT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

(Monad m, Backend b) => TableInfoRM b (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

TableInfoRM b m => TableInfoRM b (ReaderT r m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

TableInfoRM b m => TableInfoRM b (StateT s m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

(Monoid w, TableInfoRM b m) => TableInfoRM b (WriterT w m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

newtype TableCacheRT b m a Source #

Constructors

TableCacheRT 

Fields

Instances

Instances details
(Monad m, Backend b) => TableCoreInfoRM b (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

(Monad m, Backend b) => TableInfoRM b (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

MonadError e m => MonadError e (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

throwError :: e -> TableCacheRT b m a #

catchError :: TableCacheRT b m a -> (e -> TableCacheRT b m a) -> TableCacheRT b m a #

MonadState s m => MonadState s (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

get :: TableCacheRT b m s #

put :: s -> TableCacheRT b m () #

state :: (s -> (a, s)) -> TableCacheRT b m a #

MonadWriter w m => MonadWriter w (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

writer :: (a, w) -> TableCacheRT b m a #

tell :: w -> TableCacheRT b m () #

listen :: TableCacheRT b m a -> TableCacheRT b m (a, w) #

pass :: TableCacheRT b m (a, w -> w) -> TableCacheRT b m a #

MonadTrans (TableCacheRT b) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

lift :: Monad m => m a -> TableCacheRT b m a #

MonadIO m => MonadIO (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

liftIO :: IO a -> TableCacheRT b m a #

Applicative m => Applicative (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

pure :: a -> TableCacheRT b m a #

(<*>) :: TableCacheRT b m (a -> b0) -> TableCacheRT b m a -> TableCacheRT b m b0 #

liftA2 :: (a -> b0 -> c) -> TableCacheRT b m a -> TableCacheRT b m b0 -> TableCacheRT b m c #

(*>) :: TableCacheRT b m a -> TableCacheRT b m b0 -> TableCacheRT b m b0 #

(<*) :: TableCacheRT b m a -> TableCacheRT b m b0 -> TableCacheRT b m a #

Functor m => Functor (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

fmap :: (a -> b0) -> TableCacheRT b m a -> TableCacheRT b m b0 #

(<$) :: a -> TableCacheRT b m b0 -> TableCacheRT b m a #

Monad m => Monad (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

(>>=) :: TableCacheRT b m a -> (a -> TableCacheRT b m b0) -> TableCacheRT b m b0 #

(>>) :: TableCacheRT b m a -> TableCacheRT b m b0 -> TableCacheRT b m b0 #

return :: a -> TableCacheRT b m a #

MonadTx m => MonadTx (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

Methods

liftTx :: TxE QErr a -> TableCacheRT b m a Source #

UserInfoM m => UserInfoM (TableCacheRT b m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

class Monad m => CacheRM m where Source #

Instances

Instances details
Monad m => CacheRM (CacheRWT m) Source # 
Instance details

Defined in Hasura.RQL.DDL.Schema.Cache

CacheRM m => CacheRM (MetadataT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

CacheRM m => CacheRM (TraceT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

CacheRM m => CacheRM (TxET e m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

CacheRM m => CacheRM (TxET QErr m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

CacheRM m => CacheRM (ReaderT r m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

CacheRM m => CacheRM (StateT s m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

(Monoid w, CacheRM m) => CacheRM (WriterT w m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache

getRemoteDependencies :: SchemaCache -> SourceName -> [SchemaObjId] Source #

Compute all remote dependencies on a source.

Given a source name, this function computes all of its dependencies, direct or indirect, and returns all of the dependencies that are not "local" to the source, i.e. that belong to another source or to a remote schema, here dubbed "remote dependencies".

This functions returns a SchemaObjId for each such dependency, but makes no attempt at extracting the underlying SourceObjId (if any), for two reasons: 1. a SourceObjId no longer contains the source name, which most callers need to identify where the corresponding dependency is 2. this would prevent us from returning remote schema dependencies, which by definition do not have a corresponding SourceObjId

getLogicalModelBoolExpDeps :: forall b. GetAggregationPredicatesDeps b => SourceName -> LogicalModelName -> AnnBoolExpPartialSQL b -> [SchemaDependency] Source #

What schema dependencies does a given row permission for a logical model have? This will almost certainly involve some number of dependencies on logical models, but may also involve dependencies on tables. Although we can't relate tables and logical models yet, we can still declare permissions like, "you can only see this logical model if your user ID exists in this table".

getBoolExpDeps :: forall b. GetAggregationPredicatesDeps b => SourceName -> TableName b -> AnnBoolExpPartialSQL b -> [SchemaDependency] Source #

Discover the schema dependencies of an AnnBoolExpPartialSQL.

askFieldInfoMapSource :: (QErrM m, Backend b, TableCoreInfoRM b m) => TableName b -> m (FieldInfoMap (FieldInfo b)) Source #

Asking for a table's fields info without explicit SourceName argument. The source name is implicitly inferred from SourceM via @TableCoreInfoRM.