2021-02-12 06:04:09 +03:00
|
|
|
module Hasura.GraphQL.Transport.Backend where
|
|
|
|
|
|
|
|
import Hasura.Prelude
|
|
|
|
|
2021-02-20 16:45:49 +03:00
|
|
|
import qualified Data.ByteString as B
|
2021-02-12 06:04:09 +03:00
|
|
|
import qualified Language.GraphQL.Draft.Syntax as G
|
|
|
|
|
|
|
|
import qualified Hasura.Logging as L
|
|
|
|
|
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
|
2021-02-20 16:45:49 +03:00
|
|
|
import Hasura.GraphQL.Execute.LiveQuery.Plan
|
2021-03-13 17:40:50 +03:00
|
|
|
import Hasura.GraphQL.Logging (MonadQueryLog)
|
2021-02-12 06:04:09 +03:00
|
|
|
import Hasura.GraphQL.Transport.HTTP.Protocol
|
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
|
|
|
|
-> G.Name
|
|
|
|
-> 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
|
|
|
|
-> G.Name
|
|
|
|
-> 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
|
|
|
|
. ( MonadIO m
|
|
|
|
)
|
|
|
|
=> SourceConfig b
|
|
|
|
-> MultiplexedQuery b
|
|
|
|
-> [(CohortId, CohortVariables)]
|
|
|
|
-- ^ WARNING: Postgres-specific, ignored by other backends
|
|
|
|
-> m (DiffTime, Either QErr [(CohortId, B.ByteString)])
|
2021-04-13 14:10:08 +03:00
|
|
|
runDBQueryExplain
|
|
|
|
:: forall m
|
|
|
|
. ( MonadIO m
|
|
|
|
, MonadError QErr m
|
|
|
|
)
|
|
|
|
=> DBStepInfo b
|
|
|
|
-> m EncJSON
|