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

Hasura.Backends.MSSQL.FromIr

Description

The modules in the Hasura.Backends.MSSQL.FromIr namespace translates the RQL IR into TSQL, the SQL dialect of MSSQL, as defined in abstract syntax in Hasura.Backends.MSSQL.Types.

The translation happens in the FromIr monad, which manages identifier scoping and error collection.

The actual rendering of this AST into TSQL text happens in Hasura.Backends.MSSQL.ToQuery.

Synopsis

Documentation

newtype FromIr a Source #

The central Monad used throughout for all conversion functions.

It has the following features:

  • It's a MonadValidate, so it'll continue going when it encounters Errors to accumulate as many as possible.
  • It has a facility for generating fresh, unique aliases, which lets the translation output retain a resemblance with source names without the translation process needing to be bothered about potential name shadowing. See generateAlias.

Constructors

FromIr 

Fields

Instances

Instances details
Monad FromIr Source # 
Instance details

Defined in Hasura.Backends.MSSQL.FromIr

Methods

(>>=) :: FromIr a -> (a -> FromIr b) -> FromIr b #

(>>) :: FromIr a -> FromIr b -> FromIr b #

return :: a -> FromIr a #

Functor FromIr Source # 
Instance details

Defined in Hasura.Backends.MSSQL.FromIr

Methods

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

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

Applicative FromIr Source # 
Instance details

Defined in Hasura.Backends.MSSQL.FromIr

Methods

pure :: a -> FromIr a #

(<*>) :: FromIr (a -> b) -> FromIr a -> FromIr b #

liftA2 :: (a -> b -> c) -> FromIr a -> FromIr b -> FromIr c #

(*>) :: FromIr a -> FromIr b -> FromIr b #

(<*) :: FromIr a -> FromIr b -> FromIr a #

MonadValidate (NonEmpty Error) FromIr Source # 
Instance details

Defined in Hasura.Backends.MSSQL.FromIr

runFromIr :: MonadError QErr m => FromIr a -> m a Source #

Run a FromIr action, throwing errors that have been collected using the supplied action.

data Error Source #

Errors that may happen during translation.

Instances

Instances details
Eq Error Source # 
Instance details

Defined in Hasura.Backends.MSSQL.FromIr

Methods

(==) :: Error -> Error -> Bool #

(/=) :: Error -> Error -> Bool #

Show Error Source # 
Instance details

Defined in Hasura.Backends.MSSQL.FromIr

Methods

showsPrec :: Int -> Error -> ShowS #

show :: Error -> String #

showList :: [Error] -> ShowS #

MonadValidate (NonEmpty Error) FromIr Source # 
Instance details

Defined in Hasura.Backends.MSSQL.FromIr

data NameTemplate Source #

Hints about the type of entity that generateAlias is producing an alias for.

generateAlias :: NameTemplate -> FromIr Text Source #

Generate a fresh alias for a given entity to remove ambiguity and naming conflicts between scopes at the TSQL level.

Names are generated in the form type_name_occurrence, where:

  • type hints at the type of entity,
  • name refers to the source name being aliased, and
  • occurrence is an integer counter that distinguishes each occurrence of type_name.

Example outputs:

do
  "ar_articles_1" <- generateAlias (ArrayRelationTemplate "articles")
  "ar_articles_2" <- generateAlias (ArrayRelationTemplate "articles")
  "t_users_1"     <- generateAlias (TableTemplate "users")