mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 13:02:11 +03:00
ea5c92acae
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8876 GitOrigin-RevId: abfc18eeef96a1f3593bfe823adab4d161161333
41 lines
1.2 KiB
Haskell
41 lines
1.2 KiB
Haskell
{-# LANGUAGE TemplateHaskell #-}
|
|
{-# LANGUAGE UndecidableInstances #-}
|
|
|
|
module Hasura.LogicalModel.Cache
|
|
( LogicalModelInfo (..),
|
|
LogicalModelCache,
|
|
lmiName,
|
|
lmiPermissions,
|
|
lmiDescription,
|
|
lmiFields,
|
|
)
|
|
where
|
|
|
|
import Control.Lens (makeLenses)
|
|
import Data.Aeson (ToJSON (..), genericToJSON)
|
|
import Data.HashMap.Strict.InsOrd qualified as InsOrd
|
|
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.RQL.Types.Table (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 :: InsOrd.InsOrdHashMap (Column b) (LogicalModelField b),
|
|
_lmiDescription :: Maybe Text,
|
|
_lmiPermissions :: RolePermInfoMap b
|
|
}
|
|
deriving (Generic)
|
|
|
|
makeLenses ''LogicalModelInfo
|
|
|
|
instance
|
|
(Backend b, ToJSON (RolePermInfoMap b)) =>
|
|
ToJSON (LogicalModelInfo b)
|
|
where
|
|
toJSON = genericToJSON hasuraJSON
|