2023-04-27 17:02:55 +03:00
|
|
|
{-# LANGUAGE UndecidableInstances #-}
|
|
|
|
|
|
|
|
-- | The representation of stored procedures as derived from the schema cache.
|
|
|
|
module Hasura.StoredProcedure.Cache
|
|
|
|
( StoredProcedureInfo (..),
|
|
|
|
StoredProcedureCache,
|
|
|
|
)
|
|
|
|
where
|
|
|
|
|
|
|
|
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)
|
2023-04-28 22:23:32 +03:00
|
|
|
import Hasura.StoredProcedure.Metadata (InterpolatedQuery, NativeQueryArgumentName, StoredProcedureName)
|
2023-04-27 17:02:55 +03:00
|
|
|
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,
|
2023-04-28 22:23:32 +03:00
|
|
|
_spiCode :: InterpolatedQuery NativeQueryArgumentName,
|
2023-04-27 17:02:55 +03:00
|
|
|
_spiReturns :: LogicalModelInfo b,
|
2023-04-28 22:23:32 +03:00
|
|
|
_spiArguments :: HashMap NativeQueryArgumentName (NullableScalarType b),
|
2023-04-27 17:02:55 +03:00
|
|
|
_spiArrayRelationships :: InsOrdHashMap RelName (RelInfo b),
|
|
|
|
_spiDescription :: Maybe Text
|
|
|
|
}
|
|
|
|
deriving stock (Generic)
|
|
|
|
|
|
|
|
instance
|
|
|
|
(Backend b, ToJSON (RolePermInfoMap b)) =>
|
|
|
|
ToJSON (StoredProcedureInfo b)
|
|
|
|
where
|
|
|
|
toJSON = genericToJSON hasuraJSON
|