graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.RQL.IR.Insert

Description

Internal representation of an insertion in a database table.

What makes this specific mutation tricky is that we support recursive insertions, across local relationships. Because local joins come in two different kinds (object relationships and array relations), and because for each table we expose two root different root fields (insert_one and insert), we distinguish between *single row inserts* and *multi rows inserts*.

TODO: the distinction between single-row inserts and multi-rows inserts does not need to be enforced the way it currently is, with booleans and different types. The distinction could be made in the translation layer, if need be.

Synopsis

Documentation

data AnnotatedInsert (b :: BackendType) (r :: Type) v Source #

Overall representation of an insert mutation, corresponding to one root field in our mutation, including the parsed selection set of the mutation's output. For historical reasons, it will always contain a MultiObjectInsert, whether the root mutation is a single row or not, and will distinguish between them using a boolean field.

Instances

Instances details
Backend b => Functor (AnnotatedInsert b r) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

fmap :: (a -> b0) -> AnnotatedInsert b r a -> AnnotatedInsert b r b0 #

(<$) :: a -> AnnotatedInsert b r b0 -> AnnotatedInsert b r a #

Backend b => Foldable (AnnotatedInsert b r) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

fold :: Monoid m => AnnotatedInsert b r m -> m #

foldMap :: Monoid m => (a -> m) -> AnnotatedInsert b r a -> m #

foldMap' :: Monoid m => (a -> m) -> AnnotatedInsert b r a -> m #

foldr :: (a -> b0 -> b0) -> b0 -> AnnotatedInsert b r a -> b0 #

foldr' :: (a -> b0 -> b0) -> b0 -> AnnotatedInsert b r a -> b0 #

foldl :: (b0 -> a -> b0) -> b0 -> AnnotatedInsert b r a -> b0 #

foldl' :: (b0 -> a -> b0) -> b0 -> AnnotatedInsert b r a -> b0 #

foldr1 :: (a -> a -> a) -> AnnotatedInsert b r a -> a #

foldl1 :: (a -> a -> a) -> AnnotatedInsert b r a -> a #

toList :: AnnotatedInsert b r a -> [a] #

null :: AnnotatedInsert b r a -> Bool #

length :: AnnotatedInsert b r a -> Int #

elem :: Eq a => a -> AnnotatedInsert b r a -> Bool #

maximum :: Ord a => AnnotatedInsert b r a -> a #

minimum :: Ord a => AnnotatedInsert b r a -> a #

sum :: Num a => AnnotatedInsert b r a -> a #

product :: Num a => AnnotatedInsert b r a -> a #

Backend b => Traversable (AnnotatedInsert b r) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

traverse :: Applicative f => (a -> f b0) -> AnnotatedInsert b r a -> f (AnnotatedInsert b r b0) #

sequenceA :: Applicative f => AnnotatedInsert b r (f a) -> f (AnnotatedInsert b r a) #

mapM :: Monad m => (a -> m b0) -> AnnotatedInsert b r a -> m (AnnotatedInsert b r b0) #

sequence :: Monad m => AnnotatedInsert b r (m a) -> m (AnnotatedInsert b r a) #

data AnnotatedInsertData (b :: BackendType) (f :: Type -> Type) (v :: Type) Source #

One individual insert, one node from the tree. The f parameter is used to construct the container for the values to be inserted: Single for a single-row insert, '[]' for a multi-row insert.

Instances

Instances details
(Backend b, Functor f) => Functor (AnnotatedInsertData b f) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

fmap :: (a -> b0) -> AnnotatedInsertData b f a -> AnnotatedInsertData b f b0 #

(<$) :: a -> AnnotatedInsertData b f b0 -> AnnotatedInsertData b f a #

(Backend b, Foldable f) => Foldable (AnnotatedInsertData b f) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

fold :: Monoid m => AnnotatedInsertData b f m -> m #

foldMap :: Monoid m => (a -> m) -> AnnotatedInsertData b f a -> m #

foldMap' :: Monoid m => (a -> m) -> AnnotatedInsertData b f a -> m #

foldr :: (a -> b0 -> b0) -> b0 -> AnnotatedInsertData b f a -> b0 #

foldr' :: (a -> b0 -> b0) -> b0 -> AnnotatedInsertData b f a -> b0 #

foldl :: (b0 -> a -> b0) -> b0 -> AnnotatedInsertData b f a -> b0 #

foldl' :: (b0 -> a -> b0) -> b0 -> AnnotatedInsertData b f a -> b0 #

foldr1 :: (a -> a -> a) -> AnnotatedInsertData b f a -> a #

foldl1 :: (a -> a -> a) -> AnnotatedInsertData b f a -> a #

toList :: AnnotatedInsertData b f a -> [a] #

