2023-03-02 19:02:27 +03:00
|
|
|
{-# LANGUAGE TemplateHaskell #-}
|
2023-03-06 18:06:37 +03:00
|
|
|
{-# LANGUAGE UndecidableInstances #-}
|
2023-03-02 19:02:27 +03:00
|
|
|
|
|
|
|
-- | The representation of logical models as derived from the schema cache.
|
|
|
|
module Hasura.LogicalModel.Cache
|
|
|
|
( LogicalModelInfo (..),
|
|
|
|
LogicalModelCache,
|
|
|
|
lmiRootFieldName,
|
|
|
|
lmiCode,
|
|
|
|
lmiReturns,
|
|
|
|
lmiArguments,
|
2023-03-06 18:06:37 +03:00
|
|
|
lmiPermissions,
|
2023-03-02 19:02:27 +03:00
|
|
|
lmiDescription,
|
|
|
|
)
|
|
|
|
where
|
|
|
|
|
|
|
|
import Control.Lens (makeLenses)
|
2023-03-06 18:06:37 +03:00
|
|
|
import Data.Aeson (ToJSON (toJSON), genericToJSON)
|
2023-03-02 19:02:27 +03:00
|
|
|
import Hasura.CustomReturnType (CustomReturnType)
|
|
|
|
import Hasura.LogicalModel.Metadata (InterpolatedQuery, LogicalModelArgumentName, LogicalModelName)
|
2023-03-07 13:03:34 +03:00
|
|
|
import Hasura.LogicalModel.Types (NullableScalarType)
|
2023-03-02 19:02:27 +03:00
|
|
|
import Hasura.Prelude
|
2023-03-07 13:03:34 +03:00
|
|
|
import Hasura.RQL.Types.Backend (Backend)
|
2023-03-06 18:06:37 +03:00
|
|
|
import Hasura.RQL.Types.Table (RolePermInfoMap)
|
2023-03-02 19:02:27 +03:00
|
|
|
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,
|
2023-03-07 13:03:34 +03:00
|
|
|
_lmiArguments :: HashMap LogicalModelArgumentName (NullableScalarType b),
|
2023-03-06 18:06:37 +03:00
|
|
|
_lmiPermissions :: RolePermInfoMap b,
|
2023-03-02 19:02:27 +03:00
|
|
|
_lmiDescription :: Maybe Text
|
|
|
|
}
|
|
|
|
deriving stock (Generic)
|
|
|
|
|
2023-03-06 18:06:37 +03:00
|
|
|
instance
|
|
|
|
(Backend b, ToJSON (RolePermInfoMap b)) =>
|
|
|
|
ToJSON (LogicalModelInfo b)
|
|
|
|
where
|
|
|
|
toJSON = genericToJSON hasuraJSON
|
2023-03-02 19:02:27 +03:00
|
|
|
|
|
|
|
makeLenses ''LogicalModelInfo
|