module Hasura.GraphQL.Execute.Backend
  ( BackendExecute (..),
    DBStepInfo (..),
    ExecutionPlan,
    ExecutionStep (..),
    ExplainPlan (..),
    MonadQueryTags (..),
    convertRemoteSourceRelationship,
  )
where

import Control.Monad.Trans.Control (MonadBaseControl)
import Data.Aeson qualified as J
import Data.Aeson.Casing qualified as J
import Data.Aeson.Ordered qualified as JO
import Data.Environment as Env
import Data.Kind (Type)
import Data.Tagged
import Data.Text.Extended
import Data.Text.NonEmpty (mkNonEmptyTextUnsafe)
import Database.PG.Query qualified as Q
import Hasura.Base.Error
import Hasura.EncJSON
import Hasura.GraphQL.Execute.Action.Types (ActionExecutionPlan)
import Hasura.GraphQL.Execute.RemoteJoin.Types
import Hasura.GraphQL.Execute.Subscription.Plan
import Hasura.GraphQL.Namespace (RootFieldAlias, RootFieldMap)
import Hasura.GraphQL.Schema.Options qualified as Options
import Hasura.GraphQL.Transport.HTTP.Protocol qualified as GH
import Hasura.Metadata.Class
import Hasura.Prelude
import Hasura.QueryTags
import Hasura.RQL.DDL.Schema.Cache (CacheRWT)
import Hasura.RQL.IR
import Hasura.RQL.Types.Action
import Hasura.RQL.Types.Backend
import Hasura.RQL.Types.Column (ColumnType, fromCol)
import Hasura.RQL.Types.Common
import Hasura.RQL.Types.QueryTags (QueryTagsConfig)
import Hasura.RQL.Types.RemoteSchema
import Hasura.RQL.Types.ResultCustomization
import Hasura.RQL.Types.Run (RunT (..))
import Hasura.RQL.Types.SchemaCache.Build (MetadataT (..))
import Hasura.SQL.AnyBackend qualified as AB
import Hasura.SQL.Backend
import Hasura.Session
import Hasura.Tracing (TraceT)
import Language.GraphQL.Draft.Syntax qualified as G
import Network.HTTP.Types qualified as HTTP

