2021-06-11 06:26:50 +03:00
|
|
|
module Hasura.RQL.IR.Root
|
|
|
|
( SourceConfigWith(..)
|
|
|
|
, RootField(..)
|
|
|
|
, MutationDB(..)
|
|
|
|
, ActionQuery(..)
|
|
|
|
, ActionMutation(..)
|
|
|
|
, QueryRootField
|
|
|
|
, MutationRootField
|
|
|
|
, SubscriptionRootField
|
|
|
|
, QueryDBRoot(..)
|
|
|
|
, MutationDBRoot(..)
|
|
|
|
) where
|
|
|
|
|
|
|
|
import Hasura.Prelude
|
|
|
|
|
|
|
|
import qualified Data.Aeson.Ordered as JO
|
|
|
|
|
server: IR for DB-DB joins
### Description
This PR adds the required IR for DB to DB joins, based on @paf31 and @0x777 's `feature/db-to-db` branch.
To do so, it also refactors the IR to introduce a new type parameter, `r`, which is used to recursively constructs the `v` parameter of remote QueryDBs. When collecting remote joins, we replace `r` with `Const Void`, indicating at the type level that there cannot be any leftover remote join.
Furthermore, this PR refactors IR.Select for readability, moves some code from IR.Root to IR.Select to avoid having to deal with circular dependencies, and makes it compile by adding `error` in all new cases in the execution pipeline.
The diff doesn't make it clear, but most of Select.hs is actually unchanged. Declarations have just been reordered by topic, in the following order:
- type declarations
- instance declarations
- type aliases
- constructor functions
- traverse functions
https://github.com/hasura/graphql-engine-mono/pull/1580
Co-authored-by: Phil Freeman <630306+paf31@users.noreply.github.com>
GitOrigin-RevId: bbdcb4119cec8bb3fc32f1294f91b8dea0728721
2021-06-18 02:12:11 +03:00
|
|
|
import Data.Kind (Type)
|
|
|
|
|
2021-06-11 06:26:50 +03:00
|
|
|
import qualified Hasura.RQL.Types.Action as RQL
|
|
|
|
import qualified Hasura.RQL.Types.Backend as RQL
|
|
|
|
import qualified Hasura.RQL.Types.Common as RQL
|
2021-09-23 15:37:56 +03:00
|
|
|
import qualified Hasura.RQL.Types.QueryTags as RQL
|
2021-06-11 06:26:50 +03:00
|
|
|
import qualified Hasura.RQL.Types.RemoteSchema as RQL
|
|
|
|
import qualified Hasura.SQL.AnyBackend as AB
|
|
|
|
|
server: IR for DB-DB joins
### Description
This PR adds the required IR for DB to DB joins, based on @paf31 and @0x777 's `feature/db-to-db` branch.
To do so, it also refactors the IR to introduce a new type parameter, `r`, which is used to recursively constructs the `v` parameter of remote QueryDBs. When collecting remote joins, we replace `r` with `Const Void`, indicating at the type level that there cannot be any leftover remote join.
Furthermore, this PR refactors IR.Select for readability, moves some code from IR.Root to IR.Select to avoid having to deal with circular dependencies, and makes it compile by adding `error` in all new cases in the execution pipeline.
The diff doesn't make it clear, but most of Select.hs is actually unchanged. Declarations have just been reordered by topic, in the following order:
- type declarations
- instance declarations
- type aliases
- constructor functions
- traverse functions
https://github.com/hasura/graphql-engine-mono/pull/1580
Co-authored-by: Phil Freeman <630306+paf31@users.noreply.github.com>
GitOrigin-RevId: bbdcb4119cec8bb3fc32f1294f91b8dea0728721
2021-06-18 02:12:11 +03:00
|
|
|
import Hasura.RQL.IR.Delete
|
|
|
|
import Hasura.RQL.IR.Insert
|
|
|
|
import Hasura.RQL.IR.Select
|
|
|
|
import Hasura.RQL.IR.Update
|
2021-06-11 06:26:50 +03:00
|
|
|
import Hasura.SQL.Backend
|
|
|
|
|
server: IR for DB-DB joins
### Description
This PR adds the required IR for DB to DB joins, based on @paf31 and @0x777 's `feature/db-to-db` branch.
To do so, it also refactors the IR to introduce a new type parameter, `r`, which is used to recursively constructs the `v` parameter of remote QueryDBs. When collecting remote joins, we replace `r` with `Const Void`, indicating at the type level that there cannot be any leftover remote join.
Furthermore, this PR refactors IR.Select for readability, moves some code from IR.Root to IR.Select to avoid having to deal with circular dependencies, and makes it compile by adding `error` in all new cases in the execution pipeline.
The diff doesn't make it clear, but most of Select.hs is actually unchanged. Declarations have just been reordered by topic, in the following order:
- type declarations
- instance declarations
- type aliases
- constructor functions
- traverse functions
https://github.com/hasura/graphql-engine-mono/pull/1580
Co-authored-by: Phil Freeman <630306+paf31@users.noreply.github.com>
GitOrigin-RevId: bbdcb4119cec8bb3fc32f1294f91b8dea0728721
2021-06-18 02:12:11 +03:00
|
|
|
|
|
|
|
data SourceConfigWith (db :: BackendType -> Type) (b :: BackendType) =
|
2021-09-23 15:37:56 +03:00
|
|
|
SourceConfigWith (RQL.SourceConfig b) (Maybe RQL.QueryTagsConfig) (db b)
|
2021-06-11 06:26:50 +03:00
|
|
|
|
server: IR for DB-DB joins
### Description
This PR adds the required IR for DB to DB joins, based on @paf31 and @0x777 's `feature/db-to-db` branch.
To do so, it also refactors the IR to introduce a new type parameter, `r`, which is used to recursively constructs the `v` parameter of remote QueryDBs. When collecting remote joins, we replace `r` with `Const Void`, indicating at the type level that there cannot be any leftover remote join.
Furthermore, this PR refactors IR.Select for readability, moves some code from IR.Root to IR.Select to avoid having to deal with circular dependencies, and makes it compile by adding `error` in all new cases in the execution pipeline.
The diff doesn't make it clear, but most of Select.hs is actually unchanged. Declarations have just been reordered by topic, in the following order:
- type declarations
- instance declarations
- type aliases
- constructor functions
- traverse functions
https://github.com/hasura/graphql-engine-mono/pull/1580
Co-authored-by: Phil Freeman <630306+paf31@users.noreply.github.com>
GitOrigin-RevId: bbdcb4119cec8bb3fc32f1294f91b8dea0728721
2021-06-18 02:12:11 +03:00
|
|
|
data RootField (db :: BackendType -> Type) remote action raw where
|
2021-06-11 06:26:50 +03:00
|
|
|
RFDB
|
|
|
|
:: RQL.SourceName
|
|
|
|
-> AB.AnyBackend (SourceConfigWith db)
|
|
|
|
-> RootField db remote action raw
|
|
|
|
RFRemote :: remote -> RootField db remote action raw
|
|
|
|
RFAction :: action -> RootField db remote action raw
|
|
|
|
RFRaw :: raw -> RootField db remote action raw
|
|
|
|
|
|
|
|
|
server: IR for DB-DB joins
### Description
This PR adds the required IR for DB to DB joins, based on @paf31 and @0x777 's `feature/db-to-db` branch.
To do so, it also refactors the IR to introduce a new type parameter, `r`, which is used to recursively constructs the `v` parameter of remote QueryDBs. When collecting remote joins, we replace `r` with `Const Void`, indicating at the type level that there cannot be any leftover remote join.
Furthermore, this PR refactors IR.Select for readability, moves some code from IR.Root to IR.Select to avoid having to deal with circular dependencies, and makes it compile by adding `error` in all new cases in the execution pipeline.
The diff doesn't make it clear, but most of Select.hs is actually unchanged. Declarations have just been reordered by topic, in the following order:
- type declarations
- instance declarations
- type aliases
- constructor functions
- traverse functions
https://github.com/hasura/graphql-engine-mono/pull/1580
Co-authored-by: Phil Freeman <630306+paf31@users.noreply.github.com>
GitOrigin-RevId: bbdcb4119cec8bb3fc32f1294f91b8dea0728721
2021-06-18 02:12:11 +03:00
|
|
|
data MutationDB (b :: BackendType) (r :: BackendType -> Type) v
|
|
|
|
= MDBInsert (AnnInsert b r v)
|
|
|
|
| MDBUpdate (AnnUpdG b r v)
|
|
|
|
| MDBDelete (AnnDelG b r v)
|
2021-07-08 18:41:59 +03:00
|
|
|
| MDBFunction RQL.JsonAggSelect (AnnSimpleSelectG b r v)
|
2021-06-11 06:26:50 +03:00
|
|
|
-- ^ This represents a VOLATILE function, and is AnnSimpleSelG for easy
|
|
|
|
-- re-use of non-VOLATILE function tracking code.
|
2021-07-08 18:41:59 +03:00
|
|
|
deriving stock (Generic, Functor, Foldable, Traversable)
|
2021-06-11 06:26:50 +03:00
|
|
|
|
server: IR for DB-DB joins
### Description
This PR adds the required IR for DB to DB joins, based on @paf31 and @0x777 's `feature/db-to-db` branch.
To do so, it also refactors the IR to introduce a new type parameter, `r`, which is used to recursively constructs the `v` parameter of remote QueryDBs. When collecting remote joins, we replace `r` with `Const Void`, indicating at the type level that there cannot be any leftover remote join.
Furthermore, this PR refactors IR.Select for readability, moves some code from IR.Root to IR.Select to avoid having to deal with circular dependencies, and makes it compile by adding `error` in all new cases in the execution pipeline.
The diff doesn't make it clear, but most of Select.hs is actually unchanged. Declarations have just been reordered by topic, in the following order:
- type declarations
- instance declarations
- type aliases
- constructor functions
- traverse functions
https://github.com/hasura/graphql-engine-mono/pull/1580
Co-authored-by: Phil Freeman <630306+paf31@users.noreply.github.com>
GitOrigin-RevId: bbdcb4119cec8bb3fc32f1294f91b8dea0728721
2021-06-18 02:12:11 +03:00
|
|
|
data ActionQuery (b :: BackendType) (r :: BackendType -> Type) v
|
|
|
|
= AQQuery !(RQL.AnnActionExecution b r v)
|
|
|
|
| AQAsync !(RQL.AnnActionAsyncQuery b r v)
|
2021-07-08 18:41:59 +03:00
|
|
|
deriving (Functor, Foldable, Traversable)
|
2021-06-11 06:26:50 +03:00
|
|
|
|
server: IR for DB-DB joins
### Description
This PR adds the required IR for DB to DB joins, based on @paf31 and @0x777 's `feature/db-to-db` branch.
To do so, it also refactors the IR to introduce a new type parameter, `r`, which is used to recursively constructs the `v` parameter of remote QueryDBs. When collecting remote joins, we replace `r` with `Const Void`, indicating at the type level that there cannot be any leftover remote join.
Furthermore, this PR refactors IR.Select for readability, moves some code from IR.Root to IR.Select to avoid having to deal with circular dependencies, and makes it compile by adding `error` in all new cases in the execution pipeline.
The diff doesn't make it clear, but most of Select.hs is actually unchanged. Declarations have just been reordered by topic, in the following order:
- type declarations
- instance declarations
- type aliases
- constructor functions
- traverse functions
https://github.com/hasura/graphql-engine-mono/pull/1580
Co-authored-by: Phil Freeman <630306+paf31@users.noreply.github.com>
GitOrigin-RevId: bbdcb4119cec8bb3fc32f1294f91b8dea0728721
2021-06-18 02:12:11 +03:00
|
|
|
data ActionMutation (b :: BackendType) (r :: BackendType -> Type) v
|
|
|
|
= AMSync !(RQL.AnnActionExecution b r v)
|
2021-06-11 06:26:50 +03:00
|
|
|
| AMAsync !RQL.AnnActionMutationAsync
|
2021-07-08 18:41:59 +03:00
|
|
|
deriving (Functor, Foldable, Traversable)
|
|
|
|
|
2021-06-11 06:26:50 +03:00
|
|
|
|
|
|
|
-- The `db` type argument of @RootField@ expects only one type argument, the backend `b`, as not all
|
|
|
|
-- types stored in a RootField will have a second parameter like @QueryDB@ does: they all only have
|
|
|
|
-- in common the fact that they're parametric over the backend. To define @QueryRootField@ in terms
|
|
|
|
-- of @QueryDB@ (and likewise for mutations), we need a type-level function `b -> QueryDB b (v
|
|
|
|
-- b)`. Sadly, neither type synonyms nor type families may be partially applied. Hence the need for
|
|
|
|
-- @QueryDBRoot@ and @MutationDBRoot@.
|
server: IR for DB-DB joins
### Description
This PR adds the required IR for DB to DB joins, based on @paf31 and @0x777 's `feature/db-to-db` branch.
To do so, it also refactors the IR to introduce a new type parameter, `r`, which is used to recursively constructs the `v` parameter of remote QueryDBs. When collecting remote joins, we replace `r` with `Const Void`, indicating at the type level that there cannot be any leftover remote join.
Furthermore, this PR refactors IR.Select for readability, moves some code from IR.Root to IR.Select to avoid having to deal with circular dependencies, and makes it compile by adding `error` in all new cases in the execution pipeline.
The diff doesn't make it clear, but most of Select.hs is actually unchanged. Declarations have just been reordered by topic, in the following order:
- type declarations
- instance declarations
- type aliases
- constructor functions
- traverse functions
https://github.com/hasura/graphql-engine-mono/pull/1580
Co-authored-by: Phil Freeman <630306+paf31@users.noreply.github.com>
GitOrigin-RevId: bbdcb4119cec8bb3fc32f1294f91b8dea0728721
2021-06-18 02:12:11 +03:00
|
|
|
newtype QueryDBRoot r v b = QDBR (QueryDB b r (v b))
|
|
|
|
newtype MutationDBRoot r v b = MDBR (MutationDB b r (v b))
|
2021-06-11 06:26:50 +03:00
|
|
|
|
2021-07-26 16:03:51 +03:00
|
|
|
-- | Represents a query root field to an action
|
|
|
|
type QueryActionRoot v
|
|
|
|
= ActionQuery ('Postgres 'Vanilla) (RemoteSelect v) (v ('Postgres 'Vanilla))
|
2021-06-11 06:26:50 +03:00
|
|
|
|
2021-07-26 16:03:51 +03:00
|
|
|
-- | Represents a mutation root field to an action
|
|
|
|
type MutationActionRoot v
|
|
|
|
= ActionMutation ('Postgres 'Vanilla) (RemoteSelect v) (v ('Postgres 'Vanilla))
|
|
|
|
|
|
|
|
type QueryRootField v = RootField (QueryDBRoot (RemoteSelect v) v) RQL.RemoteField (QueryActionRoot v) JO.Value
|
|
|
|
type MutationRootField v = RootField (MutationDBRoot (RemoteSelect v) v) RQL.RemoteField (MutationActionRoot v) JO.Value
|
|
|
|
type SubscriptionRootField v = RootField (QueryDBRoot (RemoteSelect v) v) Void Void Void
|