null :: AnnotatedInsertData b f a -> Bool #

length :: AnnotatedInsertData b f a -> Int #

elem :: Eq a => a -> AnnotatedInsertData b f a -> Bool #

maximum :: Ord a => AnnotatedInsertData b f a -> a #

minimum :: Ord a => AnnotatedInsertData b f a -> a #

sum :: Num a => AnnotatedInsertData b f a -> a #

product :: Num a => AnnotatedInsertData b f a -> a #

(Backend b, Traversable f) => Traversable (AnnotatedInsertData b f) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

traverse :: Applicative f0 => (a -> f0 b0) -> AnnotatedInsertData b f a -> f0 (AnnotatedInsertData b f b0) #

sequenceA :: Applicative f0 => AnnotatedInsertData b f (f0 a) -> f0 (AnnotatedInsertData b f a) #

mapM :: Monad m => (a -> m b0) -> AnnotatedInsertData b f a -> m (AnnotatedInsertData b f b0) #

sequence :: Monad m => AnnotatedInsertData b f (m a) -> m (AnnotatedInsertData b f a) #

newtype Single a Source #

Ad-hoc helper. We differientate between single row inserts (SingleObjIns) and multiple row inserts (MultiObjIns), but both use the same underlying representation: AnnIns. The only difference is which functor is used as a parameter. We use '[]' for MultiObjIns, and we use this trivial Single for SingleObjIns.

Constructors

Single 

Fields

Instances

Instances details
Functor Single Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

fmap :: (a -> b) -> Single a -> Single b #

(<$) :: a -> Single b -> Single a #

Foldable Single Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

fold :: Monoid m => Single m -> m #

foldMap :: Monoid m => (a -> m) -> Single a -> m #

foldMap' :: Monoid m => (a -> m) -> Single a -> m #

foldr :: (a -> b -> b) -> b -> Single a -> b #

foldr' :: (a -> b -> b) -> b -> Single a -> b #

foldl :: (b -> a -> b) -> b -> Single a -> b #

foldl' :: (b -> a -> b) -> b -> Single a -> b #

foldr1 :: (a -> a -> a) -> Single a -> a #

foldl1 :: (a -> a -> a) -> Single a -> a #

toList :: Single a -> [a] #

null :: Single a -> Bool #

length :: Single a -> Int #

elem :: Eq a => a -> Single a -> Bool #

maximum :: Ord a => Single a -> a #

minimum :: Ord a => Single a -> a #

sum :: Num a => Single a -> a #

product :: Num a => Single a -> a #

Traversable Single Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

traverse :: Applicative f => (a -> f b) -> Single a -> f (Single b) #

sequenceA :: Applicative f => Single (f a) -> f (Single a) #

mapM :: Monad m => (a -> m b) -> Single a -> m (Single b) #

sequence :: Monad m => Single (m a) -> m (Single a) #

data AnnotatedInsertField (b :: BackendType) v Source #

An insert item. The object and array relationships are not unavailable when 'XNestedInserts b = XDisable'

Instances

Instances details
Backend b => Functor (AnnotatedInsertField b) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

fmap :: (a -> b0) -> AnnotatedInsertField b a -> AnnotatedInsertField b b0 #

(<$) :: a -> AnnotatedInsertField b b0 -> AnnotatedInsertField b a #

Backend b => Foldable (AnnotatedInsertField b) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

fold :: Monoid m => AnnotatedInsertField b m -> m #

foldMap :: Monoid m => (a -> m) -> AnnotatedInsertField b a -> m #

foldMap' :: Monoid m => (a -> m) -> AnnotatedInsertField b a -> m #

foldr :: (a -> b0 -> b0) -> b0 -> AnnotatedInsertField b a -> b0 #

foldr' :: (a -> b0 -> b0) -> b0 -> AnnotatedInsertField b a -> b0 #

foldl :: (b0 -> a -> b0) -> b0 -> AnnotatedInsertField b a -> b0 #

foldl' :: (b0 -> a -> b0) -> b0 -> AnnotatedInsertField b a -> b0 #

foldr1 :: (a -> a -> a) -> AnnotatedInsertField b a -> a #

foldl1 :: (a -> a -> a) -> AnnotatedInsertField b a -> a #

toList :: AnnotatedInsertField b a -> [a] #

null :: AnnotatedInsertField b a -> Bool #

length :: AnnotatedInsertField b a -> Int #

elem :: Eq a => a -> AnnotatedInsertField b a -> Bool #

maximum :: Ord a => AnnotatedInsertField b a -> a #

minimum :: Ord a => AnnotatedInsertField b a -> a #

sum :: Num a => AnnotatedInsertField b a -> a #

product :: Num a => AnnotatedInsertField b a -> a #