-- | 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.
class
  ( Backend b,
    ToTxt (MultiplexedQuery b),
    Monad (ExecutionMonad b)
  ) =>
  BackendExecute (b :: BackendType)
  where
  -- generated query information
  type PreparedQuery b :: Type
  type MultiplexedQuery b :: Type
  type ExecutionMonad b :: Type -> Type

  -- execution plan generation
  mkDBQueryPlan ::
    forall m.
    ( MonadError QErr m,
      MonadQueryTags m,
      MonadReader QueryTagsComment m
    ) =>
    UserInfo ->
    Env.Environment ->
    SourceName ->
    SourceConfig b ->
    QueryDB b Void (UnpreparedValue b) ->
    m (DBStepInfo b)
  mkDBMutationPlan ::
    forall m.
    ( MonadError QErr m,
      MonadQueryTags m,
      MonadReader QueryTagsComment m
    ) =>
    UserInfo ->
    Options.StringifyNumbers ->
    SourceName ->
    SourceConfig b ->
    MutationDB b Void (UnpreparedValue b) ->
    m (DBStepInfo b)
  mkLiveQuerySubscriptionPlan ::
    forall m.
    ( MonadError QErr m,
      MonadIO m,
      MonadBaseControl IO m,
      MonadReader QueryTagsComment m
    ) =>
    UserInfo ->
    SourceName ->
    SourceConfig b ->
    Maybe G.Name ->
    RootFieldMap (QueryDB b Void (UnpreparedValue b)) ->
    m (SubscriptionQueryPlan b (MultiplexedQuery b))
  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))
  mkDBQueryExplain ::
    forall m.
    ( MonadError QErr m
    ) =>
    RootFieldAlias ->
    UserInfo ->
    SourceName ->
    SourceConfig b ->
    QueryDB b Void (UnpreparedValue b) ->
    m (AB.AnyBackend DBStepInfo)
  mkSubscriptionExplain ::
    ( MonadError QErr m,
      MonadIO m,
      MonadBaseControl IO m
    ) =>
    SubscriptionQueryPlan b (MultiplexedQuery b) ->
    m SubscriptionQueryPlanExplanation

  mkDBRemoteRelationshipPlan ::
    forall m.
    ( MonadError QErr m,
      MonadQueryTags m
    ) =>
    UserInfo ->
    SourceName ->
    SourceConfig b ->
    -- | List of json objects, each of which becomes a row of the table.
    NonEmpty J.Object ->
    -- | The above objects have this schema.
    HashMap FieldName (Column b, ScalarType b) ->
    -- | This is a field name from the lhs that *has* to be selected in the
    -- response along with the relationship. It is populated in
    -- `Hasura.GraphQL.Execute.RemoteJoin.Join.processRemoteJoins_` and
    -- the function `convertRemoteSourceRelationship` below assumes it
    -- to be returned as either a number or a string with a number in it
    FieldName ->
    (FieldName, SourceRelationshipSelection b Void UnpreparedValue) ->
    m (DBStepInfo 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.
convertRemoteSourceRelationship ::
  forall b.
  (Backend b) =>
  -- | Join columns for the relationship
  HashMap (Column b) (Column b) ->
  -- | The LHS of the join, this is the expression which selects from json
  -- objects
  SelectFromG b (UnpreparedValue 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
  Column b ->
  -- | This is the type of the __argument__ id column
  ColumnType b ->
  -- | The relationship column and its name (how it should be selected in the
  -- response)
  (FieldName, SourceRelationshipSelection b Void UnpreparedValue) ->
  QueryDB b Void (UnpreparedValue b)
convertRemoteSourceRelationship :: HashMap (Column b) (Column b)
-> SelectFromG b (UnpreparedValue b)
-> Column b
-> ColumnType b
-> (FieldName, SourceRelationshipSelection b Void UnpreparedValue)
-> QueryDB b Void (UnpreparedValue b)
convertRemoteSourceRelationship
  HashMap (Column b) (Column b)
columnMapping
  SelectFromG b (UnpreparedValue b)
selectFrom
  Column b
argumentIdColumn
  ColumnType b
argumentIdColumnType
  (FieldName
relationshipName, SourceRelationshipSelection b Void UnpreparedValue
relationship) =
    AnnSimpleSelectG b Void (UnpreparedValue b)
-> QueryDB b Void (UnpreparedValue b)
forall (b :: BackendType) r v.
AnnSimpleSelectG b r v -> QueryDB b r v
QDBMultipleRows AnnSimpleSelectG b Void (UnpreparedValue b)
simpleSelect
    where
      -- TODO: FieldName should have also been a wrapper around NonEmptyText
      relName :: RelName
relName = NonEmptyText -> RelName
RelName (NonEmptyText -> RelName) -> NonEmptyText -> RelName
forall a b. (a -> b) -> a -> b
$ Text -> NonEmptyText
mkNonEmptyTextUnsafe (Text -> NonEmptyText) -> Text -> NonEmptyText
forall a b. (a -> b) -> a -> b
$ FieldName -> Text
getFieldNameTxt FieldName
relationshipName

      relationshipField :: AnnFieldG b Void (UnpreparedValue b)
relationshipField = case SourceRelationshipSelection b Void UnpreparedValue
relationship of
        SourceRelationshipObject AnnObjectSelectG b Void (UnpreparedValue b)
s ->
          ObjectRelationSelectG b Void (UnpreparedValue b)
-> AnnFieldG b Void (UnpreparedValue b)
forall (b :: BackendType) r v.
ObjectRelationSelectG b r v -> AnnFieldG b r v
AFObjectRelation (ObjectRelationSelectG b Void (UnpreparedValue b)
 -> AnnFieldG b Void (UnpreparedValue b))
-> ObjectRelationSelectG b Void (UnpreparedValue b)
-> AnnFieldG b Void (UnpreparedValue b)
forall a b. (a -> b) -> a -> b
$ RelName
-> HashMap (Column b) (Column b)
-> AnnObjectSelectG b Void (UnpreparedValue b)
-> ObjectRelationSelectG b Void (UnpreparedValue b)
forall (b :: BackendType) a.
RelName
-> HashMap (Column b) (Column b) -> a -> AnnRelationSelectG b a
AnnRelationSelectG RelName
relName HashMap (Column b) (Column b)
columnMapping AnnObjectSelectG b Void (UnpreparedValue b)
s
        SourceRelationshipArray AnnSimpleSelectG b Void (UnpreparedValue b)
s ->
          ArraySelectG b Void (UnpreparedValue b)
-> AnnFieldG b Void (UnpreparedValue b)
forall (b :: BackendType) r v.
ArraySelectG b r v -> AnnFieldG b r v
AFArrayRelation (ArraySelectG b Void (UnpreparedValue b)
 -> AnnFieldG b Void (UnpreparedValue b))
-> ArraySelectG b Void (UnpreparedValue b)
-> AnnFieldG b Void (UnpreparedValue b)
forall a b. (a -> b) -> a -> b
$ ArrayRelationSelectG b Void (UnpreparedValue b)
-> ArraySelectG b Void (UnpreparedValue b)
forall (b :: BackendType) r v.
ArrayRelationSelectG b r v -> ArraySelectG b r v
ASSimple (ArrayRelationSelectG b Void (UnpreparedValue b)
 -> ArraySelectG b Void (UnpreparedValue b))
-> ArrayRelationSelectG b Void (UnpreparedValue b)
-> ArraySelectG b Void (UnpreparedValue b)
forall a b. (a -> b) -> a -> b
$ RelName
-> HashMap (Column b) (Column b)
-> AnnSimpleSelectG b Void (UnpreparedValue b)
-> ArrayRelationSelectG b Void (UnpreparedValue b)
forall (b :: BackendType) a.
RelName
-> HashMap (Column b) (Column b) -> a -> AnnRelationSelectG b a
AnnRelationSelectG RelName
relName HashMap (Column b) (Column b)
columnMapping AnnSimpleSelectG b Void (UnpreparedValue b)
s
        SourceRelationshipArrayAggregate AnnAggregateSelectG b Void (UnpreparedValue b)
s ->
          ArraySelectG b Void (UnpreparedValue b)
-> AnnFieldG b Void (UnpreparedValue b)
forall (b :: BackendType) r v.
ArraySelectG b r v -> AnnFieldG b r v
AFArrayRelation (ArraySelectG b Void (UnpreparedValue b)
 -> AnnFieldG b Void (UnpreparedValue b))
-> ArraySelectG b Void (UnpreparedValue b)
-> AnnFieldG b Void (UnpreparedValue b)
forall a b. (a -> b) -> a -> b
$ ArrayAggregateSelectG b Void (UnpreparedValue b)
-> ArraySelectG b Void (UnpreparedValue b)
forall (b :: BackendType) r v.
ArrayAggregateSelectG b r v -> ArraySelectG b r v
ASAggregate (ArrayAggregateSelectG b Void (UnpreparedValue b)
 -> ArraySelectG b Void (UnpreparedValue b))
-> ArrayAggregateSelectG b Void (UnpreparedValue b)
-> ArraySelectG b Void (UnpreparedValue b)
forall a b. (a -> b) -> a -> b
$ RelName
-> HashMap (Column b) (Column b)
-> AnnAggregateSelectG b Void (UnpreparedValue b)
-> ArrayAggregateSelectG b Void (UnpreparedValue b)
forall (b :: BackendType) a.
RelName
-> HashMap (Column b) (Column b) -> a -> AnnRelationSelectG b a
AnnRelationSelectG RelName
relName HashMap (Column b) (Column b)
columnMapping AnnAggregateSelectG b Void (UnpreparedValue b)
s

      argumentIdField :: (FieldName, AnnFieldG b Void (UnpreparedValue b))
argumentIdField =
        ( Column b -> FieldName
forall (b :: BackendType). Backend b => Column b -> FieldName
fromCol @b Column b
argumentIdColumn,
          AnnColumnField b (UnpreparedValue b)
-> AnnFieldG b Void (UnpreparedValue b)
forall (b :: BackendType) r v.
AnnColumnField b v -> AnnFieldG b r v
AFColumn (AnnColumnField b (UnpreparedValue b)
 -> AnnFieldG b Void (UnpreparedValue b))
-> AnnColumnField b (UnpreparedValue b)
-> AnnFieldG b Void (UnpreparedValue b)
forall a b. (a -> b) -> a -> b
$
            AnnColumnField :: forall (b :: BackendType) v.
Column b
-> ColumnType b
-> Bool
-> Maybe (ScalarSelectionArguments b)
-> Maybe (AnnColumnCaseBoolExp b v)
-> AnnColumnField b v
AnnColumnField
              { $sel:_acfColumn:AnnColumnField :: Column b
_acfColumn = Column b
argumentIdColumn,
                $sel:_acfType:AnnColumnField :: ColumnType b
_acfType = ColumnType b
argumentIdColumnType,
                $sel:_acfAsText:AnnColumnField :: Bool
_acfAsText = Bool
False,
                $sel:_acfArguments:AnnColumnField :: Maybe (ScalarSelectionArguments b)
_acfArguments = Maybe (ScalarSelectionArguments b)
forall a. Maybe a
Nothing,
                $sel:_acfCaseBoolExpression:AnnColumnField :: Maybe (AnnColumnCaseBoolExp b (UnpreparedValue b))
_acfCaseBoolExpression = Maybe (AnnColumnCaseBoolExp b (UnpreparedValue b))
forall a. Maybe a
Nothing
              }
        )

      simpleSelect :: AnnSimpleSelectG b Void (UnpreparedValue b)
simpleSelect =
        AnnSelectG :: forall (b :: BackendType) (f :: * -> *) v.
Fields (f v)
-> SelectFromG b v
-> TablePermG b v
-> SelectArgsG b v
-> StringifyNumbers
-> Maybe NamingCase
-> AnnSelectG b f v
AnnSelectG
          { $sel:_asnFields:AnnSelectG :: Fields (AnnFieldG b Void (UnpreparedValue b))
_asnFields = [(FieldName, AnnFieldG b Void (UnpreparedValue b))
argumentIdField, (FieldName
relationshipName, AnnFieldG b Void (UnpreparedValue b)
relationshipField)],
            $sel:_asnFrom:AnnSelectG :: SelectFromG b (UnpreparedValue b)
_asnFrom = SelectFromG b (UnpreparedValue b)
selectFrom,
            $sel:_asnPerm:AnnSelectG :: TablePermG b (UnpreparedValue b)
_asnPerm = AnnBoolExp b (UnpreparedValue b)
-> Maybe Int -> TablePermG b (UnpreparedValue b)
forall (b :: BackendType) v.
AnnBoolExp b v -> Maybe Int -> TablePermG b v
TablePerm AnnBoolExp b (UnpreparedValue b)
forall (backend :: BackendType) scalar. AnnBoolExp backend scalar
annBoolExpTrue Maybe Int
forall a. Maybe a
Nothing,
            $sel:_asnArgs:AnnSelectG :: SelectArgsG b (UnpreparedValue b)
_asnArgs = SelectArgsG b (UnpreparedValue b)
forall (backend :: BackendType) v. SelectArgsG backend v
noSelectArgs,
            $sel:_asnStrfyNum:AnnSelectG :: StringifyNumbers
_asnStrfyNum = StringifyNumbers
Options.Don'tStringifyNumbers,
            $sel:_asnNamingConvention:AnnSelectG :: Maybe NamingCase
_asnNamingConvention = Maybe NamingCase
forall a. Maybe a
Nothing
          }

data DBStepInfo b = DBStepInfo
  { DBStepInfo b -> SourceName
dbsiSourceName :: SourceName,
    DBStepInfo b -> SourceConfig b
dbsiSourceConfig :: SourceConfig b,
    DBStepInfo b -> Maybe (PreparedQuery b)
dbsiPreparedQuery :: Maybe (PreparedQuery b),
    DBStepInfo b -> ExecutionMonad b EncJSON
dbsiAction :: ExecutionMonad b EncJSON
  }

-- | 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.
data ExplainPlan = ExplainPlan
  { ExplainPlan -> RootFieldAlias
_fpField :: !RootFieldAlias,
    ExplainPlan -> Maybe Text
_fpSql :: !(Maybe Text),
    ExplainPlan -> Maybe [Text]
_fpPlan :: !(Maybe [Text])
  }
  deriving (Int -> ExplainPlan -> ShowS
[ExplainPlan] -> ShowS
ExplainPlan -> String
(Int -> ExplainPlan -> ShowS)
-> (ExplainPlan -> String)
-> ([ExplainPlan] -> ShowS)
-> Show ExplainPlan
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExplainPlan] -> ShowS
$cshowList :: [ExplainPlan] -> ShowS
show :: ExplainPlan -> String
$cshow :: ExplainPlan -> String
showsPrec :: Int -> ExplainPlan -> ShowS
$cshowsPrec :: Int -> ExplainPlan -> ShowS
Show, ExplainPlan -> ExplainPlan -> Bool
(ExplainPlan -> ExplainPlan -> Bool)
-> (ExplainPlan -> ExplainPlan -> Bool) -> Eq ExplainPlan
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExplainPlan -> ExplainPlan -> Bool
$c/= :: ExplainPlan -> ExplainPlan -> Bool
== :: ExplainPlan -> ExplainPlan -> Bool
$c== :: ExplainPlan -> ExplainPlan -> Bool
Eq, (forall x. ExplainPlan -> Rep ExplainPlan x)
-> (forall x. Rep ExplainPlan x -> ExplainPlan)
-> Generic ExplainPlan
forall x. Rep ExplainPlan x -> ExplainPlan
forall x. ExplainPlan -> Rep ExplainPlan x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExplainPlan x -> ExplainPlan
$cfrom :: forall x. ExplainPlan -> Rep ExplainPlan x
Generic)

instance J.ToJSON ExplainPlan where
  toJSON :: ExplainPlan -> Value
toJSON = Options -> ExplainPlan -> Value
forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Options -> a -> Value
J.genericToJSON (Options -> ExplainPlan -> Value)
-> Options -> ExplainPlan -> Value
forall a b. (a -> b) -> a -> b
$ ShowS -> Options
J.aesonPrefix ShowS
J.camelCase

-- | One execution step to processing a GraphQL query (e.g. one root field).
data ExecutionStep where
  -- | A query to execute against the database
  ExecStepDB ::
    HTTP.ResponseHeaders ->
    AB.AnyBackend DBStepInfo ->
    Maybe RemoteJoins ->
    ExecutionStep
  -- | Execute an action
  ExecStepAction ::
    ActionExecutionPlan ->
    ActionsInfo ->
    Maybe RemoteJoins ->
    ExecutionStep
  -- | A graphql query to execute against a remote schema
  ExecStepRemote ::
    !RemoteSchemaInfo ->
    !ResultCustomizer ->
    !GH.GQLReqOutgoing ->
    Maybe RemoteJoins ->
    ExecutionStep
  -- | Output a plain JSON object
  ExecStepRaw ::
    JO.Value ->
    ExecutionStep
  ExecStepMulti ::
    [ExecutionStep] ->
    ExecutionStep

-- | 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.
type ExecutionPlan = RootFieldMap ExecutionStep

class (Monad m) => MonadQueryTags m where
  -- | Creates Query Tags. These are appended to the Generated SQL.
  -- Helps users to use native database monitoring tools to get some 'application-context'.
  createQueryTags ::
    QueryTagsAttributes -> Maybe QueryTagsConfig -> Tagged m QueryTagsComment

instance (MonadQueryTags m) => MonadQueryTags (ReaderT r m) where
  createQueryTags :: QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged (ReaderT r m) QueryTagsComment
createQueryTags QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr = Tagged m QueryTagsComment -> Tagged (ReaderT r m) QueryTagsComment
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag (QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
forall (m :: * -> *).
MonadQueryTags m =>
QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
createQueryTags @m QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr) :: Tagged (ReaderT r m) QueryTagsComment

instance (MonadQueryTags m) => MonadQueryTags (ExceptT e m) where
  createQueryTags :: QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged (ExceptT e m) QueryTagsComment
createQueryTags QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr = Tagged m QueryTagsComment -> Tagged (ExceptT e m) QueryTagsComment
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag (QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
forall (m :: * -> *).
MonadQueryTags m =>
QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
createQueryTags @m QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr) :: Tagged (ExceptT e m) QueryTagsComment

instance (MonadQueryTags m) => MonadQueryTags (TraceT m) where
  createQueryTags :: QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged (TraceT m) QueryTagsComment
createQueryTags QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr = Tagged m QueryTagsComment -> Tagged (TraceT m) QueryTagsComment
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag (QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
forall (m :: * -> *).
MonadQueryTags m =>
QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
createQueryTags @m QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr) :: Tagged (TraceT m) QueryTagsComment

instance (MonadQueryTags m) => MonadQueryTags (MetadataStorageT m) where
  createQueryTags :: QueryTagsAttributes
-> Maybe QueryTagsConfig
-> Tagged (MetadataStorageT m) QueryTagsComment
createQueryTags QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr = Tagged m QueryTagsComment
-> Tagged (MetadataStorageT m) QueryTagsComment
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag (QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
forall (m :: * -> *).
MonadQueryTags m =>
QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
createQueryTags @m QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr) :: Tagged (MetadataStorageT m) QueryTagsComment

instance (MonadQueryTags m) => MonadQueryTags (Q.TxET QErr m) where
  createQueryTags :: QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged (TxET QErr m) QueryTagsComment
createQueryTags QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr = Tagged m QueryTagsComment -> Tagged (TxET QErr m) QueryTagsComment
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag (QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
forall (m :: * -> *).
MonadQueryTags m =>
QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
createQueryTags @m QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr) :: Tagged (Q.TxET QErr m) QueryTagsComment

instance (MonadQueryTags m) => MonadQueryTags (MetadataT m) where
  createQueryTags :: QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged (MetadataT m) QueryTagsComment
createQueryTags QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr = Tagged m QueryTagsComment -> Tagged (MetadataT m) QueryTagsComment
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag (QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
forall (m :: * -> *).
MonadQueryTags m =>
QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
createQueryTags @m QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr) :: Tagged (MetadataT m) QueryTagsComment

instance (MonadQueryTags m) => MonadQueryTags (CacheRWT m) where
  createQueryTags :: QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged (CacheRWT m) QueryTagsComment
createQueryTags QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr = Tagged m QueryTagsComment -> Tagged (CacheRWT m) QueryTagsComment
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag (QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
forall (m :: * -> *).
MonadQueryTags m =>
QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
createQueryTags @m QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr) :: Tagged (CacheRWT m) QueryTagsComment

instance (MonadQueryTags m) => MonadQueryTags (RunT m) where
  createQueryTags :: QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged (RunT m) QueryTagsComment
createQueryTags QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr = Tagged m QueryTagsComment -> Tagged (RunT m) QueryTagsComment
forall k1 k2 (s :: k1) b (t :: k2). Tagged s b -> Tagged t b
retag (QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
forall (m :: * -> *).
MonadQueryTags m =>
QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
createQueryTags @m QueryTagsAttributes
qtSourceConfig Maybe QueryTagsConfig
attr) :: Tagged (RunT m) QueryTagsComment