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

Hasura.RQL.Types.SchemaCache.Build

Description

Types and functions used in the process of building the schema cache from metadata information stored in the hdb_catalog schema in Postgres.

Synopsis

Inconsistencies

Dependencies

Helpers

withRecordInconsistency :: (ArrowChoice arr, ArrowWriter (Seq CollectItem) arr) => ErrorA QErr arr (e, s) a -> arr (e, (MetadataObject, s)) (Maybe a) Source #

Record any errors resulting from a computation as inconsistencies

withRecordInconsistencies :: (ArrowChoice arr, ArrowWriter (Seq CollectItem) arr) => ErrorA QErr arr (e, s) a -> arr (e, ([MetadataObject], s)) (Maybe a) Source #

class CacheRM m => CacheRWM m where Source #

Instances

Instances details
(MonadIO m, MonadError QErr m, ProvidesNetwork m, MonadResolveSource m, HasCacheStaticConfig m, MonadMetadataStorage m) => CacheRWM (CacheRWT m) Source # 
Instance details

Defined in Hasura.RQL.DDL.Schema.Cache

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

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.Types.SchemaCache.Build

data BuildReason Source #

Constructors

CatalogUpdate (Maybe (HashSet SourceName))

The build was triggered by an update this instance made to the catalog (in the currently-active transaction), so information in Postgres that needs to be kept in sync with the catalog (i.e. table event triggers in hdb_catalog schema) should be updated.

CatalogSync

The build was triggered by a notification that some other currently-running Hasura instance updated the catalog. Since that instance already updated table event triggers in hdb_catalog, this build should be read-only.

Instances

Instances details
Show BuildReason Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Eq BuildReason Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

data CacheInvalidations Source #

Constructors

CacheInvalidations 

Fields

  • ciMetadata :: Bool

    Force reloading of all database information, including information not technically stored in metadata (currently just enum values). Set by the reload_metadata API.

  • ciRemoteSchemas :: HashSet RemoteSchemaName

    Force refetching of the given remote schemas, even if their definition has not changed. Set by the reload_remote_schema API.

  • ciSources :: HashSet SourceName

    Force re-establishing connections of the given data sources, even if their configuration has not changed. Set by the pg_reload_source API.

  • ciDataConnectors :: HashSet DataConnectorName

    Force re-fetching of DataConnectorInfo from the named data connectors.

Instances

Instances details
FromJSON CacheInvalidations Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

ToJSON CacheInvalidations Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Monoid CacheInvalidations Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Semigroup CacheInvalidations Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Generic CacheInvalidations Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Associated Types

type Rep CacheInvalidations :: Type -> Type #

type Rep CacheInvalidations Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

