-- | The RQL IR representation of an invocation of a stored procedure.
module Hasura.StoredProcedure.IR
  ( StoredProcedure (..),
  )
where

import Hasura.LogicalModel.IR
import Hasura.Prelude
import Hasura.RQL.Types.Backend
import Hasura.StoredProcedure.Metadata
import Language.GraphQL.Draft.Syntax qualified as G

-- | The RQL IR representation of an invocation of a stored procedure.
data StoredProcedure b field = StoredProcedure
  { -- | The SQL name of the stored procedure.
    forall (b :: BackendType) field.
StoredProcedure b field -> FunctionName b
spStoredProcedure :: FunctionName b,
    -- | The graphql name of the stored procedure.
    forall (b :: BackendType) field. StoredProcedure b field -> Name
spGraphqlName :: G.Name,
    -- | The arguments passed to the query, if any.
    forall (b :: BackendType) field.
StoredProcedure b field
-> HashMap ArgumentName (ScalarType b, field)
spArgs :: HashMap ArgumentName (ScalarType b, field),
    -- | The return type of the stored procedure
    forall (b :: BackendType) field.
StoredProcedure b field -> LogicalModel b
spLogicalModel :: LogicalModel b
  }
  deriving ((forall a b.
 (a -> b) -> StoredProcedure b a -> StoredProcedure b b)
-> (forall a b. a -> StoredProcedure b b -> StoredProcedure b a)
-> Functor (StoredProcedure b)
forall a b. a -> StoredProcedure b b -> StoredProcedure b a
forall a b. (a -> b) -> StoredProcedure b a -> StoredProcedure b b
forall (b :: BackendType) a b.
a -> StoredProcedure b b -> StoredProcedure b a
forall (b :: BackendType) a b.
(a -> b) -> StoredProcedure b a -> StoredProcedure b b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall (b :: BackendType) a b.
(a -> b) -> StoredProcedure b a -> StoredProcedure b b
fmap :: forall a b. (a -> b) -> StoredProcedure b a -> StoredProcedure b b
$c<$ :: forall (b :: BackendType) a b.
a -> StoredProcedure b b -> StoredProcedure b a
<$ :: forall a b. a -> StoredProcedure b b -> StoredProcedure b a
Functor, (forall m. Monoid m => StoredProcedure b m -> m)
-> (forall m a. Monoid m => (a -> m) -> StoredProcedure b a -> m)
-> (forall m a. Monoid m => (a -> m) -> StoredProcedure b a -> m)
-> (forall a b. (a -> b -> b) -> b -> StoredProcedure b a -> b)
-> (forall a b. (a -> b -> b) -> b -> StoredProcedure b a -> b)
-> (forall b a. (b -> a -> b) -> b -> StoredProcedure b a -> b)
-> (forall b a. (b -> a -> b) -> b -> StoredProcedure b a -> b)
-> (forall a. (a -> a -> a) -> StoredProcedure b a -> a)
-> (forall a. (a -> a -> a) -> StoredProcedure b a -> a)
-> (forall a. StoredProcedure b a -> [a])
-> (forall a. StoredProcedure b a -> Bool)
-> (forall a. StoredProcedure b a -> Int)
-> (forall a. Eq a => a -> StoredProcedure b a -> Bool)
-> (forall a. Ord a => StoredProcedure b a -> a)
-> (forall a. Ord a => StoredProcedure b a -> a)
-> (forall a. Num a => StoredProcedure b a -> a)
-> (forall a. Num a => StoredProcedure b a -> a)
-> Foldable (StoredProcedure b)
forall a. Eq a => a -> StoredProcedure b a -> Bool
forall a. Num a => StoredProcedure b a -> a
forall a. Ord a => StoredProcedure b a -> a
forall m. Monoid m => StoredProcedure b m -> m
forall a. StoredProcedure b a -> Bool
forall a. StoredProcedure b a -> Int
forall a. StoredProcedure b a -> [a]
forall a. (a -> a -> a) -> StoredProcedure b a -> a
forall m a. Monoid m => (a -> m) -> StoredProcedure b a -> m
forall b a. (b -> a -> b) -> b -> StoredProcedure b a -> b
forall a b. (a -> b -> b) -> b -> StoredProcedure b a -> b
forall (b :: BackendType) a.
Eq a =>
a -> StoredProcedure b a -> Bool
forall (b :: BackendType) a. Num a => StoredProcedure b a -> a
forall (b :: BackendType) a. Ord a => StoredProcedure b a -> a
forall (b :: BackendType) m. Monoid m => StoredProcedure b m -> m
forall (b :: BackendType) a. StoredProcedure b a -> Bool
forall (b :: BackendType) a. StoredProcedure b a -> Int
forall (b :: BackendType) a. StoredProcedure b a -> [a]
forall (b :: BackendType) a.
(a -> a -> a) -> StoredProcedure b a -> a
forall (b :: BackendType) m a.
Monoid m =>
(a -> m) -> StoredProcedure b a -> m
forall (b :: BackendType) b a.
(b -> a -> b) -> b -> StoredProcedure b a -> b
forall (b :: BackendType) a b.
(a -> b -> b) -> b -> StoredProcedure b a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall (b :: BackendType) m. Monoid m => StoredProcedure b m -> m
fold :: forall m. Monoid m => StoredProcedure b m -> m
$cfoldMap :: forall (b :: BackendType) m a.
Monoid m =>
(a -> m) -> StoredProcedure b a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> StoredProcedure b a -> m
$cfoldMap' :: forall (b :: BackendType) m a.
Monoid m =>
(a -> m) -> StoredProcedure b a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> StoredProcedure b a -> m
$cfoldr :: forall (b :: BackendType) a b.
(a -> b -> b) -> b -> StoredProcedure b a -> b
foldr :: forall a b. (a -> b -> b) -> b -> StoredProcedure b a -> b
$cfoldr' :: forall (b :: BackendType) a b.
(a -> b -> b) -> b -> StoredProcedure b a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> StoredProcedure b a -> b
$cfoldl :: forall (b :: BackendType) b a.
(b -> a -> b) -> b -> StoredProcedure b a -> b
foldl :: forall b a. (b -> a -> b) -> b -> StoredProcedure b a -> b
$cfoldl' :: forall (b :: BackendType) b a.
(b -> a -> b) -> b -> StoredProcedure b a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> StoredProcedure b a -> b
$cfoldr1 :: forall (b :: BackendType) a.
(a -> a -> a) -> StoredProcedure b a -> a
foldr1 :: forall a. (a -> a -> a) -> StoredProcedure b a -> a
$cfoldl1 :: forall (b :: BackendType) a.
(a -> a -> a) -> StoredProcedure b a -> a
foldl1 :: forall a. (a -> a -> a) -> StoredProcedure b a -> a
$ctoList :: forall (b :: BackendType) a. StoredProcedure b a -> [a]
toList :: forall a. StoredProcedure b a -> [a]
$cnull :: forall (b :: BackendType) a. StoredProcedure b a -> Bool
null :: forall a. StoredProcedure b a -> Bool
$clength :: forall (b :: BackendType) a. StoredProcedure b a -> Int
length :: forall a. StoredProcedure b a -> Int
$celem :: forall (b :: BackendType) a.
Eq a =>
a -> StoredProcedure b a -> Bool
elem :: forall a. Eq a => a -> StoredProcedure b a -> Bool
$cmaximum :: forall (b :: BackendType) a. Ord a => StoredProcedure b a -> a
maximum :: forall a. Ord a => StoredProcedure b a -> a
$cminimum :: forall (b :: BackendType) a. Ord a => StoredProcedure b a -> a
minimum :: forall a. Ord a => StoredProcedure b a -> a
$csum :: forall (b :: BackendType) a. Num a => StoredProcedure b a -> a
sum :: forall a. Num a => StoredProcedure b a -> a
$cproduct :: forall (b :: BackendType) a. Num a => StoredProcedure b a -> a
product :: forall a. Num a => StoredProcedure b a -> a
Foldable, Functor (StoredProcedure b)
Foldable (StoredProcedure b)
Functor (StoredProcedure b)
-> Foldable (StoredProcedure b)
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> StoredProcedure b a -> f (StoredProcedure b b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    StoredProcedure b (f a) -> f (StoredProcedure b a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> StoredProcedure b a -> m (StoredProcedure b b))
-> (forall (m :: * -> *) a.
    Monad m =>
    StoredProcedure b (m a) -> m (StoredProcedure b a))
-> Traversable (StoredProcedure b)
forall (b :: BackendType). Functor (StoredProcedure b)
forall (b :: BackendType). Foldable (StoredProcedure b)
forall (b :: BackendType) (m :: * -> *) a.
Monad m =>
StoredProcedure b (m a) -> m (StoredProcedure b a)
forall (b :: BackendType) (f :: * -> *) a.
Applicative f =>
StoredProcedure b (f a) -> f (StoredProcedure b a)
forall (b :: BackendType) (m :: * -> *) a b.
Monad m =>
(a -> m b) -> StoredProcedure b a -> m (StoredProcedure b b)
forall (b :: BackendType) (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> StoredProcedure b a -> f (StoredProcedure b b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
StoredProcedure b (m a) -> m (StoredProcedure b a)
forall (f :: * -> *) a.
Applicative f =>
StoredProcedure b (f a) -> f (StoredProcedure b a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> StoredProcedure b a -> m (StoredProcedure b b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> StoredProcedure b a -> f (StoredProcedure b b)
$ctraverse :: forall (b :: BackendType) (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> StoredProcedure b a -> f (StoredProcedure b b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> StoredProcedure b a -> f (StoredProcedure b b)
$csequenceA :: forall (b :: BackendType) (f :: * -> *) a.
Applicative f =>
StoredProcedure b (f a) -> f (StoredProcedure b a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
StoredProcedure b (f a) -> f (StoredProcedure b a)
$cmapM :: forall (b :: BackendType) (m :: * -> *) a b.
Monad m =>
(a -> m b) -> StoredProcedure b a -> m (StoredProcedure b b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> StoredProcedure b a -> m (StoredProcedure b b)
$csequence :: forall (b :: BackendType) (m :: * -> *) a.
Monad m =>
StoredProcedure b (m a) -> m (StoredProcedure b a)
sequence :: forall (m :: * -> *) a.
Monad m =>
StoredProcedure b (m a) -> m (StoredProcedure b a)
Traversable)

deriving instance (Backend b, Eq field) => Eq (StoredProcedure b field)

deriving instance (Backend b, Show field) => Show (StoredProcedure b field)