2021-11-04 19:08:33 +03:00
|
|
|
module Hasura.GraphQL.Transport.Backend
|
|
|
|
( BackendTransport (..),
|
|
|
|
)
|
|
|
|
where
|
2021-02-12 06:04:09 +03:00
|
|
|
|
2021-02-20 16:45:49 +03:00
|
|
|
import Data.ByteString qualified as B
|
2021-05-11 18:18:31 +03:00
|
|
|
import Hasura.Base.Error
|
2021-02-12 06:04:09 +03:00
|
|
|
import Hasura.EncJSON
|
|
|
|
import Hasura.GraphQL.Execute.Backend
|
2022-03-21 13:39:49 +03:00
|
|
|
import Hasura.GraphQL.Execute.Subscription.Plan
|
2021-03-13 17:40:50 +03:00
|
|
|
import Hasura.GraphQL.Logging (MonadQueryLog)
|
2021-10-29 17:42:07 +03:00
|
|
|
import Hasura.GraphQL.Namespace (RootFieldAlias)
|
2021-02-12 06:04:09 +03:00
|
|
|
import Hasura.GraphQL.Transport.HTTP.Protocol
|
|
|
|
import Hasura.Logging qualified as L
|
|
|
|
import Hasura.Prelude
|
2021-02-14 09:07:52 +03:00
|
|
|
import Hasura.RQL.Types.Backend
|
2021-02-12 06:04:09 +03:00
|
|
|
import Hasura.SQL.Backend
|
|
|
|
import Hasura.Server.Types (RequestId)
|
|
|
|
import Hasura.Session
|
|
|
|
import Hasura.Tracing
|
|
|
|
|
|
|
|
-- | 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-02-12 06:04:09 +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-02-12 06:04:09 +03:00
|
|
|
UserInfo ->
|
|
|
|
L.Logger L.Hasura ->
|
|
|
|
SourceConfig b ->
|
2021-02-20 16:45:49 +03:00
|
|
|
ExecutionMonad b EncJSON ->
|
2021-02-12 06:04:09 +03:00
|
|
|
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-02-12 06:04:09 +03:00
|
|
|
UserInfo ->
|
|
|
|
L.Logger L.Hasura ->
|
|
|
|
SourceConfig b ->
|
2021-02-20 16:45:49 +03:00
|
|
|
ExecutionMonad b EncJSON ->
|
2021-02-12 06:04:09 +03:00
|
|
|
Maybe (PreparedQuery b) ->
|
|
|
|
m (DiffTime, EncJSON)
|
2021-02-20 16:45:49 +03:00
|
|
|
runDBSubscription ::
|
|
|
|
forall m.
|
2021-09-01 20:56:46 +03:00
|
|
|
MonadIO m =>
|
2021-02-20 16:45:49 +03:00
|
|
|
SourceConfig b ->
|
|
|
|
MultiplexedQuery b ->
|
|
|
|
-- | WARNING: Postgres-specific, ignored by other backends
|
|
|
|
[(CohortId, CohortVariables)] ->
|
|
|
|
m (DiffTime, Either QErr [(CohortId, B.ByteString)])
|
2022-04-07 17:41:43 +03:00
|
|
|
runDBStreamingSubscription ::
|
|
|
|
forall m.
|
|
|
|
MonadIO m =>
|
|
|
|
SourceConfig b ->
|
|
|
|
MultiplexedQuery b ->
|
|
|
|
-- | WARNING: Postgres-specific, ignored by other backends
|
|
|
|
[(CohortId, CohortVariables)] ->
|
|
|
|
m (DiffTime, Either QErr [(CohortId, B.ByteString, CursorVariableValues)])
|
2021-04-13 14:10:08 +03:00
|
|
|
runDBQueryExplain ::
|
|
|
|
forall m.
|
|
|
|
( MonadIO m,
|
|
|
|
MonadError QErr m
|
|
|
|
) =>
|
|
|
|
DBStepInfo b ->
|
|
|
|
m EncJSON
|