graphql-engine/server/src-lib/Hasura/StoredProcedure/Cache.hs
Gil Mizrahi e8d2d4f364 Refer to a stored procedure by name in commands interface
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9014
GitOrigin-RevId: 64f51811770d88ad6d5b298fc4c71170ffd7182c
2023-05-02 13:32:01 +00:00

43 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, FunctionName)
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)
import Hasura.StoredProcedure.Types (NullableScalarType, StoredProcedureConfig)
import Language.GraphQL.Draft.Syntax qualified as G
type StoredProcedureCache b = HashMap (FunctionName b) (StoredProcedureInfo b)
-- | The type into which 'StoredProcedureMetadata' is resolved in
-- 'Hasura/RQL/DDL/Schema/Cache.buildSchemaCacheRule'.
data StoredProcedureInfo (b :: BackendType) = StoredProcedureInfo
{ _spiStoredProcedure :: FunctionName b,
-- | The GraphQL name of the stored procedure.
_spiGraphqlName :: G.Name,
_spiConfig :: StoredProcedureConfig,
_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