2021-11-04 19:08:33 +03:00
|
|
|
module Hasura.GraphQL.Transport.Backend
|
|
|
|
( BackendTransport (..),
|
|
|
|
)
|
|
|
|
where
|
2021-02-12 06:04:09 +03:00
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
import Data.ByteString qualified as B
|
|
|
|
import Hasura.Base.Error
|
|
|
|
import Hasura.EncJSON
|
|
|
|
import Hasura.GraphQL.Execute.Backend
|
|
|
|
import Hasura.GraphQL.Execute.LiveQuery.Plan
|
|
|
|
import Hasura.GraphQL.Logging (MonadQueryLog)
|
2021-10-29 17:42:07 +03:00
|
|
|
import Hasura.GraphQL.Namespace (RootFieldAlias)
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.GraphQL.Transport.HTTP.Protocol
|
|
|
|
import Hasura.Logging qualified as L
|
|
|
|
import Hasura.Prelude
|
|
|
|
import Hasura.RQL.Types.Backend
|
|
|
|
import Hasura.SQL.Backend
|
|
|
|
import Hasura.Server.Types (RequestId)
|
|
|
|
import Hasura.Session
|
|
|
|
import Hasura.Tracing
|
2021-02-12 06:04:09 +03:00
|
|
|
|
|
|
|
-- | This typeclass enacapsulates how a given backend sends queries and mutations over the
|
|
|
|
-- network. Each backend is currently responsible for both logging and tracing, for now.
|
2021-02-20 16:45:49 +03:00
|
|
|
class BackendExecute b => BackendTransport (b :: BackendType) where
|
2021-09-24 01:56:37 +03:00
|
|
|
runDBQuery ::
|
|
|
|
forall m.
|
|
|
|
( MonadIO m,
|
|
|
|
MonadError QErr m,
|
|
|
|
MonadQueryLog m,
|
|
|
|
MonadTrace m
|
|
|
|
) =>
|
|
|
|
RequestId ->
|
|
|
|
GQLReqUnparsed ->
|
2021-10-29 17:42:07 +03:00
|
|
|
RootFieldAlias ->
|
2021-09-24 01:56:37 +03:00
|
|
|
UserInfo ->
|
|
|
|
L.Logger L.Hasura ->
|
|
|
|
SourceConfig b ->
|
|
|
|
ExecutionMonad b EncJSON ->
|
|
|
|
Maybe (PreparedQuery b) ->
|
|
|
|
m (DiffTime, EncJSON)
|
|
|
|
runDBMutation ::
|
|
|
|
forall m.
|
|
|
|
( MonadIO m,
|
|
|
|
MonadError QErr m,
|
|
|
|
MonadQueryLog m,
|
|
|
|
MonadTrace m
|
|
|
|
) =>
|
|
|
|
RequestId ->
|
|
|
|
GQLReqUnparsed ->
|
2021-10-29 17:42:07 +03:00
|
|
|
RootFieldAlias ->
|
2021-09-24 01:56:37 +03:00
|
|
|
UserInfo ->
|
|
|
|
L.Logger L.Hasura ->
|
|
|
|
SourceConfig b ->
|
|
|
|
ExecutionMonad b EncJSON ->
|
|
|
|
Maybe (PreparedQuery b) ->
|
|
|
|
m (DiffTime, EncJSON)
|
|
|
|
runDBSubscription ::
|
|
|
|
forall m.
|
|
|
|
MonadIO m =>
|
|
|
|
SourceConfig b ->
|
|
|
|
MultiplexedQuery b ->
|
|
|
|
-- | WARNING: Postgres-specific, ignored by other backends
|
|
|
|
[(CohortId, CohortVariables)] ->
|
|
|
|
m (DiffTime, Either QErr [(CohortId, B.ByteString)])
|
|
|
|
runDBQueryExplain ::
|
|
|
|
forall m.
|
|
|
|
( MonadIO m,
|
|
|
|
MonadError QErr m
|
|
|
|
) =>
|
|
|
|
DBStepInfo b ->
|
|
|
|
m EncJSON
|