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
|
2023-05-02 16:30:22 +03:00
|
|
|
import Hasura.RQL.Types.Backend (Backend, FunctionName)
|
2023-04-27 17:02:55 +03:00
|
|
|
import Hasura.RQL.Types.BackendType (BackendType)
|
2023-05-02 16:30:22 +03:00
|
|
|
import Hasura.StoredProcedure.Metadata (ArgumentName)
|
|
|
|
import Hasura.StoredProcedure.Types (NullableScalarType, StoredProcedureConfig)
|
2023-05-17 11:53:31 +03:00
|
|
|
import Hasura.Table.Cache (RolePermInfoMap)
|
2023-05-02 16:30:22 +03:00
|
|
|
import Language.GraphQL.Draft.Syntax qualified as G
|
2023-04-27 17:02:55 +03:00
|
|
|
|
2023-05-02 16:30:22 +03:00
|
|
|
type StoredProcedureCache b = HashMap (FunctionName b) (StoredProcedureInfo b)
|
2023-04-27 17:02:55 +03:00
|
|
|
|
|
|
|
-- | The type into which 'StoredProcedureMetadata' is resolved in
|
|
|
|
-- 'Hasura/RQL/DDL/Schema/Cache.buildSchemaCacheRule'.
|
|
|
|
data StoredProcedureInfo (b :: BackendType) = StoredProcedureInfo
|
2023-05-02 16:30:22 +03:00
|
|
|
{ _spiStoredProcedure :: FunctionName b,
|
|
|
|
-- | The GraphQL name of the stored procedure.
|
|
|
|
_spiGraphqlName :: G.Name,
|
|
|
|
_spiConfig :: StoredProcedureConfig,
|
2023-04-27 17:02:55 +03:00
|
|
|
_spiReturns :: LogicalModelInfo b,
|
2023-05-02 15:54:30 +03:00
|
|
|
_spiArguments :: HashMap ArgumentName (NullableScalarType b),
|
2023-04-27 17:02:55 +03:00
|
|
|
_spiDescription :: Maybe Text
|
|
|
|
}
|
|
|
|
deriving stock (Generic)
|
|
|
|
|
|
|
|
instance
|
|
|
|
(Backend b, ToJSON (RolePermInfoMap b)) =>
|
|
|
|
ToJSON (StoredProcedureInfo b)
|
|
|
|
where
|
|
|
|
toJSON = genericToJSON hasuraJSON
|