graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hasura.GraphQL.Schema.Backend

Description

This module defines the type class BackendSchema and auxiliary types.

BackendSchema represents the part of the interface that a backend driver presents to the GraphQL Engine core that is responsible for generating the backend's Schema Parsers.

The Schema Parsers recognise (and reflect) the schema that a backend exposes.

The BackendSchema methods are used by buildGQLContext, which is the core's entrypoint to schema generation.

Many of the BackendSchema methods will have default implementations that a backend driver may use. These may be found (chiefly) in the modules:

For more information see:

Synopsis

Documentation

type MonadBuildSchema b r m n = (BackendSchema b, MonadBuildSourceSchema b r m n) Source #

Bag of constraints available to the methods of BackendSchema.

Note that BackendSchema b is itself part of this, so a methods may also call other methods. This might seem trivial, but it can be easy to miss when the functions used to implement a class instance are defined in multiple modules.

class Backend b => BackendSchema (b :: BackendType) where Source #

This type class is responsible for generating the schema of a backend. Its methods are called by the common core that orchestrates the various backend drivers.

Its purpose in life is to make it convenient to express the GraphQL schema we want to expose for the backends that we support. This means balancing the desire to have consistency with the desire to differentiate the schema of a backend.

This means that it is expected to evolve over time as we add new backends, and that you have the license to change it: Whatever form it currently takes only reflects status quo current implementation.

The module Hasura.GraphQL.Schema.Build (commonly qualified as GSB) provides standard building blocks for implementing many methods of this class. And as such, these two modules are very much expected to evolve in tandem.

See Note BackendSchema modelling principles.

Methods