Backend b => Traversable (AnnotatedInsertField b) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

traverse :: Applicative f => (a -> f b0) -> AnnotatedInsertField b a -> f (AnnotatedInsertField b b0) #

sequenceA :: Applicative f => AnnotatedInsertField b (f a) -> f (AnnotatedInsertField b a) #

mapM :: Monad m => (a -> m b0) -> AnnotatedInsertField b a -> m (AnnotatedInsertField b b0) #

sequence :: Monad m => AnnotatedInsertField b (m a) -> m (AnnotatedInsertField b a) #

type AnnotatedInsertRow b v = [AnnotatedInsertField b v] Source #

One individual row to be inserted. Contains the columns' values and all the matching recursive relationship inserts.

data RelationInsert (b :: BackendType) a Source #

One individual relationship. Unlike other types, this one is not parameterized by the type of the leaves v, but by the kind of insert has to be performed: multi-row or single row. See ObjectRelationInsert and ArrayRelationInsert.

Constructors

RelationInsert 

Instances

Instances details
Functor (RelationInsert b) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

fmap :: (a -> b0) -> RelationInsert b a -> RelationInsert b b0 #

(<$) :: a -> RelationInsert b b0 -> RelationInsert b a #

Foldable (RelationInsert b) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

fold :: Monoid m => RelationInsert b m -> m #

foldMap :: Monoid m => (a -> m) -> RelationInsert b a -> m #

foldMap' :: Monoid m => (a -> m) -> RelationInsert b a -> m #

foldr :: (a -> b0 -> b0) -> b0 -> RelationInsert b a -> b0 #

foldr' :: (a -> b0 -> b0) -> b0 -> RelationInsert b a -> b0 #

foldl :: (b0 -> a -> b0) -> b0 -> RelationInsert b a -> b0 #

foldl' :: (b0 -> a -> b0) -> b0 -> RelationInsert b a -> b0 #

foldr1 :: (a -> a -> a) -> RelationInsert b a -> a #

foldl1 :: (a -> a -> a) -> RelationInsert b a -> a #

toList :: RelationInsert b a -> [a] #

null :: RelationInsert b a -> Bool #

length :: RelationInsert b a -> Int #

elem :: Eq a => a -> RelationInsert b a -> Bool #

maximum :: Ord a => RelationInsert b a -> a #

minimum :: Ord a => RelationInsert b a -> a #

sum :: Num a => RelationInsert b a -> a #

product :: Num a => RelationInsert b a -> a #

Traversable (RelationInsert b) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

Methods

traverse :: Applicative f => (a -> f b0) -> RelationInsert b a -> f (RelationInsert b b0) #

sequenceA :: Applicative f => RelationInsert b (f a) -> f (RelationInsert b a) #

mapM :: Monad m => (a -> m b0) -> RelationInsert b a -> m (RelationInsert b b0) #

sequence :: Monad m => RelationInsert b (m a) -> m (RelationInsert b a) #

(Backend b, Eq a) => Eq (RelationInsert b a) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

(Backend b, Show a) => Show (RelationInsert b a) Source # 
Instance details

Defined in Hasura.RQL.IR.Insert

type ObjectRelationInsert b v = RelationInsert b (SingleObjectInsert b v) Source #

Insert across an object relationship. Object relationships are 1:1 relationships across tables; an insert across such a relationship can only insert one single row at a time; RelIns is therefore parameterized by a SingleObjectInsert.

type ArrayRelationInsert b v = RelationInsert b (MultiObjectInsert b v) Source #

Insert across an array relationship. Array relationships are 1:* relationships across tables; an insert across such a relationship may therefore contain multiple rows; RelIns is therefore parameterized by a MultiObjectInsert.

data InsertQueryP1 (b :: BackendType) Source #

Old-style representation used for non-recursive insertions. This is the representation used by RQL.DML, instead of the new fancy recursive one present in this file. Postgres supports both representations, and actually translates recursive queries that do not have any relationships into this representation first.

aiOutput :: forall b r v r. Lens (AnnotatedInsert b r v) (AnnotatedInsert b r v) (MutationOutputG b r v) (MutationOutputG b r v) Source #

aiNamingConvention :: forall b r v. Lens' (AnnotatedInsert b r v) (Maybe NamingCase) Source #

aiIsSingle :: forall b r v. Lens' (AnnotatedInsert b r v) Bool Source #

aiFieldName :: forall b r v. Lens' (AnnotatedInsert b r v) Text Source #

aiData :: forall b r v. Lens' (AnnotatedInsert b r v) (MultiObjectInsert b v) Source #

_AIColumn :: forall b v. Prism' (AnnotatedInsertField b v) (Column b, v) Source #