type Rep CacheInvalidations = D1 ('MetaData "CacheInvalidations" "Hasura.RQL.Types.SchemaCache.Build" "graphql-engine-1.0.0-inplace" 'False) (C1 ('MetaCons "CacheInvalidations" 'PrefixI 'True) ((S1 ('MetaSel ('Just "ciMetadata") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "ciRemoteSchemas") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (HashSet RemoteSchemaName))) :*: (S1 ('MetaSel ('Just "ciSources") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (HashSet SourceName)) :*: S1 ('MetaSel ('Just "ciDataConnectors") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (HashSet DataConnectorName)))))

type ValidateNewSchemaCache a = SchemaCache -> SchemaCache -> (ValidateNewSchemaCacheResult, a) Source #

Function that validates the new schema cache (usually involves checking for any metadata inconsistencies) and can decide whether or not to keep or discard the new schema cache (ValidateNewSchemaCacheResult). It can also return some arbitrary extra information that will be returned from tryBuildSchemaCacheWithOptions.

First parameter is the old schema cache, the second is the new schema cache.

newtype MetadataT m a Source #

Constructors

MetadataT 

Fields

Instances

Instances details
MonadTrans MetadataT Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Methods

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

MFunctor MetadataT Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> MetadataT m b -> MetadataT n b Source #

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

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.Types.SchemaCache.Build

Associated Types

type StM (MetadataT m) a Source #

Methods

liftBaseWith :: (RunInBase (MetadataT m) b -> b a) -> MetadataT m a Source #

restoreM :: StM (MetadataT m) a -> MetadataT m a Source #

MonadError e m => MonadError e (MetadataT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Methods

throwError :: e -> MetadataT m a #

catchError :: MetadataT m a -> (e -> MetadataT m a) -> MetadataT m a #

MonadReader r m => MonadReader r (MetadataT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Methods

ask :: MetadataT m r #

local :: (r -> r) -> MetadataT m a -> MetadataT m a #

reader :: (r -> a) -> MetadataT m a #

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

Defined in Hasura.RQL.Types.SchemaCache.Build

Methods

liftBase :: b α -> MetadataT m α Source #

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

Defined in Hasura.RQL.Types.SchemaCache.Build

Methods

liftIO :: IO a -> MetadataT m a #

Monad m => Applicative (MetadataT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Methods

pure :: a -> MetadataT m a #

(<*>) :: MetadataT m (a -> b) -> MetadataT m a -> MetadataT m b #

liftA2 :: (a -> b -> c) -> MetadataT m a -> MetadataT m b -> MetadataT m c #

(*>) :: MetadataT m a -> MetadataT m b -> MetadataT m b #

(<*) :: MetadataT m a -> MetadataT m b -> MetadataT m a #

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

Defined in Hasura.RQL.Types.SchemaCache.Build

Methods

fmap :: (a -> b) -> MetadataT m a -> MetadataT m b #

(<$) :: a -> MetadataT m b -> MetadataT m a #

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

Defined in Hasura.RQL.Types.SchemaCache.Build

Methods

(>>=) :: MetadataT m a -> (a -> MetadataT m b) -> MetadataT m b #

(>>) :: MetadataT m a -> MetadataT m b -> MetadataT m b #

return :: a -> MetadataT m a #

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

Defined in Hasura.RQL.Types.SchemaCache.Build

Methods

liftTx :: TxE QErr a -> MetadataT m a Source #

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

Defined in Hasura.Metadata.Class

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

Defined in Hasura.Metadata.Class

Methods

fetchMetadataResourceVersion :: MetadataT m (Either QErr MetadataResourceVersion) Source #

fetchMetadata :: MetadataT m (Either QErr MetadataWithResourceVersion) Source #

fetchMetadataNotifications :: MetadataResourceVersion -> InstanceId -> MetadataT m (Either QErr [(MetadataResourceVersion, CacheInvalidations)]) Source #

setMetadata :: MetadataResourceVersion -> Metadata -> MetadataT m (Either QErr MetadataResourceVersion) Source #

notifySchemaCacheSync :: MetadataResourceVersion -> InstanceId -> CacheInvalidations -> MetadataT m (Either QErr ()) Source #

getCatalogState :: MetadataT m (Either QErr CatalogState) Source #

setCatalogState :: CatalogStateType -> Value -> MetadataT m (Either QErr ()) Source #

fetchSourceIntrospection :: MetadataResourceVersion -> MetadataT m (Either QErr (Maybe StoredIntrospection)) Source #

storeSourceIntrospection :: StoredIntrospection -> MetadataResourceVersion -> MetadataT m (Either QErr ()) Source #

getMetadataDbUid :: MetadataT m (Either QErr MetadataDbId) Source #

checkMetadataStorageHealth :: MetadataT m (Either QErr ()) Source #

getDeprivedCronTriggerStats :: [TriggerName] -> MetadataT m (Either QErr [CronTriggerStats]) Source #

getScheduledEventsForDelivery :: [TriggerName] -> MetadataT m (Either QErr ([CronEvent], [OneOffScheduledEvent])) Source #

insertCronEvents :: [CronEventSeed] -> MetadataT m (Either QErr ()) Source #

insertOneOffScheduledEvent :: OneOffEvent -> MetadataT m (Either QErr EventId) Source #

insertScheduledEventInvocation :: Invocation 'ScheduledType -> ScheduledEventType -> MetadataT m (Either QErr ()) Source #

setScheduledEventOp :: ScheduledEventId -> ScheduledEventOp -> ScheduledEventType -> MetadataT m (Either QErr ()) Source #

unlockScheduledEvents :: ScheduledEventType -> [ScheduledEventId] -> MetadataT m (Either QErr Int) Source #

unlockAllLockedScheduledEvents :: MetadataT m (Either QErr ()) Source #

clearFutureCronEvents :: ClearCronEvents -> MetadataT m (Either QErr ()) Source #

getOneOffScheduledEvents :: ScheduledEventPagination -> [ScheduledEventStatus] -> RowsCountOption -> MetadataT m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent])) Source #

getCronEvents :: TriggerName -> ScheduledEventPagination -> [ScheduledEventStatus] -> RowsCountOption -> MetadataT m (Either QErr (WithOptionalTotalCount [CronEvent])) Source #

getScheduledEventInvocations :: GetScheduledEventInvocations -> MetadataT m (Either QErr (WithOptionalTotalCount [ScheduledEventInvocation])) Source #

deleteScheduledEvent :: ScheduledEventId -> ScheduledEventType -> MetadataT m (Either QErr ()) Source #

insertAction :: ActionName -> SessionVariables -> [Header] -> Value -> MetadataT m (Either QErr ActionId) Source #

fetchUndeliveredActionEvents :: MetadataT m (Either QErr [ActionLogItem]) Source #

setActionStatus :: ActionId -> AsyncActionStatus -> MetadataT m (Either QErr ()) Source #

fetchActionResponse :: ActionId -> MetadataT m (Either QErr ActionLogResponse) Source #

clearActionData :: ActionName -> MetadataT m (Either QErr ()) Source #

setProcessingActionLogsToPending :: LockedActionIdArray -> MetadataT m (Either QErr ()) Source #

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

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.DDL.EventTrigger

Monad m => MetadataM (MetadataT m) Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.Types.SchemaCache.Build

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

Defined in Hasura.RQL.Types.SchemaCache.Build

type StM (MetadataT m) a Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

type StM (MetadataT m) a = StM (StateT Metadata m) a

runMetadataT :: Metadata -> MetadataDefaults -> MetadataT m a -> m (a, Metadata) Source #

runMetadataT puts a stateful metadata in scope. MetadataDefaults is provided so that it can be considered from the --metadataDefaults arguments.

tryBuildSchemaCache :: (CacheRWM m, MetadataM m) => MetadataModifier -> m (HashMap MetadataObjId (NonEmpty InconsistentMetadata)) Source #

Rebuilds the schema cache after modifying metadata and returns any _new_ metadata inconsistencies. If there are any new inconsistencies, the changes to the metadata and the schema cache are abandoned.

tryBuildSchemaCacheWithModifiers :: (CacheRWM m, MetadataM m) => [Metadata -> m Metadata] -> m (HashMap MetadataObjId (NonEmpty InconsistentMetadata)) Source #

Rebuilds the schema cache after modifying metadata sequentially and returns any _new_ metadata inconsistencies. If there are any new inconsistencies, the changes to the metadata and the schema cache are abandoned. If the metadata modifiers run into validation issues (e.g. a native query is already tracked in the metadata), we throw these errors back without changing the metadata and schema cache.

tryBuildSchemaCacheAndWarnOnFailingObjects Source #

Arguments

:: forall m a. (CacheRWM m, MonadWarnings m, QErrM m, MetadataM m) 
=> (a -> m MetadataModifier)

Function makes a metadata modifier for a metadata object

-> WarningCode

Warning code to use for failed metadata objects

-> HashMap MetadataObjId a

Map of metadata objects to apply to metadata using the mkMetadataModifier function

-> m (HashMap MetadataObjId a)

Successfully applied metadata objects

Tries to modify the metadata for all the specified metadata objects. If the modification fails, any objects that directly caused a new metadata inconsistency are removed and the modification is attempted again without those failing objects. The failing objects are raised as warnings in MonadWarnings and the successful objects are returned. If there are metadata inconsistencies that are not directly related to the specified metadata objects, an error is thrown.

buildSchemaCacheFor :: (QErrM m, CacheRWM m, MetadataM m) => MetadataObjId -> MetadataModifier -> m () Source #

Rebuilds the schema cache after modifying metadata. If an object with the given object id became newly inconsistent, raises an error about it specifically. Otherwise, raises a generic metadata inconsistency error.

throwOnInconsistencies :: (QErrM m, CacheRWM m) => m () Source #

Requests the schema cache, and fails if there is any inconsistent metadata.

withNewInconsistentObjsCheck :: (QErrM m, CacheRM m) => m a -> m a Source #

Executes the given action, and if any new InconsistentMetadatas are added to the schema cache as a result of its execution, raises an error.

getInconsistentQueryCollections :: SchemaIntrospection -> QueryCollections -> ((CollectionName, ListedQuery) -> MetadataObject) -> EndpointTrie GQLQueryWithText -> [NormalizedQuery] -> [InconsistentMetadata] Source #

getInconsistentQueryCollections is a helper function that runs the static analysis over the saved queries and reports any inconsistenties with the current schema.

data StoredIntrospection Source #

Instances

Instances details
FromJSON StoredIntrospection Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

ToJSON StoredIntrospection Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Generic StoredIntrospection Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Associated Types

type Rep StoredIntrospection :: Type -> Type #

Eq StoredIntrospection Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

type Rep StoredIntrospection Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

type Rep StoredIntrospection = D1 ('MetaData "StoredIntrospection" "Hasura.RQL.Types.SchemaCache.Build" "graphql-engine-1.0.0-inplace" 'False) (C1 ('MetaCons "StoredIntrospection" 'PrefixI 'True) (S1 ('MetaSel ('Just "siBackendIntrospection") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (HashMap SourceName EncJSON)) :*: S1 ('MetaSel ('Just "siRemotes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (HashMap RemoteSchemaName EncJSON))))

data CollectItem Source #

Items to be collected while building schema cache See @buildSchemaCacheRule for more details.

Instances

Instances details
Show CollectItem Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build

Eq CollectItem Source # 
Instance details

Defined in Hasura.RQL.Types.SchemaCache.Build