2023-04-19 12:03:36 +03:00
|
|
|
{-# LANGUAGE UndecidableInstances #-}
|
|
|
|
|
|
|
|
module Hasura.LogicalModel.IR
|
|
|
|
( LogicalModel (..),
|
|
|
|
)
|
|
|
|
where
|
|
|
|
|
2023-08-17 05:03:45 +03:00
|
|
|
import Data.Aeson (ToJSON (toEncoding), defaultOptions, genericToEncoding)
|
2023-04-27 10:41:55 +03:00
|
|
|
import Data.HashMap.Strict.InsOrd qualified as InsOrdHashMap
|
2023-04-19 12:03:36 +03:00
|
|
|
import Hasura.LogicalModel.Types (LogicalModelField, LogicalModelName)
|
|
|
|
import Hasura.Prelude hiding (first)
|
|
|
|
import Hasura.RQL.Types.Backend (Backend (..))
|
2023-04-24 21:35:48 +03:00
|
|
|
import Hasura.RQL.Types.BackendType (BackendType)
|
2023-04-19 12:03:36 +03:00
|
|
|
|
|
|
|
-- | Description of a logical model for use in IR
|
|
|
|
data LogicalModel (b :: BackendType) = LogicalModel
|
|
|
|
{ lmName :: LogicalModelName,
|
2023-04-27 10:41:55 +03:00
|
|
|
lmFields :: InsOrdHashMap.InsOrdHashMap (Column b) (LogicalModelField b)
|
2023-04-19 12:03:36 +03:00
|
|
|
}
|
|
|
|
deriving (Generic)
|
|
|
|
|
|
|
|
deriving instance (Backend b) => Eq (LogicalModel b)
|
|
|
|
|
|
|
|
deriving instance (Backend b) => Show (LogicalModel b)
|
2023-08-17 05:03:45 +03:00
|
|
|
|
|
|
|
instance (Backend b) => ToJSON (LogicalModel b) where
|
|
|
|
toEncoding = genericToEncoding defaultOptions
|