graphql-engine/server/src-lib/Hasura/StoredProcedure/Cache.hs
Gil Mizrahi f6fd9f071d refactor(cleanup): extract interpolated query
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9002
GitOrigin-RevId: 2e2a499f5035adf1493a2d675ee52abb7c87a8c8
2023-04-28 19:25:32 +00:00

40 lines
1.5 KiB
Haskell

{-# 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 (InterpolatedQuery, NativeQueryArgumentName, 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 NativeQueryArgumentName,
_spiReturns :: LogicalModelInfo b,
_spiArguments :: HashMap NativeQueryArgumentName (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