buildTableQueryAndSubscriptionFields :: MonadBuildSchema b r m n => MkRootFieldName -> TableName b -> TableInfo b -> GQLNameIdentifier -> SchemaT r m ([FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))], [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))], Maybe (Name, Parser 'Output n (ApolloFederationParserFunction n))) Source #

buildTableStreamingSubscriptionFields :: MonadBuildSchema b r m n => MkRootFieldName -> TableName b -> TableInfo b -> GQLNameIdentifier -> SchemaT r m [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #

buildTableRelayQueryFields :: MonadBuildSchema b r m n => MkRootFieldName -> TableName b -> TableInfo b -> GQLNameIdentifier -> NESeq (ColumnInfo b) -> SchemaT r m [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #

buildTableInsertMutationFields :: MonadBuildSchema b r m n => MkRootFieldName -> Scenario -> TableName b -> TableInfo b -> GQLNameIdentifier -> SchemaT r m [FieldParser n (AnnotatedInsert b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #

buildTableUpdateMutationFields Source #

This method is responsible for building the GraphQL Schema for mutations backed by UPDATE statements on some table, as described in https://hasura.io/docs/latest/graphql/core/databases/postgres/mutations/update.html.

The suggested way to implement this is using building blocks in GSB, c.f. its namesake GSB.buildTableUpdateMutationFields.

buildTableDeleteMutationFields :: MonadBuildSchema b r m n => MkRootFieldName -> Scenario -> TableName b -> TableInfo b -> GQLNameIdentifier -> SchemaT r m [FieldParser n (AnnDelG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #

buildFunctionQueryFields :: MonadBuildSchema b r m n => MkRootFieldName -> FunctionName b -> FunctionInfo b -> TableName b -> SchemaT r m [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #

buildFunctionRelayQueryFields :: MonadBuildSchema b r m n => MkRootFieldName -> FunctionName b -> FunctionInfo b -> TableName b -> NESeq (ColumnInfo b) -> SchemaT r m [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #

buildFunctionMutationFields :: MonadBuildSchema b r m n => MkRootFieldName -> FunctionName b -> FunctionInfo b -> TableName b -> SchemaT r m [FieldParser n (MutationDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #

buildNativeQueryRootFields :: MonadBuildSchema b r m n => NativeQueryInfo b -> SchemaT r m (Maybe (FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)))) Source #

buildStoredProcedureRootFields :: MonadBuildSchema b r m n => StoredProcedureInfo b -> SchemaT r m (Maybe (FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)))) Source #

mkRelationshipParser :: MonadBuildSchema b r m n => RelInfo b -> SchemaT r m (Maybe (InputFieldsParser n (Maybe (AnnotatedInsertField b (UnpreparedValue b))))) Source #

Make a parser for relationships. Default implementaton elides relationships altogether.

relayExtension :: Maybe (XRelay b) Source #

nodesAggExtension :: Maybe (XNodesAgg b) Source #

streamSubscriptionExtension :: Maybe (XStreamingSubscription b) Source #

groupByExtension :: Maybe (XGroupBy b) Source #

columnParser :: MonadBuildSchema b r m n => ColumnType b -> Nullability -> SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue b))) Source #

enumParser :: MonadBuildSchema b r m n => TableName b -> NonEmpty (EnumValue, EnumValueInfo) -> Maybe Name -> Nullability -> SchemaT r m (Parser 'Both n (ScalarValue b)) Source #

possiblyNullable :: MonadParse m => ScalarType b -> Nullability -> Parser 'Both m (ScalarValue b) -> Parser 'Both m (ScalarValue b) Source #

scalarSelectionArgumentsParser :: MonadParse n => ColumnType b -> InputFieldsParser n (Maybe (ScalarSelectionArguments b)) Source #

Parser for arguments on scalar fields in a selection set

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

comparisonExps :: MonadBuildSchema b r m n => ColumnType b -> SchemaT r m (Parser 'Input n [ComparisonExp b]) Source #

countTypeInput :: MonadParse n => Maybe (Parser 'Both n (Column b, AnnRedactionExpUnpreparedValue b)) -> InputFieldsParser n (CountDistinct -> CountType b (UnpreparedValue b)) Source #

The input fields parser, for "count" aggregate field, yielding a function which generates @'CountType b' from optional "distinct" field value

aggregateOrderByCountType :: ScalarType b Source #

computedField :: MonadBuildSchema b r m n => ComputedFieldInfo b -> TableName b -> TableInfo b -> SchemaT r m (Maybe (FieldParser n (AnnotatedField b))) Source #

Computed field parser

Instances

Instances details
BackendSchema 'BigQuery Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Instances.Schema

Methods

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

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

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

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

buildTableUpdateMutationFields :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => Scenario -> TableInfo 'BigQuery -> GQLNameIdentifier -> SchemaT r m [FieldParser n (AnnotatedUpdateG 'BigQuery (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'BigQuery))] Source #

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

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

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

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

buildNativeQueryRootFields :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => NativeQueryInfo 'BigQuery -> SchemaT r m (Maybe (FieldParser n (QueryDB 'BigQuery (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'BigQuery)))) Source #

buildStoredProcedureRootFields :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => StoredProcedureInfo 'BigQuery -> SchemaT r m (Maybe (FieldParser n (QueryDB 'BigQuery (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'BigQuery)))) Source #

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

relayExtension :: Maybe (XRelay 'BigQuery) Source #

nodesAggExtension :: Maybe (XNodesAgg 'BigQuery) Source #

streamSubscriptionExtension :: Maybe (XStreamingSubscription 'BigQuery) Source #

groupByExtension :: Maybe (XGroupBy 'BigQuery) Source #

columnParser :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => ColumnType 'BigQuery -> Nullability -> SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'BigQuery))) Source #

enumParser :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => TableName 'BigQuery -> NonEmpty (EnumValue, EnumValueInfo) -> Maybe Name -> Nullability -> SchemaT r m (Parser 'Both n (ScalarValue 'BigQuery)) Source #

possiblyNullable :: forall (m :: Type -> Type). MonadParse m => ScalarType 'BigQuery -> Nullability -> Parser 'Both m (ScalarValue 'BigQuery) -> Parser 'Both m (ScalarValue 'BigQuery) Source #

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

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

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

countTypeInput :: forall (n :: Type -> Type). MonadParse n => Maybe (Parser 'Both n (Column 'BigQuery, AnnRedactionExpUnpreparedValue 'BigQuery)) -> InputFieldsParser n (CountDistinct -> CountType 'BigQuery (UnpreparedValue 'BigQuery)) Source #

aggregateOrderByCountType :: ScalarType 'BigQuery Source #

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

BackendSchema 'DataConnector Source # 
Instance details

Defined in Hasura.Backends.DataConnector.Adapter.Schema

Methods

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

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

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

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

buildTableUpdateMutationFields :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => Scenario -> TableInfo 'DataConnector -> GQLNameIdentifier -> SchemaT r m [FieldParser n (AnnotatedUpdateG 'DataConnector (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'DataConnector))] Source #

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

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

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

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

buildNativeQueryRootFields :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => NativeQueryInfo 'DataConnector -> SchemaT r m (Maybe (FieldParser n (QueryDB 'DataConnector (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'DataConnector)))) Source #

buildStoredProcedureRootFields :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => StoredProcedureInfo 'DataConnector -> SchemaT r m (Maybe (FieldParser n (QueryDB 'DataConnector (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'DataConnector)))) Source #

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

relayExtension :: Maybe (XRelay 'DataConnector) Source #

nodesAggExtension :: Maybe (XNodesAgg 'DataConnector) Source #

streamSubscriptionExtension :: Maybe (XStreamingSubscription 'DataConnector) Source #

groupByExtension :: Maybe (XGroupBy 'DataConnector) Source #

columnParser :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => ColumnType 'DataConnector -> Nullability -> SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'DataConnector))) Source #

enumParser :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => TableName 'DataConnector -> NonEmpty (EnumValue, EnumValueInfo) -> Maybe Name -> Nullability -> SchemaT r m (Parser 'Both n (ScalarValue 'DataConnector)) Source #

possiblyNullable :: forall (m :: Type -> Type). MonadParse m => ScalarType 'DataConnector -> Nullability -> Parser 'Both m (ScalarValue 'DataConnector) -> Parser 'Both m (ScalarValue 'DataConnector) Source #

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

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

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

countTypeInput :: forall (n :: Type -> Type). MonadParse n => Maybe (Parser 'Both n (Column 'DataConnector, AnnRedactionExpUnpreparedValue 'DataConnector)) -> InputFieldsParser n (CountDistinct -> CountType 'DataConnector (UnpreparedValue 'DataConnector)) Source #

aggregateOrderByCountType :: ScalarType 'DataConnector Source #

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

BackendSchema 'MSSQL Source # 
Instance details

Defined in Hasura.Backends.MSSQL.Instances.Schema

Methods

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

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

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

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

buildTableUpdateMutationFields :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => Scenario -> TableInfo 'MSSQL -> GQLNameIdentifier -> SchemaT r m [FieldParser n (AnnotatedUpdateG 'MSSQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MSSQL))] Source #

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

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

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

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

buildNativeQueryRootFields :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => NativeQueryInfo 'MSSQL -> SchemaT r m (Maybe (FieldParser n (QueryDB 'MSSQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MSSQL)))) Source #

buildStoredProcedureRootFields :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => StoredProcedureInfo 'MSSQL -> SchemaT r m (Maybe (FieldParser n (QueryDB 'MSSQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MSSQL)))) Source #

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

relayExtension :: Maybe (XRelay 'MSSQL) Source #

nodesAggExtension :: Maybe (XNodesAgg 'MSSQL) Source #

streamSubscriptionExtension :: Maybe (XStreamingSubscription 'MSSQL) Source #

groupByExtension :: Maybe (XGroupBy 'MSSQL) Source #

columnParser :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => ColumnType 'MSSQL -> Nullability -> SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'MSSQL))) Source #

enumParser :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => TableName 'MSSQL -> NonEmpty (EnumValue, EnumValueInfo) -> Maybe Name -> Nullability -> SchemaT r m (Parser 'Both n (ScalarValue 'MSSQL)) Source #

possiblyNullable :: forall (m :: Type -> Type). MonadParse m => ScalarType 'MSSQL -> Nullability -> Parser 'Both m (ScalarValue 'MSSQL) -> Parser 'Both m (ScalarValue 'MSSQL) Source #

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

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

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

countTypeInput :: forall (n :: Type -> Type). MonadParse n => Maybe (Parser 'Both n (Column 'MSSQL, AnnRedactionExpUnpreparedValue 'MSSQL)) -> InputFieldsParser n (CountDistinct -> CountType 'MSSQL (UnpreparedValue 'MSSQL)) Source #

aggregateOrderByCountType :: ScalarType 'MSSQL Source #

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

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

Defined in Hasura.Backends.Postgres.Instances.Schema

Methods

buildTableQueryAndSubscriptionFields :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => MkRootFieldName -> TableName ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> GQLNameIdentifier -> SchemaT r 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 :: Type -> Type) (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => MkRootFieldName -> TableName ('Postgres pgKind) -> TableInfo ('Postgres pgKind) -> GQLNameIdentifier -> SchemaT r m [FieldParser n (QueryDB ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind)))] Source #

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

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

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

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

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

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

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

buildNativeQueryRootFields :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => NativeQueryInfo ('Postgres pgKind) -> SchemaT r m (Maybe (FieldParser n (QueryDB ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind))))) Source #

buildStoredProcedureRootFields :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => StoredProcedureInfo ('Postgres pgKind) -> SchemaT r m (Maybe (FieldParser n (QueryDB ('Postgres pgKind) (RemoteRelationshipField UnpreparedValue) (UnpreparedValue ('Postgres pgKind))))) Source #

mkRelationshipParser :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => RelInfo ('Postgres pgKind) -> SchemaT r 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 #

groupByExtension :: Maybe (XGroupBy ('Postgres pgKind)) Source #

columnParser :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => ColumnType ('Postgres pgKind) -> Nullability -> SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue ('Postgres pgKind)))) Source #

enumParser :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => TableName ('Postgres pgKind) -> NonEmpty (EnumValue, EnumValueInfo) -> Maybe Name -> Nullability -> SchemaT r m (Parser 'Both n (ScalarValue ('Postgres pgKind))) Source #

possiblyNullable :: forall (m :: Type -> Type). MonadParse m => ScalarType ('Postgres pgKind) -> Nullability -> Parser 'Both m (ScalarValue ('Postgres pgKind)) -> Parser 'Both m (ScalarValue ('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 :: Type -> Type) (n :: Type -> Type). MonadBuildSchema ('Postgres pgKind) r m n => ColumnType ('Postgres pgKind) -> SchemaT r m (Parser 'Input n [ComparisonExp ('Postgres pgKind)]) Source #

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

aggregateOrderByCountType :: ScalarType ('Postgres pgKind) Source #

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

class Backend b => BackendTableSelectSchema (b :: BackendType) where Source #

The public interface for the schema of table queries exposed by a backend.

Remote Schemas and the Relay schema are the chief backend-agnostic clients of this typeclass.

Some of schema building components in the Hasura.GraphQL.Schema namespace also make use of these methods, ensuring backends expose a consistent schema regardless of the mode it's referenced.

Default implementations exist for all of these in Select.

Methods

tableArguments :: MonadBuildSourceSchema b r m n => TableInfo b -> SchemaT r m (InputFieldsParser n (SelectArgsG b (UnpreparedValue b))) Source #

tableSelectionSet :: MonadBuildSourceSchema b r m n => TableInfo b -> SchemaT r m (Maybe (Parser 'Output n (AnnotatedFields b))) Source #

selectTable Source #

Arguments

:: MonadBuildSourceSchema b r m n 
=> TableInfo b

table info

-> Name

field display name

-> Maybe Description

field description, if any

-> SchemaT r m (Maybe (FieldParser n (SelectExp b))) 

selectTableAggregate Source #

Arguments

:: MonadBuildSourceSchema b r m n 
=> TableInfo b

table info

-> Name

field display name

-> Maybe Description

field description, if any

-> SchemaT r m (Maybe (FieldParser n (AggSelectExp b))) 

Instances

Instances details
BackendTableSelectSchema 'BigQuery Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Instances.Schema

BackendTableSelectSchema 'DataConnector Source # 
Instance details

Defined in Hasura.Backends.DataConnector.Adapter.Schema

BackendTableSelectSchema 'MSSQL Source # 
Instance details

Defined in Hasura.Backends.MSSQL.Instances.Schema

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

Defined in Hasura.Backends.Postgres.Instances.Schema

Methods

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

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

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

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

class Backend b => BackendLogicalModelSelectSchema (b :: BackendType) where Source #

Instances

Instances details
BackendLogicalModelSelectSchema 'BigQuery Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Instances.Schema

BackendLogicalModelSelectSchema 'MSSQL Source # 
Instance details

Defined in Hasura.Backends.MSSQL.Instances.Schema

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

Defined in Hasura.Backends.Postgres.Instances.Schema

Methods

logicalModelArguments :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSourceSchema ('Postgres pgKind) r m n => LogicalModelInfo ('Postgres pgKind) -> SchemaT r m (InputFieldsParser n (SelectArgsG ('Postgres pgKind) (UnpreparedValue ('Postgres pgKind)))) Source #

logicalModelSelectionSet :: forall r (m :: Type -> Type) (n :: Type -> Type). MonadBuildSourceSchema ('Postgres pgKind) r m n => LogicalModelInfo ('Postgres pgKind) -> SchemaT r m (Maybe (Parser 'Output n (AnnotatedFields ('Postgres pgKind)))) Source #

class BackendLogicalModelSelectSchema b => BackendNativeQuerySelectSchema (b :: BackendType) where Source #

Minimal complete definition

Nothing

Instances

Instances details
BackendNativeQuerySelectSchema 'BigQuery Source # 
Instance details

Defined in Hasura.Backends.BigQuery.Instances.Schema

BackendNativeQuerySelectSchema 'MSSQL Source # 
Instance details

Defined in Hasura.Backends.MSSQL.Instances.Schema

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

Defined in Hasura.Backends.Postgres.Instances.Schema

class Backend b => BackendUpdateOperatorsSchema (b :: BackendType) where Source #

Associated Types

type UpdateOperators b :: Type -> Type Source #

Intermediate Representation of the set of update operators that act upon table fields during an update mutation. (For example, _set and _inc)

It is parameterised over the type of fields, which changes during the IR translation phases.

Instances

Instances details
BackendUpdateOperatorsSchema 'DataConnector Source # 
Instance details

Defined in Hasura.Backends.DataConnector.Adapter.Schema

Associated Types

type UpdateOperators 'DataConnector :: Type -> Type Source #

BackendUpdateOperatorsSchema 'MSSQL Source # 
Instance details

Defined in Hasura.Backends.MSSQL.Instances.Schema

Associated Types

type UpdateOperators 'MSSQL :: Type -> Type Source #

Backend ('Postgres pgKind) => BackendUpdateOperatorsSchema ('Postgres pgKind) Source # 
Instance details

Defined in Hasura.Backends.Postgres.Instances.Schema

Associated Types

type UpdateOperators ('Postgres pgKind) :: Type -> Type Source #

Methods

parseUpdateOperators :: forall (m :: Type -> Type) (n :: Type -> Type) r. MonadBuildSchema ('Postgres pgKind) r m n => TableInfo ('Postgres pgKind) -> UpdPermInfo ('Postgres pgKind) -> SchemaT r m (InputFieldsParser n (HashMap (Column ('Postgres pgKind)) (UpdateOperators ('Postgres pgKind) (UnpreparedValue ('Postgres pgKind))))) Source #

In its current form, we model every component, from the top level (query, insert mutation, etc.) of the schema down to its leaf values, as a type class method of BackendSchema.

Consider, for example, the following query for a given table "author":

query {
  author(where: {id: {_eq: 2}}) {
    name
  }
}

The chain of functions leading to a parser for this RootField will be along the lines of:

> BackendSchema.buildTableQueryAndSubscriptionFields     (Suggested default its GSB namesake)
  > GSS.selectTable
    > BackendSchema.tableArguments        (Suggested default implementation being
                                           GSS.defaultTableArgs)
      > GSS.tableWhereArg
        > GSBE.boolExp
          > BackendSchema.comparisonExps
            > BackendSchema.columnParser

    > tableSelectionSet     (...)
      > fieldSelection

(where the abbreviation GSB refers to Hasura.GraphQL.Schema.Build and GSS refers to Hasura.GraphQL.Schema.Select, and GSBE refers to Hasura.GraphQL.Schema.BoolExp.)

Several of those steps are part of the class, meaning that a backend can customize part of this tree without having to reimplement all of it. For instance, a backend that supports a different set ot table arguments can choose to reimplement tableArguments, but can still use tableWhereArg in its custom implementation.

Applying the above modelling guidelines has pros and cons:

  • Pro: You can specify both shared and diverging behavior.
  • Pro: You can specify a lot of behavior implicitly, i.e. it's easy to write.
  • Con: You can specify a lot of behavior implicitly, i.e. it's hard to understand without tracing through implementations.
  • Con: You get a proliferation of type class methods and it's difficult to understand how they fit together.

Going forward, we want to follow some different modelling guidelines:

We should break up / refactor the building blocks (in Hasura.GraphQL.Schema.Build etc.) which are used to implement the top-level type class methods (e.g. BackendSchema.buildTableQueryAndSubscriptionFields, c.f. GSB.buildTableQueryAndSubscriptionFields, etc.) and have them invoke the backend-specific behaviors they rely on via function arguments instead of other type class methods.

When we do this, the function call sites (which will often be in instance BackendSchema ...) become the centralised places where we decide which behavior variation to follow.

When faced with answering the question of "what does this method do, and how does it do it?", at least you will have listed the other components it depends on front and center without having to trace through its implementation.

That is of course, if we refactor our building blocks mindfully into conceptually meaningful units. Otherwise we'll just end up with an incomprehensible mass of poorly shaped pieces. And we will still have a hard time explaining what they do.

In other words, It is still the case that if you don't clean your room you'll be living in a mess.