mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 21:12:09 +03:00
342391f39d
This upgrades the version of Ormolu required by the HGE repository to v0.5.0.1, and reformats all code accordingly. Ormolu v0.5 reformats code that uses infix operators. This is mostly useful, adding newlines and indentation to make it clear which operators are applied first, but in some cases, it's unpleasant. To make this easier on the eyes, I had to do the following: * Add a few fixity declarations (search for `infix`) * Add parentheses to make precedence clear, allowing Ormolu to keep everything on one line * Rename `relevantEq` to `(==~)` in #6651 and set it to `infix 4` * Add a few _.ormolu_ files (thanks to @hallettj for helping me get started), mostly for Autodocodec operators that don't have explicit fixity declarations In general, I think these changes are quite reasonable. They mostly affect indentation. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6675 GitOrigin-RevId: cd47d87f1d089fb0bc9dcbbe7798dbceedcd7d83
88 lines
3.3 KiB
Haskell
88 lines
3.3 KiB
Haskell
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
|
|
module Hasura.Backends.DataConnector.Adapter.Transport () where
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Control.Exception.Safe (throwIO)
|
|
import Data.Aeson qualified as J
|
|
import Data.Text.Extended ((<>>))
|
|
import Hasura.Backends.DataConnector.API qualified as API
|
|
import Hasura.Backends.DataConnector.Adapter.Execute ()
|
|
import Hasura.Backends.DataConnector.Adapter.Types (SourceConfig (..))
|
|
import Hasura.Backends.DataConnector.Agent.Client (AgentClientContext (..), AgentClientT, runAgentClientT)
|
|
import Hasura.Backends.DataConnector.Plan qualified as DC
|
|
import Hasura.Base.Error (Code (NotSupported), QErr, throw400)
|
|
import Hasura.EncJSON (EncJSON)
|
|
import Hasura.GraphQL.Execute.Backend (DBStepInfo (..))
|
|
import Hasura.GraphQL.Logging qualified as HGL
|
|
import Hasura.GraphQL.Namespace (RootFieldAlias)
|
|
import Hasura.GraphQL.Transport.Backend (BackendTransport (..))
|
|
import Hasura.GraphQL.Transport.HTTP.Protocol (GQLReqUnparsed)
|
|
import Hasura.Logging (Hasura, Logger, nullLogger)
|
|
import Hasura.Prelude
|
|
import Hasura.SQL.Backend (BackendType (DataConnector))
|
|
import Hasura.Server.Types (RequestId)
|
|
import Hasura.Session (UserInfo)
|
|
import Hasura.Tracing qualified as Tracing
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
instance BackendTransport 'DataConnector where
|
|
runDBQuery = runDBQuery'
|
|
runDBQueryExplain = runDBQueryExplain'
|
|
runDBMutation _ _ _ _ _ _ _ _ =
|
|
throw400 NotSupported "runDBMutation: not implemented for the Data Connector backend."
|
|
runDBStreamingSubscription _ _ _ =
|
|
liftIO . throwIO $ userError "runDBStreamingSubscription: not implemented for the Data Connector backend."
|
|
runDBSubscription _ _ _ =
|
|
liftIO . throwIO $ userError "runDBSubscription: not implemented for the Data Connector backend."
|
|
|
|
runDBQuery' ::
|
|
( MonadIO m,
|
|
MonadError QErr m,
|
|
Tracing.MonadTrace m,
|
|
HGL.MonadQueryLog m
|
|
) =>
|
|
RequestId ->
|
|
GQLReqUnparsed ->
|
|
RootFieldAlias ->
|
|
UserInfo ->
|
|
Logger Hasura ->
|
|
SourceConfig ->
|
|
AgentClientT (Tracing.TraceT (ExceptT QErr IO)) a ->
|
|
Maybe API.QueryRequest ->
|
|
m (DiffTime, a)
|
|
runDBQuery' requestId query fieldName _userInfo logger SourceConfig {..} action queryRequest = do
|
|
void $ HGL.logQueryLog logger $ mkQueryLog query fieldName queryRequest requestId
|
|
withElapsedTime
|
|
. Tracing.trace ("Data Connector backend query for root field " <>> fieldName)
|
|
. Tracing.interpTraceT (liftEitherM . liftIO . runExceptT)
|
|
. flip runAgentClientT (AgentClientContext logger _scEndpoint _scManager _scTimeoutMicroseconds)
|
|
$ action
|
|
|
|
mkQueryLog ::
|
|
GQLReqUnparsed ->
|
|
RootFieldAlias ->
|
|
Maybe API.QueryRequest ->
|
|
RequestId ->
|
|
HGL.QueryLog
|
|
mkQueryLog gqlQuery fieldName maybeQuery requestId =
|
|
HGL.QueryLog
|
|
gqlQuery
|
|
((\query -> (fieldName, HGL.GeneratedQuery (DC.renderQuery query) J.Null)) <$> maybeQuery)
|
|
requestId
|
|
HGL.QueryLogKindDatabase
|
|
|
|
runDBQueryExplain' ::
|
|
(MonadIO m, MonadError QErr m) =>
|
|
DBStepInfo 'DataConnector ->
|
|
m EncJSON
|
|
runDBQueryExplain' (DBStepInfo _ SourceConfig {..} _ action) =
|
|
liftEitherM
|
|
. liftIO
|
|
. runExceptT
|
|
. Tracing.runTraceTWithReporter Tracing.noReporter "explain"
|
|
. flip runAgentClientT (AgentClientContext nullLogger _scEndpoint _scManager _scTimeoutMicroseconds)
|
|
$ action
|