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

Hasura.GraphQL.Execute.Backend

Synopsis

Documentation

class (Backend b, ToTxt (MultiplexedQuery b), Monad (ExecutionMonad b)) => BackendExecute (b :: BackendType) where Source #

This typeclass enacapsulates how a given backend translates a root field into an execution plan. For now, each root field maps to one execution step, but in the future, when we have a client-side dataloader, each root field might translate into a multi-step plan.

Associated Types

type PreparedQuery b :: Type Source #

type MultiplexedQuery b :: Type Source #

type ExecutionMonad b :: Type -> Type Source #

Methods

mkDBQueryPlan :: forall m. (MonadError QErr m, MonadQueryTags m, MonadReader QueryTagsComment m) => UserInfo -> Environment -> SourceName -> SourceConfig b -> QueryDB b Void (UnpreparedValue b) -> m (DBStepInfo b) Source #

mkDBMutationPlan :: forall m. (MonadError QErr m, MonadQueryTags m, MonadReader QueryTagsComment m) => UserInfo -> StringifyNumbers -> SourceName -> SourceConfig b -> MutationDB b Void (UnpreparedValue b) -> m (DBStepInfo b) Source #

mkLiveQuerySubscriptionPlan :: forall m. (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig b -> Maybe Name -> RootFieldMap (QueryDB b Void (UnpreparedValue b)) -> m (SubscriptionQueryPlan b (MultiplexedQuery b)) Source #

mkDBStreamingSubscriptionPlan :: forall m. (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig b -> (RootFieldAlias, QueryDB b Void (UnpreparedValue b)) -> m (SubscriptionQueryPlan b (MultiplexedQuery b)) Source #

mkDBQueryExplain :: forall m. MonadError QErr m => RootFieldAlias -> UserInfo -> SourceName -> SourceConfig b -> QueryDB b Void (UnpreparedValue b) -> m (AnyBackend DBStepInfo) Source #

mkSubscriptionExplain :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m) => SubscriptionQueryPlan b (MultiplexedQuery b) -> m SubscriptionQueryPlanExplanation Source #

mkDBRemoteRelationshipPlan Source #

Arguments

:: forall m. (MonadError QErr m, MonadQueryTags m) 
=> UserInfo 
-> SourceName 
-> SourceConfig b 
-> NonEmpty Object

List of json objects, each of which becomes a row of the table.

-> HashMap FieldName (Column b, ScalarType b)

The above objects have this schema.

-> FieldName

This is a field name from the lhs that *has* to be selected in the response along with the relationship. It is populated in processRemoteJoins_ and the function convertRemoteSourceRelationship below assumes it to be returned as either a number or a string with a number in it

-> (FieldName, SourceRelationshipSelection b Void UnpreparedValue) 
-> m (DBStepInfo b) 

Instances

Instances details
BackendExecute 'MSSQL Source # 
Instance details

Defined in Hasura.Backends.MSSQL.Instances.Execute

Methods

mkDBQueryPlan :: (MonadError QErr m, MonadQueryTags m, MonadReader QueryTagsComment m) => UserInfo -> Environment -> SourceName -> SourceConfig 'MSSQL -> QueryDB 'MSSQL Void (UnpreparedValue 'MSSQL) -> m (DBStepInfo 'MSSQL) Source #

mkDBMutationPlan :: (MonadError QErr m, MonadQueryTags m, MonadReader QueryTagsComment m) => UserInfo -> StringifyNumbers -> SourceName -> SourceConfig 'MSSQL -> MutationDB 'MSSQL Void (UnpreparedValue 'MSSQL) -> m (DBStepInfo 'MSSQL) Source #

mkLiveQuerySubscriptionPlan :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig 'MSSQL -> Maybe Name -> RootFieldMap (QueryDB 'MSSQL Void (UnpreparedValue 'MSSQL)) -> m (SubscriptionQueryPlan 'MSSQL (MultiplexedQuery 'MSSQL)) Source #

mkDBStreamingSubscriptionPlan :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig 'MSSQL -> (RootFieldAlias, QueryDB 'MSSQL Void (UnpreparedValue 'MSSQL)) -> m (SubscriptionQueryPlan 'MSSQL (MultiplexedQuery 'MSSQL)) Source #

mkDBQueryExplain :: MonadError QErr m => RootFieldAlias -> UserInfo -> SourceName -> SourceConfig 'MSSQL -> QueryDB 'MSSQL Void (UnpreparedValue 'MSSQL) -> m (AnyBackend DBStepInfo) Source #

mkSubscriptionExplain :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m) => SubscriptionQueryPlan 'MSSQL (MultiplexedQuery 'MSSQL) -> m SubscriptionQueryPlanExplanation Source #

mkDBRemoteRelationshipPlan :: (MonadError QErr m, MonadQueryTags m) => UserInfo -> SourceName -> SourceConfig 'MSSQL -> NonEmpty Object -> HashMap FieldName (Column 'MSSQL, ScalarType 'MSSQL) -> FieldName -> (FieldName, SourceRelationshipSelection 'MSSQL Void UnpreparedValue) -> m (DBStepInfo 'MSSQL) Source #

BackendExecute 'BigQuery Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Instances.Execute

Methods

mkDBQueryPlan :: (MonadError QErr m, MonadQueryTags m, MonadReader QueryTagsComment m) => UserInfo -> Environment -> SourceName -> SourceConfig 'BigQuery -> QueryDB 'BigQuery Void (UnpreparedValue 'BigQuery) -> m (DBStepInfo 'BigQuery) Source #

mkDBMutationPlan :: (MonadError QErr m, MonadQueryTags m, MonadReader QueryTagsComment m) => UserInfo -> StringifyNumbers -> SourceName -> SourceConfig 'BigQuery -> MutationDB 'BigQuery Void (UnpreparedValue 'BigQuery) -> m (DBStepInfo 'BigQuery) Source #

mkLiveQuerySubscriptionPlan :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig 'BigQuery -> Maybe Name -> RootFieldMap (QueryDB 'BigQuery Void (UnpreparedValue 'BigQuery)) -> m (SubscriptionQueryPlan 'BigQuery (MultiplexedQuery 'BigQuery)) Source #

mkDBStreamingSubscriptionPlan :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig 'BigQuery -> (RootFieldAlias, QueryDB 'BigQuery Void (UnpreparedValue 'BigQuery)) -> m (SubscriptionQueryPlan 'BigQuery (MultiplexedQuery 'BigQuery)) Source #

mkDBQueryExplain :: MonadError QErr m => RootFieldAlias -> UserInfo -> SourceName -> SourceConfig 'BigQuery -> QueryDB 'BigQuery Void (UnpreparedValue 'BigQuery) -> m (AnyBackend DBStepInfo) Source #

mkSubscriptionExplain :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m) => SubscriptionQueryPlan 'BigQuery (MultiplexedQuery 'BigQuery) -> m SubscriptionQueryPlanExplanation Source #

mkDBRemoteRelationshipPlan :: (MonadError QErr m, MonadQueryTags m) => UserInfo -> SourceName -> SourceConfig 'BigQuery -> NonEmpty Object -> HashMap FieldName (Column 'BigQuery, ScalarType 'BigQuery) -> FieldName -> (FieldName, SourceRelationshipSelection 'BigQuery Void UnpreparedValue) -> m (DBStepInfo 'BigQuery) Source #

BackendExecute 'MySQL Source # 
Instance details

Defined in Hasura.Backends.MySQL.Instances.Execute

Methods

mkDBQueryPlan :: (MonadError QErr m, MonadQueryTags m, MonadReader QueryTagsComment m) => UserInfo -> Environment -> SourceName -> SourceConfig 'MySQL -> QueryDB 'MySQL Void (UnpreparedValue 'MySQL) -> m (DBStepInfo 'MySQL) Source #

mkDBMutationPlan :: (MonadError QErr m, MonadQueryTags m, MonadReader QueryTagsComment m) => UserInfo -> StringifyNumbers -> SourceName -> SourceConfig 'MySQL -> MutationDB 'MySQL Void (UnpreparedValue 'MySQL) -> m (DBStepInfo 'MySQL) Source #

mkLiveQuerySubscriptionPlan :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig 'MySQL -> Maybe Name -> RootFieldMap (QueryDB 'MySQL Void (UnpreparedValue 'MySQL)) -> m (SubscriptionQueryPlan 'MySQL (MultiplexedQuery 'MySQL)) Source #

mkDBStreamingSubscriptionPlan :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig 'MySQL -> (RootFieldAlias, QueryDB 'MySQL Void (UnpreparedValue 'MySQL)) -> m (SubscriptionQueryPlan 'MySQL (MultiplexedQuery 'MySQL)) Source #

mkDBQueryExplain :: MonadError QErr m => RootFieldAlias -> UserInfo -> SourceName -> SourceConfig 'MySQL -> QueryDB 'MySQL Void (UnpreparedValue 'MySQL) -> m (AnyBackend DBStepInfo) Source #

mkSubscriptionExplain :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m) => SubscriptionQueryPlan 'MySQL (MultiplexedQuery 'MySQL) -> m SubscriptionQueryPlanExplanation Source #

mkDBRemoteRelationshipPlan :: (MonadError QErr m, MonadQueryTags m) => UserInfo -> SourceName -> SourceConfig 'MySQL -> NonEmpty Object -> HashMap FieldName (Column 'MySQL, ScalarType 'MySQL) -> FieldName -> (FieldName, SourceRelationshipSelection 'MySQL Void UnpreparedValue) -> m (DBStepInfo 'MySQL) Source #

BackendExecute 'DataConnector Source # 
Instance details

Defined in Hasura.Backends.DataConnector.Adapter.Execute

Methods

mkDBQueryPlan :: (MonadError QErr m, MonadQueryTags m, MonadReader QueryTagsComment m) => UserInfo -> Environment -> SourceName -> SourceConfig 'DataConnector -> QueryDB 'DataConnector Void (UnpreparedValue 'DataConnector) -> m (DBStepInfo 'DataConnector) Source #

mkDBMutationPlan :: (MonadError QErr m, MonadQueryTags m, MonadReader QueryTagsComment m) => UserInfo -> StringifyNumbers -> SourceName -> SourceConfig 'DataConnector -> MutationDB 'DataConnector Void (UnpreparedValue 'DataConnector) -> m (DBStepInfo 'DataConnector) Source #

mkLiveQuerySubscriptionPlan :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig 'DataConnector -> Maybe Name -> RootFieldMap (QueryDB 'DataConnector Void (UnpreparedValue 'DataConnector)) -> m (SubscriptionQueryPlan 'DataConnector (MultiplexedQuery 'DataConnector)) Source #

mkDBStreamingSubscriptionPlan :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig 'DataConnector -> (RootFieldAlias, QueryDB 'DataConnector Void (UnpreparedValue 'DataConnector)) -> m (SubscriptionQueryPlan 'DataConnector (MultiplexedQuery 'DataConnector)) Source #

mkDBQueryExplain :: MonadError QErr m => RootFieldAlias -> UserInfo -> SourceName -> SourceConfig 'DataConnector -> QueryDB 'DataConnector Void (UnpreparedValue 'DataConnector) -> m (AnyBackend DBStepInfo) Source #

mkSubscriptionExplain :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m) => SubscriptionQueryPlan 'DataConnector (MultiplexedQuery 'DataConnector) -> m SubscriptionQueryPlanExplanation Source #

mkDBRemoteRelationshipPlan :: (MonadError QErr m, MonadQueryTags m) => UserInfo -> SourceName -> SourceConfig 'DataConnector -> NonEmpty Object -> HashMap FieldName (Column 'DataConnector, ScalarType 'DataConnector) -> FieldName -> (FieldName, SourceRelationshipSelection 'DataConnector Void UnpreparedValue) -> m (DBStepInfo 'DataConnector) Source #

(Backend ('Postgres pgKind), PostgresAnnotatedFieldJSON pgKind) => BackendExecute ('Postgres pgKind) Source # 
Instance details

Defined in Hasura.Backends.Postgres.Instances.Execute

Associated Types

type PreparedQuery ('Postgres pgKind) Source #

type MultiplexedQuery ('Postgres pgKind) Source #

type ExecutionMonad ('Postgres pgKind) :: Type -> Type Source #

Methods

mkDBQueryPlan :: (MonadError QErr m, MonadQueryTags m, MonadReader QueryTagsComment m) => UserInfo -> Environment -> SourceName -> SourceConfig ('Postgres pgKind) -> QueryDB ('Postgres pgKind) Void (UnpreparedValue ('Postgres pgKind)) -> m (DBStepInfo ('Postgres pgKind)) Source #

mkDBMutationPlan :: (MonadError QErr m, MonadQueryTags m, MonadReader QueryTagsComment m) => UserInfo -> StringifyNumbers -> SourceName -> SourceConfig ('Postgres pgKind) -> MutationDB ('Postgres pgKind) Void (UnpreparedValue ('Postgres pgKind)) -> m (DBStepInfo ('Postgres pgKind)) Source #

mkLiveQuerySubscriptionPlan :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig ('Postgres pgKind) -> Maybe Name -> RootFieldMap (QueryDB ('Postgres pgKind) Void (UnpreparedValue ('Postgres pgKind))) -> m (SubscriptionQueryPlan ('Postgres pgKind) (MultiplexedQuery ('Postgres pgKind))) Source #

mkDBStreamingSubscriptionPlan :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m, MonadReader QueryTagsComment m) => UserInfo -> SourceName -> SourceConfig ('Postgres pgKind) -> (RootFieldAlias, QueryDB ('Postgres pgKind) Void (UnpreparedValue ('Postgres pgKind))) -> m (SubscriptionQueryPlan ('Postgres pgKind) (MultiplexedQuery ('Postgres pgKind))) Source #

mkDBQueryExplain :: MonadError QErr m => RootFieldAlias -> UserInfo -> SourceName -> SourceConfig ('Postgres pgKind) -> QueryDB ('Postgres pgKind) Void (UnpreparedValue ('Postgres pgKind)) -> m (AnyBackend DBStepInfo) Source #

mkSubscriptionExplain :: (MonadError QErr m, MonadIO m, MonadBaseControl IO m) => SubscriptionQueryPlan ('Postgres pgKind) (MultiplexedQuery ('Postgres pgKind)) -> m SubscriptionQueryPlanExplanation Source #

mkDBRemoteRelationshipPlan :: (MonadError QErr m, MonadQueryTags m) => UserInfo -> SourceName -> SourceConfig ('Postgres pgKind) -> NonEmpty Object -> HashMap FieldName (Column ('Postgres pgKind), ScalarType ('Postgres pgKind)) -> FieldName -> (FieldName, SourceRelationshipSelection ('Postgres pgKind) Void UnpreparedValue) -> m (DBStepInfo ('Postgres pgKind)) Source #

convertRemoteSourceRelationship Source #

Arguments

:: forall b. Backend b 
=> HashMap (Column b) (Column b)

Join columns for the relationship

-> SelectFromG b (UnpreparedValue b)

The LHS of the join, this is the expression which selects from json objects

-> Column b

This is the argument id column, that needs to be added to the response This is used by by the remote joins processing logic to convert the response from upstream to join indices

-> ColumnType b

This is the type of the argument id column

-> (FieldName, SourceRelationshipSelection b Void UnpreparedValue)

The relationship column and its name (how it should be selected in the response)

-> QueryDB b Void (UnpreparedValue b) 

This is a helper function to convert a remote source's relationship to a normal relationship to a temporary table. This function can be used to implement executeRemoteRelationship function in databases which support constructing a temporary table for a list of json objects.

data ExplainPlan Source #

The result of an explain query: for a given root field (denoted by its name): the generated SQL query, and the detailed explanation obtained from the database (if any). We mostly use this type as an intermediary step, and immediately tranform any value we obtain into an equivalent JSON representation.

Constructors

ExplainPlan 

Fields

Instances

Instances details
Eq ExplainPlan Source # 
Instance details

Defined in Hasura.GraphQL.Execute.Backend

Show ExplainPlan Source # 
Instance details

Defined in Hasura.GraphQL.Execute.Backend

Generic ExplainPlan Source # 
Instance details

Defined in Hasura.GraphQL.Execute.Backend

Associated Types

type Rep ExplainPlan :: Type -> Type #

ToJSON ExplainPlan Source # 
Instance details

Defined in Hasura.GraphQL.Execute.Backend

Methods

toJSON :: ExplainPlan -> Value

toEncoding :: ExplainPlan -> Encoding

toJSONList :: [ExplainPlan] -> Value

toEncodingList :: [ExplainPlan] -> Encoding

type Rep ExplainPlan Source # 
Instance details

Defined in Hasura.GraphQL.Execute.Backend

type Rep ExplainPlan = D1 ('MetaData "ExplainPlan" "Hasura.GraphQL.Execute.Backend" "graphql-engine-1.0.0-inplace" 'False) (C1 ('MetaCons "ExplainPlan" 'PrefixI 'True) (S1 ('MetaSel ('Just "_fpField") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RootFieldAlias) :*: (S1 ('MetaSel ('Just "_fpSql") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "_fpPlan") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe [Text])))))

data ExecutionStep where Source #

One execution step to processing a GraphQL query (e.g. one root field).

Constructors

ExecStepDB :: ResponseHeaders -> AnyBackend DBStepInfo -> Maybe RemoteJoins -> ExecutionStep

A query to execute against the database

ExecStepAction :: ActionExecutionPlan -> ActionsInfo -> Maybe RemoteJoins -> ExecutionStep

Execute an action

ExecStepRemote :: !RemoteSchemaInfo -> !ResultCustomizer -> !GQLReqOutgoing -> Maybe RemoteJoins -> ExecutionStep

A graphql query to execute against a remote schema

ExecStepRaw :: Value -> ExecutionStep

Output a plain JSON object

ExecStepMulti :: [ExecutionStep] -> ExecutionStep 

type ExecutionPlan = RootFieldMap ExecutionStep Source #

The series of steps that need to be executed for a given query. For now, those steps are all independent. In the future, when we implement a client-side dataloader and generalized joins, this will need to be changed into an annotated tree.

class Monad m => MonadQueryTags m where Source #

Methods

createQueryTags :: QueryTagsAttributes -> Maybe QueryTagsConfig -> Tagged m QueryTagsComment Source #

Creates Query Tags. These are appended to the Generated SQL. Helps users to use native database monitoring tools to get some 'application-context'.

Instances

Instances details
MonadQueryTags m => MonadQueryTags (TraceT m) Source # 
Instance details

Defined in Hasura.GraphQL.Execute.Backend

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

Defined in Hasura.GraphQL.Execute.Backend

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

Defined in Hasura.GraphQL.Execute.Backend

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

Defined in Hasura.GraphQL.Execute.Backend

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

Defined in Hasura.GraphQL.Execute.Backend

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

Defined in Hasura.App

MonadQueryTags m => MonadQueryTags (ExceptT e m) Source # 
Instance details

Defined in Hasura.GraphQL.Execute.Backend

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

Defined in Hasura.GraphQL.Execute.Backend

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

Defined in Hasura.GraphQL.Execute.Backend