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

Hasura.RQL.DDL.Webhook.Transform.Class

Description

The Transform typeclass with various types and helper functions for evaluating transformations.

Synopsis

Documentation

class Transform a where Source #

Transform describes how to reify a defunctionalized transformation for a particular request field.

Associated Types

data TransformFn a :: Type Source #

The associated type 'TransformFn a' is the defunctionalized version of some transformation that should be applied to a given request field.

In most cases it is some variation on a piece of template text describing the transformation.

Methods

transform :: MonadError TransformErrorBundle m => TransformFn a -> RequestTransformCtx -> a -> m a Source #

transform is a function which takes TransformFn of a and reifies it into a function of the form:

  ReqTransformCtx -> a -> m a

validate :: TemplatingEngine -> TransformFn a -> Validation TransformErrorBundle () Source #

Validate a TransformFn of a.

Instances

Instances details
Transform Url Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Url

Associated Types

data TransformFn Url Source #

Transform QueryParams Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.QueryParams

Associated Types

data TransformFn QueryParams Source #

Transform Method Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Method

Associated Types

data TransformFn Method Source #

Transform Headers Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Headers

Associated Types

data TransformFn Headers Source #

Transform Body Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Body

Associated Types

data TransformFn Body Source #

newtype TransformErrorBundle Source #

We use collect all transformation failures as a '[J.Value]'.

Constructors

TransformErrorBundle 

Fields

Instances

Instances details
Eq TransformErrorBundle Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Show TransformErrorBundle Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Generic TransformErrorBundle Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Associated Types

type Rep TransformErrorBundle :: Type -> Type #

Semigroup TransformErrorBundle Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Monoid TransformErrorBundle Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

NFData TransformErrorBundle Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

rnf :: TransformErrorBundle -> () #

FromJSON TransformErrorBundle Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

parseJSON :: Value -> Parser TransformErrorBundle

parseJSONList :: Value -> Parser [TransformErrorBundle]

ToJSON TransformErrorBundle Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Cacheable TransformErrorBundle Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

type Rep TransformErrorBundle Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

