2023-04-19 12:03:36 +03:00
|
|
|
{-# LANGUAGE UndecidableInstances #-}
|
|
|
|
|
|
|
|
module Hasura.LogicalModel.Cache
|
|
|
|
( LogicalModelInfo (..),
|
|
|
|
LogicalModelCache,
|
|
|
|
)
|
|
|
|
where
|
|
|
|
|
|
|
|
import Data.Aeson (ToJSON (..), genericToJSON)
|
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-05-17 11:53:31 +03:00
|
|
|
import Hasura.Table.Cache (RolePermInfoMap)
|
2023-04-19 12:03:36 +03:00
|
|
|
|
|
|
|
type LogicalModelCache b = HashMap LogicalModelName (LogicalModelInfo b)
|
|
|
|
|
|
|
|
-- | Description of a logical model for use in metadata (after schema cache)
|
|
|
|
data LogicalModelInfo (b :: BackendType) = LogicalModelInfo
|
|
|
|
{ _lmiName :: LogicalModelName,
|
2023-04-27 10:41:55 +03:00
|
|
|
_lmiFields :: InsOrdHashMap.InsOrdHashMap (Column b) (LogicalModelField b),
|
2023-04-19 12:03:36 +03:00
|
|
|
_lmiDescription :: Maybe Text,
|
|
|
|
_lmiPermissions :: RolePermInfoMap b
|
|
|
|
}
|
|
|
|
deriving (Generic)
|
|
|
|
|
|
|
|
instance
|
|
|
|
(Backend b, ToJSON (RolePermInfoMap b)) =>
|
|
|
|
ToJSON (LogicalModelInfo b)
|
|
|
|
where
|
|
|
|
toJSON = genericToJSON hasuraJSON
|