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

Hasura.Backends.Postgres.Instances.Schema

Description

Postgres Instances Schema

Defines a BackendSchema type class instance for Postgres.

Synopsis

Documentation

class PostgresSchema (pgKind :: PostgresKind) where Source #

This class is an implementation detail of BackendSchema. Some functions of BackendSchema differ across different Postgres "kinds", or call to functions (such as those related to Relay) that have not been generalized to all kinds of Postgres and still explicitly work on Vanilla Postgres. This class allows each "kind" to specify its own specific implementation. All common code is directly part of BackendSchema.

Note: Users shouldn't ever put this as a constraint. Use `BackendSchema ('Postgres pgKind)` instead.

_aggregationFunctions :: [FunctionSignature ('Postgres pgKind)] Source #

The aggregation functions that are supported by postgres variants. TODO: Add more.

backendInsertParser :: forall pgKind m r n. MonadBuildSchema ('Postgres pgKind) r m n => SourceInfo ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> m (InputFieldsParser n (BackendInsert pgKind (UnpreparedValue ('Postgres pgKind)))) Source #

pgkBuildTableUpdateMutationFields Source #

Arguments

:: forall r m n pgKind. (MonadBuildSchema ('Postgres pgKind) r m n, BackendTableSelectSchema ('Postgres pgKind)) 
=> MkRootFieldName 
-> Scenario 
-> SourceInfo ('Postgres pgKind)

The source that the table lives in

-> TableName ('Postgres pgKind)

The name of the table being acted on

-> TableInfo ('Postgres pgKind)

table info

-> GQLNameIdentifier

field display name

-> m [FieldParser n (AnnotatedUpdateG ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind)))] 

updateTableMany :: forall r m n pgKind. (MonadBuildSchema ('Postgres pgKind) r m n, BackendTableSelectSchema ('Postgres pgKind)) => MkRootFieldName -> Scenario -> SourceInfo ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> GQLNameIdentifier -> m (Maybe (FieldParser n (AnnotatedUpdateG ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind))))) Source #

Create a parser for update_table_many. This function is very similar to both buildTableUpdateMutationFields and updateTable.

It is similar to the former because of its shape: has to deal with grabbing the casing, deals with update permissions, etc.

It is similar to the latter because it deals with creating the parsersubselectionetc.

The reason this function exists here is because it is Postgres specific. It would not fit very well next to the functions mentioned above.

However, if you are trying to implement this feature for other backends, please consider making this function similar to updateTable and moving it there. Note: this will likely require adding a type or a function to BackendSchema.

mkMultiRowUpdateParser :: forall pgKind r m n. MonadBuildSchema ('Postgres pgKind) r m n => SourceInfo ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> UpdPermInfo ('Postgres pgKind) -> m (InputFieldsParser n (BackendUpdate pgKind (UnpreparedValue ('Postgres pgKind)))) Source #

Create a parser for the updates section of the update_table_many update.

It parses a list with two fields: 'where', and an update expression (setincetc).

columnParser :: (MonadParse n, MonadError QErr m, MonadReader r m, Has MkTypename r, Has NamingCase r) => ColumnType ('Postgres pgKind) -> Nullability -> m (Parser 'Both n (ValueWithOrigin (ColumnValue ('Postgres pgKind)))) Source #

orderByOperators :: NamingCase -> (Name, NonEmpty (Definition EnumValueInfo, (BasicOrderType ('Postgres pgKind), NullsOrderType ('Postgres pgKind)))) Source #

Do NOT use this function directly, this should be used via orderByOperatorsHasuraCase or orderByOperatorsGraphqlCase

comparisonExps :: forall pgKind m n r. (BackendSchema ('Postgres pgKind), MonadMemoize m, MonadParse n, MonadError QErr m, MonadReader r m, Has SchemaOptions r, Has MkTypename r, Has NamingCase r) => ColumnType ('Postgres pgKind) -> m (Parser 'Input n [ComparisonExp ('Postgres pgKind)]) Source #

prependOp :: forall pgKind m n r. (BackendSchema ('Postgres pgKind), MonadReader r m, MonadError QErr m, MonadParse n, Has MkTypename r, Has NamingCase r) => UpdateOperator ('Postgres pgKind) m n (UnpreparedValue ('Postgres pgKind)) Source #

Update operator that prepends a value to a column containing jsonb arrays.

Note: Currently this is Postgres specific because json columns have not been ported to other backends yet.

appendOp :: forall pgKind m n r. (BackendSchema ('Postgres pgKind), MonadReader r m, MonadError QErr m, MonadParse n, Has MkTypename r, Has NamingCase r) => UpdateOperator ('Postgres pgKind) m n (UnpreparedValue ('Postgres pgKind)) Source #

Update operator that appends a value to a column containing jsonb arrays.

Note: Currently this is Postgres specific because json columns have not been ported to other backends yet.

deleteKeyOp :: forall pgKind m n r. (BackendSchema ('Postgres pgKind), MonadReader r m, MonadError QErr m, MonadParse n, Has MkTypename r, Has NamingCase r) => UpdateOperator ('Postgres pgKind) m n (UnpreparedValue ('Postgres pgKind)) Source #

Update operator that deletes a value at a specified key from a column containing jsonb objects.

Note: Currently this is Postgres specific because json columns have not been ported to other backends yet.

deleteElemOp :: forall pgKind m n r. (BackendSchema ('Postgres pgKind), MonadReader r m, MonadError QErr m, MonadParse n, Has MkTypename r, Has NamingCase r) => UpdateOperator ('Postgres pgKind) m n (UnpreparedValue ('Postgres pgKind)) Source #

Update operator that deletes a value at a specific index from a column containing jsonb arrays.

Note: Currently this is Postgres specific because json columns have not been ported to other backends yet.

deleteAtPathOp :: forall pgKind m n r. (BackendSchema ('Postgres pgKind), MonadReader r m, MonadError QErr m, MonadParse n, Has MkTypename r, Has NamingCase r) => UpdateOperator ('Postgres pgKind) m n [UnpreparedValue ('Postgres pgKind)] Source #

Update operator that deletes a field at a certan path from a column containing jsonb objects.

Note: Currently this is Postgres specific because json columns have not been ported to other backends yet.

updateOperators :: forall pgKind m n r. MonadBuildSchema ('Postgres pgKind) r m n => TableInfo ('Postgres pgKind) -> UpdPermInfo ('Postgres pgKind) -> m (InputFieldsParser n (HashMap (Column ('Postgres pgKind)) (UpdateOpExpression (UnpreparedValue ('Postgres pgKind))))) Source #

The update operators that we support on Postgres.

Orphan instances

(PostgresSchema pgKind, Backend ('Postgres pgKind), HasTag ('Postgres pgKind)) => BackendTableSelectSchema ('Postgres pgKind) Source # 
Instance details

Methods

tableArguments :: forall r m (n :: Type -> Type). MonadBuildSchemaBase r m n => SourceInfo ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> m (InputFieldsParser n (SelectArgsG ('Postgres pgKind) (UnpreparedValue ('Postgres pgKind)))) Source #

tableSelectionSet :: forall r m (n :: Type -> Type). MonadBuildSchemaBase r m n => SourceInfo ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> m (Maybe (Parser 'Output n (AnnotatedFields ('Postgres pgKind)))) Source #

selectTable :: forall r m (n :: Type -> Type). MonadBuildSchemaBase r m n => SourceInfo ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> Name -> Maybe Description -> m (Maybe (FieldParser n (SelectExp ('Postgres pgKind)))) Source #

selectTableAggregate :: forall r m (n :: Type -> Type). MonadBuildSchemaBase r m n => SourceInfo ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> Name -> Maybe Description -> m (Maybe (FieldParser n (AggSelectExp ('Postgres pgKind)))) Source #

(Backend ('Postgres pgKind), PostgresSchema pgKind) => BackendSchema ('Postgres pgKind) Source # 
Instance details

Methods

buildTableQueryAndSubscriptionFields :: forall r m (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => MkRootFieldName -> SourceInfo ('Postgres pgKind) -> TableName ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> GQLNameIdentifier -> m ([FieldParser n (QueryDB ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind)))], [FieldParser n (QueryDB ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind)))], Maybe (Name, Parser 'Output n (ApolloFederationParserFunction n))) Source #

buildTableStreamingSubscriptionFields :: forall r m (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => MkRootFieldName -> SourceInfo ('Postgres pgKind) -> TableName ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> GQLNameIdentifier -> m [FieldParser n (QueryDB ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind)))] Source #

buildTableRelayQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => MkRootFieldName -> SourceInfo ('Postgres pgKind) -> TableName ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> GQLNameIdentifier -> NESeq (ColumnInfo ('Postgres pgKind)) -> m [FieldParser n (QueryDB ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind)))] Source #

buildTableInsertMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => MkRootFieldName -> Scenario -> SourceInfo ('Postgres pgKind) -> TableName ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> GQLNameIdentifier -> m [FieldParser n (AnnotatedInsert ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind)))] Source #

buildTableUpdateMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => MkRootFieldName -> Scenario -> SourceInfo ('Postgres pgKind) -> TableName ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> GQLNameIdentifier -> m [FieldParser n (AnnotatedUpdateG ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind)))] Source #

buildTableDeleteMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => MkRootFieldName -> Scenario -> SourceInfo ('Postgres pgKind) -> TableName ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> GQLNameIdentifier -> m [FieldParser n (AnnDelG ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind)))] Source #

buildFunctionQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => MkRootFieldName -> SourceInfo ('Postgres pgKind) -> FunctionName ('Postgres pgKind) -> FunctionInfo ('Postgres pgKind) -> TableName ('Postgres pgKind) -> m [FieldParser n (QueryDB ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind)))] Source #

buildFunctionRelayQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => MkRootFieldName -> SourceInfo ('Postgres pgKind) -> FunctionName ('Postgres pgKind) -> FunctionInfo ('Postgres pgKind) -> TableName ('Postgres pgKind) -> NESeq (ColumnInfo ('Postgres pgKind)) -> m [FieldParser n (QueryDB ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind)))] Source #

buildFunctionMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => MkRootFieldName -> SourceInfo ('Postgres pgKind) -> FunctionName ('Postgres pgKind) -> FunctionInfo ('Postgres pgKind) -> TableName ('Postgres pgKind) -> m [FieldParser n (MutationDB ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind)))] Source #

mkRelationshipParser :: forall r m (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => SourceInfo ('Postgres pgKind) -> RelInfo ('Postgres pgKind) -> m (Maybe (InputFieldsParser n (Maybe (AnnotatedInsertField ('Postgres pgKind) (UnpreparedValue ('Postgres pgKind)))))) Source #

relayExtension :: Maybe (XRelay ('Postgres pgKind)) Source #

nodesAggExtension :: Maybe (XNodesAgg ('Postgres pgKind)) Source #

streamSubscriptionExtension :: Maybe (XStreamingSubscription ('Postgres pgKind)) Source #

columnParser :: forall (n :: Type -> Type) m r. (MonadParse n, MonadError QErr m, MonadReader r m, Has MkTypename r, Has NamingCase r) => ColumnType ('Postgres pgKind) -> Nullability -> m (Parser 'Both n (ValueWithOrigin (ColumnValue ('Postgres pgKind)))) Source #

scalarSelectionArgumentsParser :: forall (n :: Type -> Type). MonadParse n => ColumnType ('Postgres pgKind) -> InputFieldsParser n (Maybe (ScalarSelectionArguments ('Postgres pgKind))) Source #

orderByOperators :: SourceInfo ('Postgres pgKind) -> NamingCase -> (Name, NonEmpty (Definition EnumValueInfo, (BasicOrderType ('Postgres pgKind), NullsOrderType ('Postgres pgKind)))) Source #

comparisonExps :: forall r m (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => ColumnType ('Postgres pgKind) -> m (Parser 'Input n [ComparisonExp ('Postgres pgKind)]) Source #

countTypeInput :: forall (n :: Type -> Type). MonadParse n => Maybe (Parser 'Both n (Column ('Postgres pgKind))) -> InputFieldsParser n (CountDistinct -> CountType ('Postgres pgKind)) Source #

aggregateOrderByCountType :: ScalarType ('Postgres pgKind) Source #

computedField :: forall r m (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => SourceInfo ('Postgres pgKind) -> ComputedFieldInfo ('Postgres pgKind) -> TableName ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> m (Maybe (FieldParser n (AnnotatedField ('Postgres pgKind)))) Source #

AggregationPredicatesSchema ('Postgres pgKind) Source # 
Instance details

Methods

aggregationPredicatesParser :: forall r m (n :: Type -> Type). MonadBuildSchemaBase r m n => SourceInfo ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> m (Maybe (InputFieldsParser n [AggregationPredicates ('Postgres pgKind) (UnpreparedValue ('Postgres pgKind))])) Source #