type Rep TransformErrorBundle = D1 ('MetaData "TransformErrorBundle" "Hasura.RQL.DDL.Webhook.Transform.Class" "graphql-engine-1.0.0-inplace" 'True) (C1 ('MetaCons "TransformErrorBundle" 'PrefixI 'True) (S1 ('MetaSel ('Just "tebMessages") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Value])))

throwErrorBundle :: MonadError TransformErrorBundle m => Text -> Maybe Value -> m a Source #

A helper function for serializing transformation errors to JSON.

data RequestTransformCtx Source #

Common context that is made available to all request transformations.

Constructors

RequestTransformCtx 

Fields

Instances

Instances details
ToJSON RequestTransformCtx Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

mkReqTransformCtx :: Text -> Maybe SessionVariables -> TemplatingEngine -> Request -> RequestTransformCtx Source #

A smart constructor for constructing the RequestTransformCtx

XXX: This function makes internal usage of decodeUtf8, which throws an impure exception when the supplied ByteString cannot be decoded into valid UTF8 text!

data ResponseTransformCtx Source #

Common context that is made available to all response transformations.

Constructors

ResponseTransformCtx 

Fields

data TemplatingEngine Source #

Available templating engines.

Constructors

Kriti 

Instances

Instances details
Bounded TemplatingEngine Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Enum TemplatingEngine Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Eq TemplatingEngine Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Show TemplatingEngine Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Generic TemplatingEngine Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Associated Types

type Rep TemplatingEngine :: Type -> Type #

NFData TemplatingEngine Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

rnf :: TemplatingEngine -> () #

FromJSON TemplatingEngine Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

parseJSON :: Value -> Parser TemplatingEngine

parseJSONList :: Value -> Parser [TemplatingEngine]

ToJSON TemplatingEngine Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Cacheable TemplatingEngine Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

type Rep TemplatingEngine Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

type Rep TemplatingEngine = D1 ('MetaData "TemplatingEngine" "Hasura.RQL.DDL.Webhook.Transform.Class" "graphql-engine-1.0.0-inplace" 'False) (C1 ('MetaCons "Kriti" 'PrefixI 'False) (U1 :: Type -> Type))

newtype Template Source #

Textual transformation template.

Constructors

Template 

Fields

Instances

Instances details
Eq Template Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Ord Template Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Show Template Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Generic Template Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Associated Types

type Rep Template :: Type -> Type #

Methods

from :: Template -> Rep Template x #

to :: Rep Template x -> Template #

NFData Template Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

rnf :: Template -> () #

Hashable Template Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

FromJSONKey Template Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

fromJSONKey :: FromJSONKeyFunction Template

fromJSONKeyList :: FromJSONKeyFunction [Template]

FromJSON Template Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

parseJSON :: Value -> Parser Template

parseJSONList :: Value -> Parser [Template]

ToJSONKey Template Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

toJSONKey :: ToJSONKeyFunction Template

toJSONKeyList :: ToJSONKeyFunction [Template]

ToJSON Template Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

toJSON :: Template -> Value

toEncoding :: Template -> Encoding

toJSONList :: [Template] -> Value

toEncodingList :: [Template] -> Encoding

Cacheable Template Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

type Rep Template Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

type Rep Template = D1 ('MetaData "Template" "Hasura.RQL.DDL.Webhook.Transform.Class" "graphql-engine-1.0.0-inplace" 'True) (C1 ('MetaCons "Template" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTemplate") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

runRequestTemplateTransform :: Template -> RequestTransformCtx -> Either TransformErrorBundle Value Source #

A helper function for executing transformations from a Template and a RequestTransformCtx.

NOTE: This and all related funtions are hard-coded to Kriti at the moment. When we add additional template engines this function will need to take a TemplatingEngine parameter.

runResponseTemplateTransform :: Template -> ResponseTransformCtx -> Either TransformErrorBundle Value Source #

A helper function for executing transformations from a Template and a ResponseTransformCtx.

NOTE: This and all related funtions are hard-coded to Kriti at the moment. When we add additional template engines this function will need to take a TemplatingEngine parameter.

data Version Source #

RequestTransform Versioning

Constructors

V1 
V2 

Instances

Instances details
Eq Version Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

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

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

Show Version Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Generic Version Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Associated Types

type Rep Version :: Type -> Type #

Methods

from :: Version -> Rep Version x #

to :: Rep Version x -> Version #

NFData Version Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

rnf :: Version -> () #

Hashable Version Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

hashWithSalt :: Int -> Version -> Int

hash :: Version -> Int

FromJSON Version Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

parseJSON :: Value -> Parser Version

parseJSONList :: Value -> Parser [Version]

ToJSON Version Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

toJSON :: Version -> Value

toEncoding :: Version -> Encoding

toJSONList :: [Version] -> Value

toEncodingList :: [Version] -> Encoding

Cacheable Version Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

type Rep Version Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

type Rep Version = D1 ('MetaData "Version" "Hasura.RQL.DDL.Webhook.Transform.Class" "graphql-engine-1.0.0-inplace" 'False) (C1 ('MetaCons "V1" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "V2" 'PrefixI 'False) (U1 :: Type -> Type))

newtype UnescapedTemplate Source #

Validated textual transformation template /for string interpolation only/.

This is necessary due to Kriti not distinguishing between string literals and string templates.

Constructors

UnescapedTemplate 

Fields

Instances

Instances details
Eq UnescapedTemplate Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Ord UnescapedTemplate Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Show UnescapedTemplate Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Generic UnescapedTemplate Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Associated Types

type Rep UnescapedTemplate :: Type -> Type #

NFData UnescapedTemplate Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

rnf :: UnescapedTemplate -> () #

Hashable UnescapedTemplate Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

FromJSONKey UnescapedTemplate Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

fromJSONKey :: FromJSONKeyFunction UnescapedTemplate

fromJSONKeyList :: FromJSONKeyFunction [UnescapedTemplate]

FromJSON UnescapedTemplate Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

parseJSON :: Value -> Parser UnescapedTemplate

parseJSONList :: Value -> Parser [UnescapedTemplate]

ToJSONKey UnescapedTemplate Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Methods

toJSONKey :: ToJSONKeyFunction UnescapedTemplate

toJSONKeyList :: ToJSONKeyFunction [UnescapedTemplate]

ToJSON UnescapedTemplate Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

Cacheable UnescapedTemplate Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

type Rep UnescapedTemplate Source # 
Instance details

Defined in Hasura.RQL.DDL.Webhook.Transform.Class

type Rep UnescapedTemplate = D1 ('MetaData "UnescapedTemplate" "Hasura.RQL.DDL.Webhook.Transform.Class" "graphql-engine-1.0.0-inplace" 'True) (C1 ('MetaCons "UnescapedTemplate" 'PrefixI 'True) (S1 ('MetaSel ('Just "getUnescapedTemplate") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

runUnescapedRequestTemplateTransform :: RequestTransformCtx -> UnescapedTemplate -> Either TransformErrorBundle ByteString Source #

A helper function for executing Kriti transformations from a UnescapedTemplate and a RequestTrasformCtx.

The difference from runRequestTemplateTransform is that this function will wrap the template text in double quotes before running Kriti.

runUnescapedRequestTemplateTransform' :: RequestTransformCtx -> UnescapedTemplate -> Validation TransformErrorBundle ByteString Source #

Run a Kriti transformation with an unescaped template in Validation instead of Either.

encodeScalar :: MonadError TransformErrorBundle m => Value -> m ByteString Source #

Encode a JSON Scalar Value as a ByteString. If a non-Scalar value is provided, will return a TrnasformErrorBundle