2021-06-11 06:26:50 +03:00
|
|
|
module Hasura.RQL.IR.Root
|
2021-09-24 01:56:37 +03:00
|
|
|
( SourceConfigWith (..),
|
|
|
|
RootField (..),
|
|
|
|
MutationDB (..),
|
|
|
|
ActionQuery (..),
|
|
|
|
ActionMutation (..),
|
|
|
|
QueryRootField,
|
|
|
|
MutationRootField,
|
|
|
|
SubscriptionRootField,
|
|
|
|
QueryDBRoot (..),
|
|
|
|
MutationDBRoot (..),
|
|
|
|
)
|
|
|
|
where
|
|
|
|
|
|
|
|
import Data.Aeson.Ordered qualified as JO
|
|
|
|
import Data.Kind (Type)
|
|
|
|
import Hasura.Prelude
|
|
|
|
import Hasura.RQL.IR.Delete
|
|
|
|
import Hasura.RQL.IR.Insert
|
|
|
|
import Hasura.RQL.IR.Select
|
|
|
|
import Hasura.RQL.IR.Update
|
|
|
|
import Hasura.RQL.Types.Action qualified as RQL
|
|
|
|
import Hasura.RQL.Types.Backend qualified as RQL
|
|
|
|
import Hasura.RQL.Types.Common qualified as RQL
|
|
|
|
import Hasura.RQL.Types.QueryTags qualified as RQL
|
|
|
|
import Hasura.RQL.Types.RemoteSchema qualified as RQL
|
|
|
|
import Hasura.SQL.AnyBackend qualified as AB
|
|
|
|
import Hasura.SQL.Backend
|
|
|
|
|
|
|
|
data SourceConfigWith (db :: BackendType -> Type) (b :: BackendType)
|
|
|
|
= 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-09-24 01:56:37 +03:00
|
|
|
RFDB ::
|
|
|
|
RQL.SourceName ->
|
|
|
|
AB.AnyBackend (SourceConfigWith db) ->
|
|
|
|
RootField db remote action raw
|
2021-06-11 06:26:50 +03:00
|
|
|
RFRemote :: remote -> RootField db remote action raw
|
|
|
|
RFAction :: action -> RootField db remote action raw
|
2021-09-24 01:56:37 +03:00
|
|
|
RFRaw :: raw -> RootField db remote action raw
|
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 MutationDB (b :: BackendType) (r :: BackendType -> Type) v
|
|
|
|
= MDBInsert (AnnInsert b r v)
|
2021-11-25 00:39:42 +03:00
|
|
|
| MDBUpdate (AnnotatedUpdateG b r v)
|
2021-09-24 01:56:37 +03:00
|
|
|
| MDBDelete (AnnDelG b r v)
|
|
|
|
| -- | This represents a VOLATILE function, and is AnnSimpleSelG for easy
|
|
|
|
-- re-use of non-VOLATILE function tracking code.
|
|
|
|
MDBFunction RQL.JsonAggSelect (AnnSimpleSelectG b r v)
|
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
|
2021-09-24 01:56:37 +03:00
|
|
|
= AQQuery !(RQL.AnnActionExecution b r v)
|
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
|
|
|
| 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@.
|
2021-09-24 01:56:37 +03:00
|
|
|
newtype QueryDBRoot r v b = QDBR (QueryDB b r (v b))
|
|
|
|
|
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 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
|
2021-09-24 01:56:37 +03:00
|
|
|
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
|
2021-09-24 01:56:37 +03:00
|
|
|
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
|
2021-07-26 16:03:51 +03:00
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
type SubscriptionRootField v = RootField (QueryDBRoot (RemoteSelect v) v) Void Void Void
|