mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 20:41:49 +03:00
8f4692d871
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9174 GitOrigin-RevId: d440647ac04b9c1717ecf22a2dbfb8c5f22b7c7a
33 lines
1.0 KiB
Haskell
33 lines
1.0 KiB
Haskell
{-# LANGUAGE UndecidableInstances #-}
|
|
|
|
module Hasura.LogicalModel.Cache
|
|
( LogicalModelInfo (..),
|
|
LogicalModelCache,
|
|
)
|
|
where
|
|
|
|
import Data.Aeson (ToJSON (..), genericToJSON)
|
|
import Data.HashMap.Strict.InsOrd qualified as InsOrdHashMap
|
|
import Hasura.LogicalModel.Types (LogicalModelField, LogicalModelName)
|
|
import Hasura.Prelude hiding (first)
|
|
import Hasura.RQL.Types.Backend (Backend (..))
|
|
import Hasura.RQL.Types.BackendType (BackendType)
|
|
import Hasura.Table.Cache (RolePermInfoMap)
|
|
|
|
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,
|
|
_lmiFields :: InsOrdHashMap.InsOrdHashMap (Column b) (LogicalModelField b),
|
|
_lmiDescription :: Maybe Text,
|
|
_lmiPermissions :: RolePermInfoMap b
|
|
}
|
|
deriving (Generic)
|
|
|
|
instance
|
|
(Backend b, ToJSON (RolePermInfoMap b)) =>
|
|
ToJSON (LogicalModelInfo b)
|
|
where
|
|
toJSON = genericToJSON hasuraJSON
|