diff --git a/server/src-lib/Hasura/Backends/BigQuery/Instances/Schema.hs b/server/src-lib/Hasura/Backends/BigQuery/Instances/Schema.hs index cd8ddebf364..e566b864d9d 100644 --- a/server/src-lib/Hasura/Backends/BigQuery/Instances/Schema.hs +++ b/server/src-lib/Hasura/Backends/BigQuery/Instances/Schema.hs @@ -44,7 +44,6 @@ import Hasura.RQL.Types.Common import Hasura.RQL.Types.ComputedField import Hasura.RQL.Types.Function import Hasura.RQL.Types.Source (SourceInfo) -import Hasura.RQL.Types.SourceCustomization (MkRootFieldName) import Hasura.RQL.Types.Table import Hasura.SQL.Backend import Language.GraphQL.Draft.Syntax qualified as G @@ -55,14 +54,14 @@ import Language.GraphQL.Draft.Syntax qualified as G instance BackendSchema 'BigQuery where -- top level parsers buildTableQueryAndSubscriptionFields = GSB.buildTableQueryAndSubscriptionFields - buildTableRelayQueryFields = bqBuildTableRelayQueryFields + buildTableRelayQueryFields _ _ _ _ _ _ = pure [] buildTableStreamingSubscriptionFields = GSB.buildTableStreamingSubscriptionFields - buildTableInsertMutationFields = bqBuildTableInsertMutationFields - buildTableUpdateMutationFields = bqBuildTableUpdateMutationFields - buildTableDeleteMutationFields = bqBuildTableDeleteMutationFields - buildFunctionQueryFields = bqBuildFunctionQueryFields - buildFunctionRelayQueryFields = bqBuildFunctionRelayQueryFields - buildFunctionMutationFields = bqBuildFunctionMutationFields + buildTableInsertMutationFields _ _ _ _ _ _ = pure [] + buildTableUpdateMutationFields _ _ _ _ _ _ = pure [] + buildTableDeleteMutationFields _ _ _ _ _ _ = pure [] + buildFunctionQueryFields _ _ _ _ _ = pure [] + buildFunctionRelayQueryFields _ _ _ _ _ _ = pure [] + buildFunctionMutationFields _ _ _ _ _ = pure [] -- backend extensions relayExtension = Nothing @@ -71,7 +70,7 @@ instance BackendSchema 'BigQuery where -- individual components columnParser = bqColumnParser - scalarSelectionArgumentsParser = bqScalarSelectionArgumentsParser + scalarSelectionArgumentsParser _ = pure Nothing orderByOperators _sourceInfo = bqOrderByOperators comparisonExps = bqComparisonExps countTypeInput = bqCountTypeInput @@ -84,91 +83,6 @@ instance BackendTableSelectSchema 'BigQuery where selectTableAggregate = defaultSelectTableAggregate tableSelectionSet = defaultTableSelectionSet ----------------------------------------------------------------- --- Top level parsers - -bqBuildTableRelayQueryFields :: - MonadBuildSchema 'BigQuery r m n => - MkRootFieldName -> - SourceInfo 'BigQuery -> - TableName 'BigQuery -> - TableInfo 'BigQuery -> - C.GQLNameIdentifier -> - NESeq (ColumnInfo 'BigQuery) -> - m [P.FieldParser n a] -bqBuildTableRelayQueryFields _mkRootFieldName _sourceName _tableName _tableInfo _gqlName _pkeyColumns = - pure [] - -bqBuildTableInsertMutationFields :: - MonadBuildSchema 'BigQuery r m n => - MkRootFieldName -> - Scenario -> - SourceInfo 'BigQuery -> - TableName 'BigQuery -> - TableInfo 'BigQuery -> - C.GQLNameIdentifier -> - m [P.FieldParser n a] -bqBuildTableInsertMutationFields _mkRootFieldName _scenario _sourceName _tableName _tableInfo _gqlName = - pure [] - -bqBuildTableUpdateMutationFields :: - MonadBuildSchema 'BigQuery r m n => - MkRootFieldName -> - Scenario -> - SourceInfo 'BigQuery -> - TableName 'BigQuery -> - TableInfo 'BigQuery -> - C.GQLNameIdentifier -> - m [P.FieldParser n a] -bqBuildTableUpdateMutationFields _mkRootFieldName _scenario _sourceName _tableName _tableInfo _gqlName = - pure [] - -bqBuildTableDeleteMutationFields :: - MonadBuildSchema 'BigQuery r m n => - MkRootFieldName -> - Scenario -> - SourceInfo 'BigQuery -> - TableName 'BigQuery -> - TableInfo 'BigQuery -> - C.GQLNameIdentifier -> - m [P.FieldParser n a] -bqBuildTableDeleteMutationFields _mkRootFieldName _scenario _sourceName _tableName _tableInfo _gqlName = - pure [] - -bqBuildFunctionQueryFields :: - MonadBuildSchema 'BigQuery r m n => - MkRootFieldName -> - SourceInfo 'BigQuery -> - FunctionName 'BigQuery -> - FunctionInfo 'BigQuery -> - TableName 'BigQuery -> - m [P.FieldParser n a] -bqBuildFunctionQueryFields _ _ _ _ _ = - pure [] - -bqBuildFunctionRelayQueryFields :: - MonadBuildSchema 'BigQuery r m n => - MkRootFieldName -> - SourceInfo 'BigQuery -> - FunctionName 'BigQuery -> - FunctionInfo 'BigQuery -> - TableName 'BigQuery -> - NESeq (ColumnInfo 'BigQuery) -> - m [P.FieldParser n a] -bqBuildFunctionRelayQueryFields _mkRootFieldName _sourceName _functionName _functionInfo _tableName _pkeyColumns = - pure [] - -bqBuildFunctionMutationFields :: - MonadBuildSchema 'BigQuery r m n => - MkRootFieldName -> - SourceInfo 'BigQuery -> - FunctionName 'BigQuery -> - FunctionInfo 'BigQuery -> - TableName 'BigQuery -> - m [P.FieldParser n a] -bqBuildFunctionMutationFields _ _ _ _ _ = - pure [] - ---------------------------------------------------------------- -- Individual components @@ -231,12 +145,6 @@ bqColumnParser columnType (G.Nullability isNullable) = stringBased scalarName = P.string {P.pType = P.TNamed P.NonNullable $ P.Definition scalarName Nothing Nothing [] P.TIScalar} -bqScalarSelectionArgumentsParser :: - MonadParse n => - ColumnType 'BigQuery -> - InputFieldsParser n (Maybe (ScalarSelectionArguments 'BigQuery)) -bqScalarSelectionArgumentsParser _columnType = pure Nothing - bqOrderByOperators :: NamingCase -> ( G.Name, @@ -524,14 +432,3 @@ bqComputedField sourceName ComputedFieldInfo {..} tableName tableInfo = runMaybe fieldName <- textToName argumentName let argParser = P.field fieldName Nothing typedParser pure $ argParser `P.bindFields` \inputValue -> pure ((argumentName, BigQuery.AEInput $ IR.mkParameter inputValue)) - -{- -NOTE: Unused. Should we remove? --- | Remote join field parser. --- Currently unsupported: returns Nothing for now. -bqRemoteRelationshipField :: - MonadBuildSchema 'BigQuery r m n => - RemoteFieldInfo (DBJoinField 'BigQuery) -> - m (Maybe [FieldParser n (AnnotatedField 'BigQuery)]) -bqRemoteRelationshipField _remoteFieldInfo = pure Nothing --} diff --git a/server/src-lib/Hasura/Backends/MSSQL/Instances/Schema.hs b/server/src-lib/Hasura/Backends/MSSQL/Instances/Schema.hs index 008f59d12c7..1a3f39b4a08 100644 --- a/server/src-lib/Hasura/Backends/MSSQL/Instances/Schema.hs +++ b/server/src-lib/Hasura/Backends/MSSQL/Instances/Schema.hs @@ -41,13 +41,9 @@ import Hasura.GraphQL.Schema.Update qualified as SU import Hasura.Name qualified as Name import Hasura.Prelude import Hasura.RQL.IR -import Hasura.RQL.IR.Insert qualified as IR import Hasura.RQL.IR.Select qualified as IR import Hasura.RQL.Types.Backend hiding (BackendInsert) import Hasura.RQL.Types.Column -import Hasura.RQL.Types.ComputedField -import Hasura.RQL.Types.Function -import Hasura.RQL.Types.Relationships.Local import Hasura.RQL.Types.SchemaCache import Hasura.RQL.Types.Source import Hasura.RQL.Types.SourceCustomization (MkRootFieldName (..)) @@ -62,31 +58,41 @@ import Language.GraphQL.Draft.Syntax qualified as G instance BackendSchema 'MSSQL where -- top level parsers buildTableQueryAndSubscriptionFields = GSB.buildTableQueryAndSubscriptionFields - buildTableRelayQueryFields = msBuildTableRelayQueryFields + buildTableRelayQueryFields _ _ _ _ _ _ = pure [] buildTableStreamingSubscriptionFields = GSB.buildTableStreamingSubscriptionFields buildTableInsertMutationFields = GSB.buildTableInsertMutationFields backendInsertParser buildTableDeleteMutationFields = GSB.buildTableDeleteMutationFields buildTableUpdateMutationFields = msBuildTableUpdateMutationFields - buildFunctionQueryFields = msBuildFunctionQueryFields - buildFunctionRelayQueryFields = msBuildFunctionRelayQueryFields - buildFunctionMutationFields = msBuildFunctionMutationFields + buildFunctionQueryFields _ _ _ _ _ = pure [] + buildFunctionRelayQueryFields _ _ _ _ _ _ = pure [] + buildFunctionMutationFields _ _ _ _ _ = pure [] -- backend extensions relayExtension = Nothing nodesAggExtension = Just () streamSubscriptionExtension = Nothing - mkRelationshipParser = msMkRelationshipParser + -- When we support nested inserts, we also need to ensure we limit ourselves + -- to inserting into tables whch supports inserts: + {- + import Hasura.GraphQL.Schema.Mutation qualified as GSB + + runMaybeT $ do + let otherTableName = riRTable relationshipInfo + otherTableInfo <- lift $ askTableInfo sourceName otherTableName + guard (supportsInserts otherTableInfo) + -} + mkRelationshipParser _ _ = pure Nothing -- individual components columnParser = msColumnParser - scalarSelectionArgumentsParser = msScalarSelectionArgumentsParser + scalarSelectionArgumentsParser _ = pure Nothing orderByOperators _sourceInfo = msOrderByOperators comparisonExps = msComparisonExps countTypeInput = msCountTypeInput aggregateOrderByCountType = MSSQL.IntegerType - computedField = msComputedField + computedField _ _ _ _ = pure Nothing instance BackendTableSelectSchema 'MSSQL where tableArguments = msTableArgs @@ -98,18 +104,6 @@ instance BackendTableSelectSchema 'MSSQL where -- * Top level parsers -msBuildTableRelayQueryFields :: - MonadBuildSchema 'MSSQL r m n => - MkRootFieldName -> - SourceInfo 'MSSQL -> - TableName 'MSSQL -> - TableInfo 'MSSQL -> - C.GQLNameIdentifier -> - NESeq (ColumnInfo 'MSSQL) -> - m [P.FieldParser n a] -msBuildTableRelayQueryFields _mkRootFieldName _sourceName _tableName _tableInfo _gqlName _pkeyColumns = - pure [] - backendInsertParser :: forall m r n. MonadBuildSchema 'MSSQL r m n => @@ -155,40 +149,6 @@ msBuildTableUpdateMutationFields mkRootFieldName scenario sourceName tableName t gqlName pure . fold @Maybe @[_] $ fieldParsers -msBuildFunctionQueryFields :: - MonadBuildSchema 'MSSQL r m n => - MkRootFieldName -> - SourceInfo 'MSSQL -> - FunctionName 'MSSQL -> - FunctionInfo 'MSSQL -> - TableName 'MSSQL -> - m [P.FieldParser n a] -msBuildFunctionQueryFields _ _ _ _ _ = - pure [] - -msBuildFunctionRelayQueryFields :: - MonadBuildSchema 'MSSQL r m n => - MkRootFieldName -> - SourceInfo 'MSSQL -> - FunctionName 'MSSQL -> - FunctionInfo 'MSSQL -> - TableName 'MSSQL -> - NESeq (ColumnInfo 'MSSQL) -> - m [P.FieldParser n a] -msBuildFunctionRelayQueryFields _mkRootFieldName _sourceName _functionName _functionInfo _tableName _pkeyColumns = - pure [] - -msBuildFunctionMutationFields :: - MonadBuildSchema 'MSSQL r m n => - MkRootFieldName -> - SourceInfo 'MSSQL -> - FunctionName 'MSSQL -> - FunctionInfo 'MSSQL -> - TableName 'MSSQL -> - m [P.FieldParser n a] -msBuildFunctionMutationFields _ _ _ _ _ = - pure [] - ---------------------------------------------------------------- -- * Table arguments @@ -217,25 +177,6 @@ msTableArgs sourceName tableInfo = do IR._saDistinct = Nothing } -msMkRelationshipParser :: - forall r m n. - MonadBuildSchema 'MSSQL r m n => - SourceInfo 'MSSQL -> - RelInfo 'MSSQL -> - m (Maybe (InputFieldsParser n (Maybe (IR.AnnotatedInsertField 'MSSQL (UnpreparedValue 'MSSQL))))) -msMkRelationshipParser _sourceName _relationshipInfo = do - -- When we support nested inserts, we also need to ensure we limit ourselves - -- to inserting into tables whch supports inserts: - {- - import Hasura.GraphQL.Schema.Mutation qualified as GSB - - runMaybeT $ do - let otherTableName = riRTable relationshipInfo - otherTableInfo <- lift $ askTableInfo sourceName otherTableName - guard (supportsInserts otherTableInfo) - -} - return Nothing - ---------------------------------------------------------------- -- * Individual components @@ -297,12 +238,6 @@ msColumnParser columnType (G.Nullability isNullable) = ODBC.TextValue $ G.unName value ) -msScalarSelectionArgumentsParser :: - MonadParse n => - ColumnType 'MSSQL -> - InputFieldsParser n (Maybe (ScalarSelectionArguments 'MSSQL)) -msScalarSelectionArgumentsParser _columnType = pure Nothing - msOrderByOperators :: NamingCase -> ( G.Name, @@ -449,26 +384,3 @@ msCountTypeInput = \case mkCountType _ Nothing = MSSQL.StarCountable mkCountType IR.SelectCountDistinct (Just col) = MSSQL.DistinctCountable col mkCountType IR.SelectCountNonDistinct (Just col) = MSSQL.NonNullFieldCountable col - --- | Computed field parser. --- Currently unsupported: returns Nothing for now. -msComputedField :: - MonadBuildSchema 'MSSQL r m n => - SourceInfo 'MSSQL -> - ComputedFieldInfo 'MSSQL -> - TableName 'MSSQL -> - TableInfo 'MSSQL -> - m (Maybe (FieldParser n (AnnotatedField 'MSSQL))) -msComputedField _sourceName _fieldInfo _table _tableInfo = pure Nothing - -{- -NOTE: Unused, should we remove? - --- | Remote join field parser. --- Currently unsupported: returns Nothing for now. -msRemoteRelationshipField :: - MonadBuildSchema 'MSSQL r m n => - RemoteFieldInfo (DBJoinField 'MSSQL) -> - m (Maybe [FieldParser n (AnnotatedField 'MSSQL)]) -msRemoteRelationshipField _remoteFieldInfo = pure Nothing --} diff --git a/server/src-lib/Hasura/Backends/MySQL/Instances/Schema.hs b/server/src-lib/Hasura/Backends/MySQL/Instances/Schema.hs index 85cb6c84353..efee84a1637 100644 --- a/server/src-lib/Hasura/Backends/MySQL/Instances/Schema.hs +++ b/server/src-lib/Hasura/Backends/MySQL/Instances/Schema.hs @@ -8,7 +8,6 @@ import Data.ByteString (ByteString) import Data.Has import Data.HashMap.Strict qualified as HM import Data.List.NonEmpty qualified as NE -import Data.Text.Casing qualified as C import Data.Text.Encoding (encodeUtf8) import Data.Text.Extended import Database.MySQL.Base.Types qualified as MySQL @@ -35,28 +34,26 @@ import Hasura.RQL.IR import Hasura.RQL.IR.Select qualified as IR import Hasura.RQL.Types.Backend as RQL import Hasura.RQL.Types.Column as RQL -import Hasura.RQL.Types.Function as RQL import Hasura.RQL.Types.SchemaCache as RQL import Hasura.RQL.Types.Source as RQL -import Hasura.RQL.Types.SourceCustomization as RQL import Hasura.SQL.Backend import Language.GraphQL.Draft.Syntax qualified as GQL instance BackendSchema 'MySQL where buildTableQueryAndSubscriptionFields = GSB.buildTableQueryAndSubscriptionFields - buildTableRelayQueryFields = buildTableRelayQueryFields' + buildTableRelayQueryFields _ _ _ _ _ _ = pure [] buildTableStreamingSubscriptionFields = GSB.buildTableStreamingSubscriptionFields - buildTableInsertMutationFields = buildTableInsertMutationFields' - buildTableUpdateMutationFields = buildTableUpdateMutationFields' - buildTableDeleteMutationFields = buildTableDeleteMutationFields' - buildFunctionQueryFields = buildFunctionQueryFields' - buildFunctionRelayQueryFields = buildFunctionRelayQueryFields' - buildFunctionMutationFields = buildFunctionMutationFields' + buildTableInsertMutationFields _ _ _ _ _ _ = pure [] + buildTableUpdateMutationFields _ _ _ _ _ _ = pure [] + buildTableDeleteMutationFields _ _ _ _ _ _ = pure [] + buildFunctionQueryFields _ _ _ _ _ = pure [] + buildFunctionRelayQueryFields _ _ _ _ _ _ = pure [] + buildFunctionMutationFields _ _ _ _ _ = pure [] relayExtension = Nothing nodesAggExtension = Just () streamSubscriptionExtension = Nothing columnParser = columnParser' - scalarSelectionArgumentsParser = scalarSelectionArgumentsParser' + scalarSelectionArgumentsParser _ = pure Nothing orderByOperators _sourceInfo = orderByOperators' comparisonExps = comparisonExps' countTypeInput = mysqlCountTypeInput @@ -92,88 +89,6 @@ mysqlTableArgs sourceInfo tableInfo = do IR._saDistinct = Nothing } -buildTableRelayQueryFields' :: - MonadBuildSchema 'MySQL r m n => - RQL.MkRootFieldName -> - RQL.SourceInfo 'MySQL -> - RQL.TableName 'MySQL -> - TableInfo 'MySQL -> - C.GQLNameIdentifier -> - NESeq (ColumnInfo 'MySQL) -> - m [P.FieldParser n a] -buildTableRelayQueryFields' _mkRootFieldName _sourceInfo _tableName _tableInfo _gqlName _pkeyColumns = - pure [] - -buildTableInsertMutationFields' :: - MonadBuildSchema 'MySQL r m n => - RQL.MkRootFieldName -> - Scenario -> - RQL.SourceInfo 'MySQL -> - RQL.TableName 'MySQL -> - TableInfo 'MySQL -> - C.GQLNameIdentifier -> - m [P.FieldParser n a] -buildTableInsertMutationFields' _mkRootFieldName _scenario _sourceInfo _tableName _tableInfo _gqlName = - pure [] - -buildTableUpdateMutationFields' :: - MonadBuildSchema 'MySQL r m n => - RQL.MkRootFieldName -> - Scenario -> - RQL.SourceInfo 'MySQL -> - RQL.TableName 'MySQL -> - TableInfo 'MySQL -> - C.GQLNameIdentifier -> - m [P.FieldParser n a] -buildTableUpdateMutationFields' _mkRootFieldName _scenario _sourceInfo _tableName _tableInfo _gqlName = - pure [] - -buildTableDeleteMutationFields' :: - MonadBuildSchema 'MySQL r m n => - RQL.MkRootFieldName -> - Scenario -> - RQL.SourceInfo 'MySQL -> - RQL.TableName 'MySQL -> - TableInfo 'MySQL -> - C.GQLNameIdentifier -> - m [P.FieldParser n a] -buildTableDeleteMutationFields' _mkRootFieldName _scenario _sourceInfo _tableName _tableInfo _gqlName = - pure [] - -buildFunctionQueryFields' :: - MonadBuildSchema 'MySQL r m n => - RQL.MkRootFieldName -> - RQL.SourceInfo 'MySQL -> - FunctionName 'MySQL -> - FunctionInfo 'MySQL -> - RQL.TableName 'MySQL -> - m [P.FieldParser n a] -buildFunctionQueryFields' _ _ _ _ _ = - pure [] - -buildFunctionRelayQueryFields' :: - MonadBuildSchema 'MySQL r m n => - RQL.MkRootFieldName -> - RQL.SourceInfo 'MySQL -> - FunctionName 'MySQL -> - FunctionInfo 'MySQL -> - RQL.TableName 'MySQL -> - NESeq (ColumnInfo 'MySQL) -> - m [P.FieldParser n a] -buildFunctionRelayQueryFields' _mkRootFieldName _sourceInfo _functionName _functionInfo _tableName _pkeyColumns = - pure [] - -buildFunctionMutationFields' :: - MonadBuildSchema 'MySQL r m n => - RQL.MkRootFieldName -> - RQL.SourceInfo 'MySQL -> - FunctionName 'MySQL -> - FunctionInfo 'MySQL -> - RQL.TableName 'MySQL -> - m [P.FieldParser n a] -buildFunctionMutationFields' _ _ _ _ _ = - pure [] - bsParser :: MonadParse m => Parser 'Both m ByteString bsParser = encodeUtf8 <$> P.string @@ -229,12 +144,6 @@ columnParser' columnType (GQL.Nullability isNullable) = MySQL.VarcharValue $ GQL.unName value ) -scalarSelectionArgumentsParser' :: - MonadParse n => - ColumnType 'MySQL -> - InputFieldsParser n (Maybe (ScalarSelectionArguments 'MySQL)) -scalarSelectionArgumentsParser' _columnType = pure Nothing - orderByOperators' :: NamingCase -> (GQL.Name, NonEmpty (P.Definition P.EnumValueInfo, (BasicOrderType 'MySQL, NullsOrderType 'MySQL))) orderByOperators' _tCase = (Name._order_by,) $ @@ -290,13 +199,6 @@ comparisonExps' = P.memoize 'comparisonExps $ \columnType -> do P.fieldOptional Name.__lte Nothing (ALTE . mkParameter <$> typedParser) ] -{- -NOTE: Should this be removed? -offsetParser' :: MonadParse n => Parser 'Both n (SQLExpression 'MySQL) -offsetParser' = - MySQL.ValueExpression . MySQL.BigValue . fromIntegral <$> P.int --} - mysqlCountTypeInput :: MonadParse n => Maybe (Parser 'Both n (Column 'MySQL)) ->