mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 21:12:09 +03:00
e93d3d2735
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8214 GitOrigin-RevId: 1ecf4c9c362aad9eabad2134a70266ff1170577b
48 lines
1.5 KiB
Haskell
48 lines
1.5 KiB
Haskell
{-# LANGUAGE TemplateHaskell #-}
|
|
{-# LANGUAGE UndecidableInstances #-}
|
|
|
|
-- | The representation of logical models as derived from the schema cache.
|
|
module Hasura.LogicalModel.Cache
|
|
( LogicalModelInfo (..),
|
|
LogicalModelCache,
|
|
lmiRootFieldName,
|
|
lmiCode,
|
|
lmiReturns,
|
|
lmiArguments,
|
|
lmiPermissions,
|
|
lmiDescription,
|
|
)
|
|
where
|
|
|
|
import Control.Lens (makeLenses)
|
|
import Data.Aeson (ToJSON (toJSON), genericToJSON)
|
|
import Hasura.CustomReturnType (CustomReturnType)
|
|
import Hasura.LogicalModel.Metadata (InterpolatedQuery, LogicalModelArgumentName, LogicalModelName)
|
|
import Hasura.LogicalModel.Types (NullableScalarType)
|
|
import Hasura.Prelude
|
|
import Hasura.RQL.Types.Backend (Backend)
|
|
import Hasura.RQL.Types.Table (RolePermInfoMap)
|
|
import Hasura.SQL.Backend (BackendType)
|
|
|
|
type LogicalModelCache b = HashMap LogicalModelName (LogicalModelInfo b)
|
|
|
|
-- | The type into which 'LogicalModelMetadata' is resolved in
|
|
-- 'Hasura/RQL/DDL/Schema/Cache.buildSchemaCacheRule'.
|
|
data LogicalModelInfo (b :: BackendType) = LogicalModelInfo
|
|
{ _lmiRootFieldName :: LogicalModelName,
|
|
_lmiCode :: InterpolatedQuery LogicalModelArgumentName,
|
|
_lmiReturns :: CustomReturnType b,
|
|
_lmiArguments :: HashMap LogicalModelArgumentName (NullableScalarType b),
|
|
_lmiPermissions :: RolePermInfoMap b,
|
|
_lmiDescription :: Maybe Text
|
|
}
|
|
deriving stock (Generic)
|
|
|
|
instance
|
|
(Backend b, ToJSON (RolePermInfoMap b)) =>
|
|
ToJSON (LogicalModelInfo b)
|
|
where
|
|
toJSON = genericToJSON hasuraJSON
|
|
|
|
makeLenses ''LogicalModelInfo
|