graphql-engine/server/src-lib/Hasura/StoredProcedure/Cache.hs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.4 KiB
Haskell
Raw Normal View History

{-# 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)
import Hasura.StoredProcedure.Metadata (ArgumentName, InterpolatedQuery, 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 ArgumentName,
_spiReturns :: LogicalModelInfo b,
_spiArguments :: HashMap ArgumentName (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