{-# LANGUAGE TemplateHaskell #-}
module Hasura.RQL.Types.Backend
( Backend (..),
Representable,
SessionVarType,
XDisable,
XEnable,
ComputedFieldReturnType (..),
_ReturnsTable,
SupportedNamingCase (..),
)
where
import Autodocodec (HasCodec)
import Control.Lens.TH (makePrisms)
import Data.Aeson.Extended
import Data.Kind (Type)
import Data.Text.Casing (GQLNameIdentifier)
import Data.Text.Extended
import Data.Typeable (Typeable)
import Hasura.Base.Error
import Hasura.Base.ToErrorValue
import Hasura.Incremental (Cacheable)
import Hasura.Prelude
import Hasura.SQL.Backend
import Hasura.SQL.Tag
import Hasura.SQL.Types
import Language.GraphQL.Draft.Syntax qualified as G
type Representable a = (Show a, Eq a, Hashable a, Cacheable a, NFData a)
type SessionVarType b = CollectableType (ScalarType b)
data ComputedFieldReturnType (b :: BackendType)
= ReturnsScalar (ScalarType b)
| ReturnsTable (TableName b)
| ReturnsOthers
type XEnable = ()
type XDisable = Void
data SupportedNamingCase = OnlyHasuraCase | AllConventions
class
( Representable (TableName b),
Representable (FunctionName b),
Representable (FunctionArgument b),
Representable (ConstraintName b),
Representable (BasicOrderType b),
Representable (NullsOrderType b),
Representable (Column b),
Representable (ScalarType b),
Representable (SQLExpression b),
Representable (ScalarSelectionArguments b),
Representable (SourceConnConfiguration b),
Representable (ExtraTableMetadata b),
Representable (XComputedField b),
Representable (ComputedFieldDefinition b),
Representable (ComputedFieldImplicitArguments b),
Representable (ComputedFieldReturn b),
Ord (TableName b),
Ord (FunctionName b),
Ord (ScalarType b),
Data (TableName b),
FromJSON (BackendConfig b),
FromJSON (Column b),
FromJSON (ConstraintName b),
FromJSON (FunctionName b),
FromJSON (ScalarType b),
FromJSON (TableName b),
FromJSON (SourceConnConfiguration b),
FromJSON (ExtraTableMetadata b),
FromJSON (ComputedFieldDefinition b),
FromJSON (BackendSourceKind b),
FromJSONKey (Column b),
HasCodec (BackendSourceKind b),
HasCodec (SourceConnConfiguration b),
ToJSON (BackendConfig b),
ToJSON (Column b),
ToJSON (ConstraintName b),
ToJSON (FunctionArgument b),
ToJSON (FunctionName b),
ToJSON (ScalarType b),
ToJSON (SourceConfig b),
ToJSON (TableName b),
ToJSON (SourceConnConfiguration b),
ToJSON (ExtraTableMetadata b),
ToJSON (SQLExpression b),
ToJSON (ComputedFieldDefinition b),
ToJSON (ComputedFieldImplicitArguments b),
ToJSON (ComputedFieldReturn b),
ToJSONKey (Column b),
ToJSONKey (FunctionName b),
ToJSONKey (ScalarType b),
ToJSONKey (TableName b),
ToTxt (Column b),
ToTxt (FunctionName b),
ToTxt (ScalarType b),
ToTxt (TableName b),
ToTxt (ConstraintName b),
ToErrorValue (Column b),
ToErrorValue (FunctionName b),
ToErrorValue (ScalarType b),
ToErrorValue (TableName b),
ToErrorValue (ConstraintName b),
Cacheable (SourceConfig b),
Cacheable (BackendConfig b),
Typeable (TableName b),
Typeable (ConstraintName b),
Typeable b,
HasTag b,
Functor (FunctionArgumentExp b),
Foldable (FunctionArgumentExp b),
Traversable (FunctionArgumentExp b),
Eq (BackendConfig b),
Show (BackendConfig b),
Monoid (BackendConfig b),
Eq (CountType b),
Show (CountType b),
Eq (ScalarValue b),
Show (ScalarValue b),
Eq (XNodesAgg b),
Show (XNodesAgg b),
Eq (XRelay b),
Show (XRelay b),
Eq (XStreamingSubscription b),
Show (XStreamingSubscription b),
Traversable (BooleanOperators b),
Functor (BackendUpdate b),
Foldable (BackendUpdate b),
Traversable (BackendUpdate b),
Functor (BackendInsert b),
Foldable (BackendInsert b),
Traversable (BackendInsert b),
Functor (AggregationPredicates b),
Foldable (AggregationPredicates b),
Traversable (AggregationPredicates b)
) =>
Backend (b :: BackendType)
where
type BackendConfig b :: Type
type SourceConnConfiguration b :: Type
type SourceConfig b :: Type
type TableName b :: Type
type FunctionName b :: Type
type RawFunctionInfo b :: Type
type ConstraintName b :: Type
type BasicOrderType b :: Type
type NullsOrderType b :: Type
type CountType b :: Type
type Column b :: Type
type ScalarValue b :: Type
type ScalarType b :: Type
type SQLExpression b :: Type
type ComputedFieldDefinition b :: Type
type ScalarSelectionArguments b :: Type
type b :: Type
type FunctionArgument b :: Type
type FunctionArgumentExp b :: Type -> Type
type ComputedFieldImplicitArguments b :: Type
type ComputedFieldReturn b :: Type
type BooleanOperators b :: Type -> Type
type AggregationPredicates b :: Type -> Type
type AggregationPredicates b = Const Void
type BackendUpdate b :: Type -> Type
type BackendUpdate b = Const Void
type BackendInsert b :: Type -> Type
type BackendInsert b = Const Void
type XComputedField b :: Type
type XRelay b :: Type
type XNodesAgg b :: Type
type XNestedInserts b :: Type
type XStreamingSubscription b :: Type
isComparableType :: ScalarType b -> Bool
isNumType :: ScalarType b -> Bool
textToScalarValue :: Maybe Text -> ScalarValue b
parseScalarValue :: ScalarType b -> Value -> Either QErr (ScalarValue b)
scalarValueToJSON :: ScalarValue b -> Value
functionToTable :: FunctionName b -> TableName b
tableToFunction :: TableName b -> FunctionName b
computedFieldFunction :: ComputedFieldDefinition b -> FunctionName b
computedFieldReturnType :: ComputedFieldReturn b -> ComputedFieldReturnType b
fromComputedFieldImplicitArguments :: v -> ComputedFieldImplicitArguments b -> [FunctionArgumentExp b v]
tableGraphQLName :: TableName b -> Either QErr G.Name
functionGraphQLName :: FunctionName b -> Either QErr G.Name
getTableIdentifier :: TableName b -> Either QErr GQLNameIdentifier
snakeCaseTableName :: TableName b -> Text
namingConventionSupport :: SupportedNamingCase
$(makePrisms ''ComputedFieldReturnType)