graphql-engine/server/src-lib/Hasura/GraphQL
Antoine Leblanc dec8579db8 Allow backend execution to happen on the base app monad.
### Description

Each Backend executes queries against the database in a slightly different stack: Postgres uses its own `TXeT`, MSSQL uses a variant of it, BigQuery is simply in `ExceptT QErr IO`... To accommodate those variations, we had originally introduced an `ExecutionMonad b` type family in `BackendExecute`, allowing each backend to describe its own stack. It was then up to that backend's `BackendTransport` instance to implement running said stack, and converting the result back into our main app monad.

However, this was not without complications: `TraceT` is one of them: as it usually needs to be on the top of the stack, converting from one stack to the other implies the use `interpTraceT`, which is quite monstrous. Furthermore, as part of the Entitlement Services work, we're trying to move to a "Services" architecture in which the entire engine runs in one base monad, that delegates features and dependencies to monad constraints; and as a result we'd like to minimize the number of different monad stacks we have to maintain and translate from and to in the codebase.

To improve things, this PR changes `ExecutionMonad b` from an _absolute_ stack to a _relative_ one: i.e.: what needs to be stacked on top of our base monad for the execution. In `Transport`, we then only need to pop the top of the stack, and voila. This greatly simplifies the implementation of the backends, as there's no longer any need to do any stack transformation: MySQL's implementation becomes a `runIdentityT`! This also removes most mentions of `TraceT` from the execution code since it's no longer required: we can rely on the base monad's existing `MonadTrace` constraint.

To continue encapsulating monadic actions in `DBStepInfo` and avoid threading a bunch of `forall` all over the place, this PR introduces a small local helper: `OnBaseMonad`. One only downside of all this is that this requires adding `MonadBaseControl IO m` constraint all over the place: previously, we would run directly on `IO` and lift, and would therefore not need to bring that constraint all the way.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7789
GitOrigin-RevId: e9b2e431c5c47fa9851abf87545c0415ff6d1a12
2023-02-09 14:40:04 +00:00
..
Execute Allow backend execution to happen on the base app monad. 2023-02-09 14:40:04 +00:00
Schema Added result_type property to SingleColumnAggregate 2023-02-06 04:20:17 +00:00
Transport Allow backend execution to happen on the base app monad. 2023-02-09 14:40:04 +00:00
Analyse.hs Upgrade Ormolu to v0.5. 2022-11-02 20:55:13 +00:00
ApolloFederation.hs server: remove built-in scalars from graphql schema printer 2022-11-10 18:53:05 +00:00
Context.hs server: runParse returns QErr 2022-06-16 12:22:30 +00:00
Execute.hs [Gardening] Eliminate boolean blindness in soAllowList 2023-02-08 03:36:45 +00:00
Explain.hs Allow backend execution to happen on the base app monad. 2023-02-09 14:40:04 +00:00
Logging.hs Remove MetadataStorageT, clean up error handling. 2023-02-03 01:05:09 +00:00
Namespace.hs Move MkTypename and NamingCase into their own modules. 2022-07-12 14:01:28 +00:00
ParameterizedQueryHash.hs Implement HLint suggestions and turn warnings into errors 2022-07-01 10:50:33 +00:00
RemoteServer.hs server: plumb StoredIntrospection while building the Schema Cache 2023-01-20 14:52:36 +00:00
Schema.hs Integrating Native Query metadata and schema 2023-01-30 16:06:34 +00:00