mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 12:31:52 +03:00
800b6aa9be
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8969 GitOrigin-RevId: 2a33ab836fc26619acbe160278c87d036253388d
50 lines
1.7 KiB
Haskell
50 lines
1.7 KiB
Haskell
{-# LANGUAGE TemplateHaskell #-}
|
|
{-# LANGUAGE UndecidableInstances #-}
|
|
|
|
-- | The representation of stored procedures as derived from the schema cache.
|
|
module Hasura.StoredProcedure.Cache
|
|
( StoredProcedureInfo (..),
|
|
StoredProcedureCache,
|
|
spiRootFieldName,
|
|
spiArrayRelationships,
|
|
spiCode,
|
|
spiReturns,
|
|
spiArguments,
|
|
spiDescription,
|
|
)
|
|
where
|
|
|
|
import Control.Lens (makeLenses)
|
|
import Data.Aeson (ToJSON (toJSON), genericToJSON)
|
|
import Hasura.LogicalModel.Cache (LogicalModelInfo)
|
|
import Hasura.Prelude
|
|
import Hasura.RQL.Types.Backend (Backend)
|
|
import Hasura.RQL.Types.BackendType (BackendType)
|
|
import Hasura.RQL.Types.Common (RelName)
|
|
import Hasura.RQL.Types.Relationships.Local (RelInfo)
|
|
import Hasura.RQL.Types.Table (RolePermInfoMap)
|
|
import Hasura.StoredProcedure.Metadata (InterpolatedQuery, StoredProcedureArgumentName, StoredProcedureName)
|
|
import Hasura.StoredProcedure.Types (NullableScalarType)
|
|
|
|
type StoredProcedureCache b = HashMap StoredProcedureName (StoredProcedureInfo b)
|
|
|
|
-- | The type into which 'StoredProcedureMetadata' is resolved in
|
|
-- 'Hasura/RQL/DDL/Schema/Cache.buildSchemaCacheRule'.
|
|
data StoredProcedureInfo (b :: BackendType) = StoredProcedureInfo
|
|
{ _spiRootFieldName :: StoredProcedureName,
|
|
_spiCode :: InterpolatedQuery StoredProcedureArgumentName,
|
|
_spiReturns :: LogicalModelInfo b,
|
|
_spiArguments :: HashMap StoredProcedureArgumentName (NullableScalarType b),
|
|
_spiArrayRelationships :: InsOrdHashMap RelName (RelInfo b),
|
|
_spiDescription :: Maybe Text
|
|
}
|
|
deriving stock (Generic)
|
|
|
|
instance
|
|
(Backend b, ToJSON (RolePermInfoMap b)) =>
|
|
ToJSON (StoredProcedureInfo b)
|
|
where
|
|
toJSON = genericToJSON hasuraJSON
|
|
|
|
makeLenses ''StoredProcedureInfo
|