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.
Minimal complete definition
buildTableQueryAndSubscriptionFields, buildTableStreamingSubscriptionFields, buildTableRelayQueryFields, buildTableInsertMutationFields, buildTableUpdateMutationFields, buildTableDeleteMutationFields, buildFunctionQueryFields, buildFunctionRelayQueryFields, buildFunctionMutationFields, relayExtension, nodesAggExtension, streamSubscriptionExtension, columnParser, scalarSelectionArgumentsParser, orderByOperators, comparisonExps, countTypeInput, aggregateOrderByCountType, computedField
Methods
buildTableQueryAndSubscriptionFields :: MonadBuildSchema b r m n => MkRootFieldName -> SourceInfo b -> TableName b -> TableInfo b -> GQLNameIdentifier -> 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 -> SourceInfo b -> TableName b -> TableInfo b -> GQLNameIdentifier -> m [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #
buildTableRelayQueryFields :: MonadBuildSchema b r m n => MkRootFieldName -> SourceInfo b -> TableName b -> TableInfo b -> GQLNameIdentifier -> NESeq (ColumnInfo b) -> m [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #
buildTableInsertMutationFields :: MonadBuildSchema b r m n => MkRootFieldName -> Scenario -> SourceInfo b -> TableName b -> TableInfo b -> GQLNameIdentifier -> m [FieldParser n (AnnotatedInsert b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #
buildTableUpdateMutationFields Source #
buildTableDeleteMutationFields :: MonadBuildSchema b r m n => MkRootFieldName -> Scenario -> SourceInfo b -> TableName b -> TableInfo b -> GQLNameIdentifier -> m [FieldParser n (AnnDelG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #
buildFunctionQueryFields :: MonadBuildSchema b r m n => MkRootFieldName -> SourceInfo b -> FunctionName b -> FunctionInfo b -> TableName b -> m [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #
buildFunctionRelayQueryFields :: MonadBuildSchema b r m n => MkRootFieldName -> SourceInfo b -> FunctionName b -> FunctionInfo b -> TableName b -> NESeq (ColumnInfo b) -> m [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #
buildFunctionMutationFields :: MonadBuildSchema b r m n => MkRootFieldName -> SourceInfo b -> FunctionName b -> FunctionInfo b -> TableName b -> m [FieldParser n (MutationDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))] Source #
mkRelationshipParser :: MonadBuildSchema b r m n => SourceInfo b -> RelInfo b -> 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 #
columnParser :: (MonadParse n, MonadError QErr m, MonadReader r m, Has MkTypename r, Has NamingCase r) => ColumnType b -> Nullability -> m (Parser 'Both n (ValueWithOrigin (ColumnValue 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 -> m (Parser 'Input n [ComparisonExp b]) Source #
countTypeInput :: MonadParse n => Maybe (Parser 'Both n (Column b)) -> InputFieldsParser n (CountDistinct -> CountType 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 => SourceInfo b -> ComputedFieldInfo b -> TableName b -> TableInfo b -> m (Maybe (FieldParser n (AnnotatedField b))) Source #
Instances
Instances details
BackendSchema 'MSSQL Source # | |
Instance detailsDefined in Hasura.Backends.MSSQL.Instances.Schema Methods buildTableQueryAndSubscriptionFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => MkRootFieldName -> SourceInfo 'MSSQL -> TableName 'MSSQL -> TableInfo 'MSSQL -> GQLNameIdentifier -> 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 (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => MkRootFieldName -> SourceInfo 'MSSQL -> TableName 'MSSQL -> TableInfo 'MSSQL -> GQLNameIdentifier -> m [FieldParser n (QueryDB 'MSSQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MSSQL))] Source # buildTableRelayQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => MkRootFieldName -> SourceInfo 'MSSQL -> TableName 'MSSQL -> TableInfo 'MSSQL -> GQLNameIdentifier -> NESeq (ColumnInfo 'MSSQL) -> m [FieldParser n (QueryDB 'MSSQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MSSQL))] Source # buildTableInsertMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => MkRootFieldName -> Scenario -> SourceInfo 'MSSQL -> TableName 'MSSQL -> TableInfo 'MSSQL -> GQLNameIdentifier -> m [FieldParser n (AnnotatedInsert 'MSSQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MSSQL))] Source # buildTableUpdateMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => MkRootFieldName -> Scenario -> SourceInfo 'MSSQL -> TableName 'MSSQL -> TableInfo 'MSSQL -> GQLNameIdentifier -> m [FieldParser n (AnnotatedUpdateG 'MSSQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MSSQL))] Source # buildTableDeleteMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => MkRootFieldName -> Scenario -> SourceInfo 'MSSQL -> TableName 'MSSQL -> TableInfo 'MSSQL -> GQLNameIdentifier -> m [FieldParser n (AnnDelG 'MSSQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MSSQL))] Source # buildFunctionQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => MkRootFieldName -> SourceInfo 'MSSQL -> FunctionName 'MSSQL -> FunctionInfo 'MSSQL -> TableName 'MSSQL -> m [FieldParser n (QueryDB 'MSSQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MSSQL))] Source # buildFunctionRelayQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => MkRootFieldName -> SourceInfo 'MSSQL -> FunctionName 'MSSQL -> FunctionInfo 'MSSQL -> TableName 'MSSQL -> NESeq (ColumnInfo 'MSSQL) -> m [FieldParser n (QueryDB 'MSSQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MSSQL))] Source # buildFunctionMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => MkRootFieldName -> SourceInfo 'MSSQL -> FunctionName 'MSSQL -> FunctionInfo 'MSSQL -> TableName 'MSSQL -> m [FieldParser n (MutationDB 'MSSQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MSSQL))] Source # mkRelationshipParser :: forall r m (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => SourceInfo 'MSSQL -> RelInfo 'MSSQL -> 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 # columnParser :: forall (n :: Type -> Type) m r. (MonadParse n, MonadError QErr m, MonadReader r m, Has MkTypename r, Has NamingCase r) => ColumnType 'MSSQL -> Nullability -> m (Parser 'Both n (ValueWithOrigin (ColumnValue '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 (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => ColumnType 'MSSQL -> m (Parser 'Input n [ComparisonExp 'MSSQL]) Source # countTypeInput :: forall (n :: Type -> Type). MonadParse n => Maybe (Parser 'Both n (Column 'MSSQL)) -> InputFieldsParser n (CountDistinct -> CountType 'MSSQL) Source # aggregateOrderByCountType :: ScalarType 'MSSQL Source # computedField :: forall r m (n :: Type -> Type). MonadBuildSchema 'MSSQL r m n => SourceInfo 'MSSQL -> ComputedFieldInfo 'MSSQL -> TableName 'MSSQL -> TableInfo 'MSSQL -> m (Maybe (FieldParser n (AnnotatedField 'MSSQL))) Source # |
BackendSchema 'BigQuery Source # | |
Instance detailsDefined in Hasura.Backends.BigQuery.Instances.Schema Methods buildTableQueryAndSubscriptionFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => MkRootFieldName -> SourceInfo 'BigQuery -> TableName 'BigQuery -> TableInfo 'BigQuery -> GQLNameIdentifier -> 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 (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => MkRootFieldName -> SourceInfo 'BigQuery -> TableName 'BigQuery -> TableInfo 'BigQuery -> GQLNameIdentifier -> m [FieldParser n (QueryDB 'BigQuery (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'BigQuery))] Source # buildTableRelayQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => MkRootFieldName -> SourceInfo 'BigQuery -> TableName 'BigQuery -> TableInfo 'BigQuery -> GQLNameIdentifier -> NESeq (ColumnInfo 'BigQuery) -> m [FieldParser n (QueryDB 'BigQuery (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'BigQuery))] Source # buildTableInsertMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => MkRootFieldName -> Scenario -> SourceInfo 'BigQuery -> TableName 'BigQuery -> TableInfo 'BigQuery -> GQLNameIdentifier -> m [FieldParser n (AnnotatedInsert 'BigQuery (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'BigQuery))] Source # buildTableUpdateMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => MkRootFieldName -> Scenario -> SourceInfo 'BigQuery -> TableName 'BigQuery -> TableInfo 'BigQuery -> GQLNameIdentifier -> m [FieldParser n (AnnotatedUpdateG 'BigQuery (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'BigQuery))] Source # buildTableDeleteMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => MkRootFieldName -> Scenario -> SourceInfo 'BigQuery -> TableName 'BigQuery -> TableInfo 'BigQuery -> GQLNameIdentifier -> m [FieldParser n (AnnDelG 'BigQuery (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'BigQuery))] Source # buildFunctionQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => MkRootFieldName -> SourceInfo 'BigQuery -> FunctionName 'BigQuery -> FunctionInfo 'BigQuery -> TableName 'BigQuery -> m [FieldParser n (QueryDB 'BigQuery (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'BigQuery))] Source # buildFunctionRelayQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => MkRootFieldName -> SourceInfo 'BigQuery -> FunctionName 'BigQuery -> FunctionInfo 'BigQuery -> TableName 'BigQuery -> NESeq (ColumnInfo 'BigQuery) -> m [FieldParser n (QueryDB 'BigQuery (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'BigQuery))] Source # buildFunctionMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => MkRootFieldName -> SourceInfo 'BigQuery -> FunctionName 'BigQuery -> FunctionInfo 'BigQuery -> TableName 'BigQuery -> m [FieldParser n (MutationDB 'BigQuery (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'BigQuery))] Source # mkRelationshipParser :: forall r m (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => SourceInfo 'BigQuery -> RelInfo 'BigQuery -> 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 # columnParser :: forall (n :: Type -> Type) m r. (MonadParse n, MonadError QErr m, MonadReader r m, Has MkTypename r, Has NamingCase r) => ColumnType 'BigQuery -> Nullability -> m (Parser 'Both n (ValueWithOrigin (ColumnValue '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 (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => ColumnType 'BigQuery -> m (Parser 'Input n [ComparisonExp 'BigQuery]) Source # countTypeInput :: forall (n :: Type -> Type). MonadParse n => Maybe (Parser 'Both n (Column 'BigQuery)) -> InputFieldsParser n (CountDistinct -> CountType 'BigQuery) Source # aggregateOrderByCountType :: ScalarType 'BigQuery Source # computedField :: forall r m (n :: Type -> Type). MonadBuildSchema 'BigQuery r m n => SourceInfo 'BigQuery -> ComputedFieldInfo 'BigQuery -> TableName 'BigQuery -> TableInfo 'BigQuery -> m (Maybe (FieldParser n (AnnotatedField 'BigQuery))) Source # |
BackendSchema 'MySQL Source # | |
Instance detailsDefined in Hasura.Backends.MySQL.Instances.Schema Methods buildTableQueryAndSubscriptionFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MySQL r m n => MkRootFieldName -> SourceInfo 'MySQL -> TableName 'MySQL -> TableInfo 'MySQL -> GQLNameIdentifier -> m ([FieldParser n (QueryDB 'MySQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MySQL))], [FieldParser n (QueryDB 'MySQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MySQL))], Maybe (Name, Parser 'Output n (ApolloFederationParserFunction n))) Source # buildTableStreamingSubscriptionFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MySQL r m n => MkRootFieldName -> SourceInfo 'MySQL -> TableName 'MySQL -> TableInfo 'MySQL -> GQLNameIdentifier -> m [FieldParser n (QueryDB 'MySQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MySQL))] Source # buildTableRelayQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MySQL r m n => MkRootFieldName -> SourceInfo 'MySQL -> TableName 'MySQL -> TableInfo 'MySQL -> GQLNameIdentifier -> NESeq (ColumnInfo 'MySQL) -> m [FieldParser n (QueryDB 'MySQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MySQL))] Source # buildTableInsertMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MySQL r m n => MkRootFieldName -> Scenario -> SourceInfo 'MySQL -> TableName 'MySQL -> TableInfo 'MySQL -> GQLNameIdentifier -> m [FieldParser n (AnnotatedInsert 'MySQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MySQL))] Source # buildTableUpdateMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MySQL r m n => MkRootFieldName -> Scenario -> SourceInfo 'MySQL -> TableName 'MySQL -> TableInfo 'MySQL -> GQLNameIdentifier -> m [FieldParser n (AnnotatedUpdateG 'MySQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MySQL))] Source # buildTableDeleteMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MySQL r m n => MkRootFieldName -> Scenario -> SourceInfo 'MySQL -> TableName 'MySQL -> TableInfo 'MySQL -> GQLNameIdentifier -> m [FieldParser n (AnnDelG 'MySQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MySQL))] Source # buildFunctionQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MySQL r m n => MkRootFieldName -> SourceInfo 'MySQL -> FunctionName 'MySQL -> FunctionInfo 'MySQL -> TableName 'MySQL -> m [FieldParser n (QueryDB 'MySQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MySQL))] Source # buildFunctionRelayQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MySQL r m n => MkRootFieldName -> SourceInfo 'MySQL -> FunctionName 'MySQL -> FunctionInfo 'MySQL -> TableName 'MySQL -> NESeq (ColumnInfo 'MySQL) -> m [FieldParser n (QueryDB 'MySQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MySQL))] Source # buildFunctionMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'MySQL r m n => MkRootFieldName -> SourceInfo 'MySQL -> FunctionName 'MySQL -> FunctionInfo 'MySQL -> TableName 'MySQL -> m [FieldParser n (MutationDB 'MySQL (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'MySQL))] Source # mkRelationshipParser :: forall r m (n :: Type -> Type). MonadBuildSchema 'MySQL r m n => SourceInfo 'MySQL -> RelInfo 'MySQL -> m (Maybe (InputFieldsParser n (Maybe (AnnotatedInsertField 'MySQL (UnpreparedValue 'MySQL))))) Source # relayExtension :: Maybe (XRelay 'MySQL) Source # nodesAggExtension :: Maybe (XNodesAgg 'MySQL) Source # streamSubscriptionExtension :: Maybe (XStreamingSubscription 'MySQL) Source # columnParser :: forall (n :: Type -> Type) m r. (MonadParse n, MonadError QErr m, MonadReader r m, Has MkTypename r, Has NamingCase r) => ColumnType 'MySQL -> Nullability -> m (Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))) Source # scalarSelectionArgumentsParser :: forall (n :: Type -> Type). MonadParse n => ColumnType 'MySQL -> InputFieldsParser n (Maybe (ScalarSelectionArguments 'MySQL)) Source # orderByOperators :: SourceInfo 'MySQL -> NamingCase -> (Name, NonEmpty (Definition EnumValueInfo, (BasicOrderType 'MySQL, NullsOrderType 'MySQL))) Source # comparisonExps :: forall r m (n :: Type -> Type). MonadBuildSchema 'MySQL r m n => ColumnType 'MySQL -> m (Parser 'Input n [ComparisonExp 'MySQL]) Source # countTypeInput :: forall (n :: Type -> Type). MonadParse n => Maybe (Parser 'Both n (Column 'MySQL)) -> InputFieldsParser n (CountDistinct -> CountType 'MySQL) Source # aggregateOrderByCountType :: ScalarType 'MySQL Source # computedField :: forall r m (n :: Type -> Type). MonadBuildSchema 'MySQL r m n => SourceInfo 'MySQL -> ComputedFieldInfo 'MySQL -> TableName 'MySQL -> TableInfo 'MySQL -> m (Maybe (FieldParser n (AnnotatedField 'MySQL))) Source # |
BackendSchema 'DataConnector Source # | |
Instance detailsDefined in Hasura.Backends.DataConnector.Adapter.Schema Methods buildTableQueryAndSubscriptionFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => MkRootFieldName -> SourceInfo 'DataConnector -> TableName 'DataConnector -> TableInfo 'DataConnector -> GQLNameIdentifier -> 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 (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => MkRootFieldName -> SourceInfo 'DataConnector -> TableName 'DataConnector -> TableInfo 'DataConnector -> GQLNameIdentifier -> m [FieldParser n (QueryDB 'DataConnector (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'DataConnector))] Source # buildTableRelayQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => MkRootFieldName -> SourceInfo 'DataConnector -> TableName 'DataConnector -> TableInfo 'DataConnector -> GQLNameIdentifier -> NESeq (ColumnInfo 'DataConnector) -> m [FieldParser n (QueryDB 'DataConnector (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'DataConnector))] Source # buildTableInsertMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => MkRootFieldName -> Scenario -> SourceInfo 'DataConnector -> TableName 'DataConnector -> TableInfo 'DataConnector -> GQLNameIdentifier -> m [FieldParser n (AnnotatedInsert 'DataConnector (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'DataConnector))] Source # buildTableUpdateMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => MkRootFieldName -> Scenario -> SourceInfo 'DataConnector -> TableName 'DataConnector -> TableInfo 'DataConnector -> GQLNameIdentifier -> m [FieldParser n (AnnotatedUpdateG 'DataConnector (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'DataConnector))] Source # buildTableDeleteMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => MkRootFieldName -> Scenario -> SourceInfo 'DataConnector -> TableName 'DataConnector -> TableInfo 'DataConnector -> GQLNameIdentifier -> m [FieldParser n (AnnDelG 'DataConnector (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'DataConnector))] Source # buildFunctionQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => MkRootFieldName -> SourceInfo 'DataConnector -> FunctionName 'DataConnector -> FunctionInfo 'DataConnector -> TableName 'DataConnector -> m [FieldParser n (QueryDB 'DataConnector (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'DataConnector))] Source # buildFunctionRelayQueryFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => MkRootFieldName -> SourceInfo 'DataConnector -> FunctionName 'DataConnector -> FunctionInfo 'DataConnector -> TableName 'DataConnector -> NESeq (ColumnInfo 'DataConnector) -> m [FieldParser n (QueryDB 'DataConnector (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'DataConnector))] Source # buildFunctionMutationFields :: forall r m (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => MkRootFieldName -> SourceInfo 'DataConnector -> FunctionName 'DataConnector -> FunctionInfo 'DataConnector -> TableName 'DataConnector -> m [FieldParser n (MutationDB 'DataConnector (RemoteRelationshipField UnpreparedValue) (UnpreparedValue 'DataConnector))] Source # mkRelationshipParser :: forall r m (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => SourceInfo 'DataConnector -> RelInfo 'DataConnector -> 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 # columnParser :: forall (n :: Type -> Type) m r. (MonadParse n, MonadError QErr m, MonadReader r m, Has MkTypename r, Has NamingCase r) => ColumnType 'DataConnector -> Nullability -> m (Parser 'Both n (ValueWithOrigin (ColumnValue '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 (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => ColumnType 'DataConnector -> m (Parser 'Input n [ComparisonExp 'DataConnector]) Source # countTypeInput :: forall (n :: Type -> Type). MonadParse n => Maybe (Parser 'Both n (Column 'DataConnector)) -> InputFieldsParser n (CountDistinct -> CountType 'DataConnector) Source # aggregateOrderByCountType :: ScalarType 'DataConnector Source # computedField :: forall r m (n :: Type -> Type). MonadBuildSchema 'DataConnector r m n => SourceInfo 'DataConnector -> ComputedFieldInfo 'DataConnector -> TableName 'DataConnector -> TableInfo 'DataConnector -> m (Maybe (FieldParser n (AnnotatedField 'DataConnector))) Source # |
(Backend ('Postgres pgKind), PostgresSchema pgKind) => BackendSchema ('Postgres pgKind) Source # | |
Instance detailsDefined in Hasura.Backends.Postgres.Instances.Schema 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 # |
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.