mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
chore(server): split NamingCase type from functions
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9184 GitOrigin-RevId: caf36bdaa6c739855153b33a0f130b3f2dda6c0a
This commit is contained in:
parent
ee2258288e
commit
42817af958
@ -810,6 +810,7 @@ library
|
||||
, Hasura.RQL.Types.Metadata.Instances
|
||||
, Hasura.RQL.Types.Metadata.Object
|
||||
, Hasura.RQL.Types.Metadata.Serialization
|
||||
, Hasura.RQL.Types.NamingCase
|
||||
, Hasura.RQL.Types.OpenTelemetry
|
||||
, Hasura.RQL.Types.Permission
|
||||
, Hasura.RQL.Types.QueryCollection
|
||||
|
@ -34,13 +34,13 @@ import Hasura.Eventing.Common (LockedEventsCtx)
|
||||
import Hasura.Eventing.EventTrigger
|
||||
import Hasura.GraphQL.Execute.Subscription.Options
|
||||
import Hasura.GraphQL.Execute.Subscription.State qualified as ES
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.Incremental qualified as Inc
|
||||
import Hasura.Logging qualified as L
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.DDL.Schema.Cache.Config
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.Metadata
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Roles (RoleName)
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.RQL.Types.SchemaCache (MetadataResourceVersion)
|
||||
@ -187,7 +187,7 @@ data InvalidationKeys = InvalidationKeys
|
||||
-- subset of the environment, exposed by small, local typeclasses. For instance,
|
||||
-- at time of writing, this can be used to implement 'HasServerConfigCtx', as a
|
||||
-- first step towards breaking it down.
|
||||
class Monad m => HasAppEnv m where
|
||||
class (Monad m) => HasAppEnv m where
|
||||
askAppEnv :: m AppEnv
|
||||
|
||||
instance (HasAppEnv m) => HasAppEnv (ReaderT r m) where
|
||||
|
@ -15,7 +15,6 @@ import Hasura.Backends.BigQuery.DDL.Source as M
|
||||
import Hasura.Backends.BigQuery.Types qualified as BigQuery
|
||||
import Hasura.Base.Error
|
||||
import Hasura.Function.Cache
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.IR.BoolExp
|
||||
import Hasura.RQL.Types.Backend
|
||||
@ -23,6 +22,7 @@ import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.EventTrigger
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.SchemaCache
|
||||
import Hasura.SQL.Types
|
||||
import Hasura.Server.Utils
|
||||
|
@ -21,7 +21,6 @@ import Hasura.GraphQL.Schema.Backend
|
||||
import Hasura.GraphQL.Schema.BoolExp
|
||||
import Hasura.GraphQL.Schema.Build qualified as GSB
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Parser
|
||||
( FieldParser,
|
||||
InputFieldsParser,
|
||||
@ -45,6 +44,7 @@ import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.ComputedField
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.RQL.Types.Source
|
||||
import Hasura.RQL.Types.SourceCustomization
|
||||
|
@ -23,7 +23,6 @@ import Hasura.GraphQL.Schema.Backend (BackendSchema (..), BackendTableSelectSche
|
||||
import Hasura.GraphQL.Schema.BoolExp qualified as GS.BE
|
||||
import Hasura.GraphQL.Schema.Build qualified as GS.B
|
||||
import Hasura.GraphQL.Schema.Common qualified as GS.C
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Parser qualified as P
|
||||
import Hasura.GraphQL.Schema.Select qualified as GS.S
|
||||
import Hasura.GraphQL.Schema.Update qualified as GS.U
|
||||
@ -40,6 +39,7 @@ import Hasura.RQL.IR.Value qualified as IR
|
||||
import Hasura.RQL.Types.Backend qualified as RQL
|
||||
import Hasura.RQL.Types.BackendType (BackendType (..))
|
||||
import Hasura.RQL.Types.Column qualified as RQL
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.RQL.Types.Source qualified as RQL
|
||||
import Hasura.RQL.Types.SourceCustomization qualified as RQL
|
||||
|
@ -23,7 +23,6 @@ import Hasura.Backends.MSSQL.DDL.Source as M
|
||||
import Hasura.Backends.MSSQL.Types.Internal qualified as MT
|
||||
import Hasura.Base.Error
|
||||
import Hasura.Function.Cache
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.IR.BoolExp
|
||||
import Hasura.RQL.Types.Backend
|
||||
@ -32,6 +31,7 @@ import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.ComputedField
|
||||
import Hasura.RQL.Types.EventTrigger
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.SchemaCache
|
||||
import Hasura.SQL.Types
|
||||
import Hasura.Server.Utils
|
||||
|
@ -24,7 +24,6 @@ import Hasura.GraphQL.Schema.Backend
|
||||
import Hasura.GraphQL.Schema.BoolExp
|
||||
import Hasura.GraphQL.Schema.Build qualified as GSB
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Parser
|
||||
( InputFieldsParser,
|
||||
Kind (..),
|
||||
@ -42,6 +41,7 @@ import Hasura.RQL.IR.Select qualified as IR
|
||||
import Hasura.RQL.Types.Backend hiding (BackendInsert)
|
||||
import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.RQL.Types.SchemaCache
|
||||
import Hasura.RQL.Types.Source
|
||||
@ -120,7 +120,7 @@ instance BackendUpdateOperatorsSchema 'MSSQL where
|
||||
|
||||
backendInsertParser ::
|
||||
forall m r n.
|
||||
MonadBuildSchema 'MSSQL r m n =>
|
||||
(MonadBuildSchema 'MSSQL r m n) =>
|
||||
TableInfo 'MSSQL ->
|
||||
SchemaT r m (InputFieldsParser n (BackendInsert (UnpreparedValue 'MSSQL)))
|
||||
backendInsertParser tableInfo = do
|
||||
@ -136,7 +136,7 @@ backendInsertParser tableInfo = do
|
||||
|
||||
msTableArgs ::
|
||||
forall r m n.
|
||||
MonadBuildSchema 'MSSQL r m n =>
|
||||
(MonadBuildSchema 'MSSQL r m n) =>
|
||||
TableInfo 'MSSQL ->
|
||||
SchemaT r m (InputFieldsParser n (IR.SelectArgsG 'MSSQL (UnpreparedValue 'MSSQL)))
|
||||
msTableArgs tableInfo = do
|
||||
@ -162,7 +162,7 @@ msTableArgs tableInfo = do
|
||||
-- * Individual components
|
||||
|
||||
msColumnParser ::
|
||||
MonadBuildSchema 'MSSQL r m n =>
|
||||
(MonadBuildSchema 'MSSQL r m n) =>
|
||||
ColumnType 'MSSQL ->
|
||||
G.Nullability ->
|
||||
SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue 'MSSQL)))
|
||||
@ -234,7 +234,7 @@ msColumnParser columnType nullability = case columnType of
|
||||
else ODBC.TextValue txt -- an ODBC.TextValue becomes an NVARCHAR
|
||||
|
||||
msEnumParser ::
|
||||
MonadBuildSchema 'MSSQL r m n =>
|
||||
(MonadBuildSchema 'MSSQL r m n) =>
|
||||
TableName 'MSSQL ->
|
||||
NonEmpty (EnumValue, EnumValueInfo) ->
|
||||
Maybe G.Name ->
|
||||
@ -296,7 +296,7 @@ msOrderByOperators _tCase =
|
||||
|
||||
msComparisonExps ::
|
||||
forall m n r.
|
||||
MonadBuildSchema 'MSSQL r m n =>
|
||||
(MonadBuildSchema 'MSSQL r m n) =>
|
||||
ColumnType 'MSSQL ->
|
||||
SchemaT r m (Parser 'Input n [ComparisonExp 'MSSQL])
|
||||
msComparisonExps = P.memoize 'comparisonExps \columnType -> do
|
||||
@ -385,7 +385,7 @@ msComparisonExps = P.memoize 'comparisonExps \columnType -> do
|
||||
UVLiteral . MSSQL.ListExpression . fmap (MSSQL.ValueExpression . cvValue)
|
||||
|
||||
msCountTypeInput ::
|
||||
MonadParse n =>
|
||||
(MonadParse n) =>
|
||||
Maybe (Parser 'Both n (Column 'MSSQL)) ->
|
||||
InputFieldsParser n (IR.CountDistinct -> CountType 'MSSQL)
|
||||
msCountTypeInput = \case
|
||||
@ -401,7 +401,7 @@ msCountTypeInput = \case
|
||||
|
||||
msParseUpdateOperators ::
|
||||
forall m n r.
|
||||
MonadBuildSchema 'MSSQL r m n =>
|
||||
(MonadBuildSchema 'MSSQL r m n) =>
|
||||
TableInfo 'MSSQL ->
|
||||
UpdPermInfo 'MSSQL ->
|
||||
SchemaT r m (InputFieldsParser n (HashMap (Column 'MSSQL) (UpdateOperators 'MSSQL (UnpreparedValue 'MSSQL))))
|
||||
|
@ -20,11 +20,11 @@ import Hasura.Backends.Postgres.Types.Function
|
||||
import Hasura.Base.Error
|
||||
import Hasura.Function.Cache
|
||||
import Hasura.Function.Common (getFunctionAggregateGQLName, getFunctionArgsGQLName, getFunctionGQLName)
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.SchemaCache
|
||||
import Hasura.RQL.Types.SchemaCacheTypes
|
||||
import Hasura.RQL.Types.SourceCustomization (applyFieldNameCaseCust)
|
||||
|
@ -28,7 +28,6 @@ import Hasura.Backends.Postgres.Translate.Select (PostgresAnnotatedFieldJSON)
|
||||
import Hasura.Backends.Postgres.Types.Insert
|
||||
import Hasura.Base.Error
|
||||
import Hasura.EncJSON
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase)
|
||||
import Hasura.Prelude
|
||||
import Hasura.QueryTags
|
||||
import Hasura.RQL.IR.BoolExp
|
||||
@ -38,6 +37,7 @@ import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
import Hasura.RQL.Types.Relationships.Local
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.Session
|
||||
@ -327,7 +327,7 @@ validateInsert insCols objRels addCols = do
|
||||
insConflictCols = insCols `intersect` addCols
|
||||
|
||||
mkInsertQ ::
|
||||
Backend ('Postgres pgKind) =>
|
||||
(Backend ('Postgres pgKind)) =>
|
||||
QualifiedTable ->
|
||||
Maybe (IR.OnConflictClause ('Postgres pgKind) Postgres.SQLExp) ->
|
||||
HashMap.HashMap PGCol Postgres.SQLExp ->
|
||||
@ -352,7 +352,7 @@ mkInsertQ table onConflictM insertRow (insCheck, updCheck) =
|
||||
in Postgres.CTEInsert sqlInsert
|
||||
|
||||
fetchFromColVals ::
|
||||
MonadError QErr m =>
|
||||
(MonadError QErr m) =>
|
||||
ColumnValues ('Postgres pgKind) TxtEncodedVal ->
|
||||
[ColumnInfo ('Postgres pgKind)] ->
|
||||
m [(PGCol, Postgres.SQLExp)]
|
||||
|
@ -33,7 +33,6 @@ import Hasura.Backends.Postgres.Translate.Select.Internal.Helpers (customSQLToTo
|
||||
import Hasura.Backends.Postgres.Translate.Update
|
||||
import Hasura.Base.Error
|
||||
import Hasura.EncJSON
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase)
|
||||
import Hasura.Prelude
|
||||
import Hasura.QueryTags
|
||||
import Hasura.RQL.IR.BoolExp
|
||||
@ -46,6 +45,7 @@ import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.Session
|
||||
|
||||
@ -235,7 +235,7 @@ executeMutationOutputQuery ::
|
||||
m EncJSON
|
||||
executeMutationOutputQuery qt allCols preCalAffRows cte mutOutput strfyNum tCase prepArgs = do
|
||||
queryTags <- ask
|
||||
let queryTx :: PG.FromRes a => m a
|
||||
let queryTx :: (PG.FromRes a) => m a
|
||||
queryTx = do
|
||||
let selectWith = mkMutationOutputExp qt allCols preCalAffRows cte mutOutput strfyNum tCase
|
||||
query = toQuery selectWith
|
||||
@ -257,7 +257,7 @@ mutateAndFetchCols ::
|
||||
Maybe NamingCase ->
|
||||
PG.TxE QErr (MutateResp ('Postgres pgKind) TxtEncodedVal)
|
||||
mutateAndFetchCols qt cols (cte, p) strfyNum tCase = do
|
||||
let mutationTx :: PG.FromRes a => PG.TxE QErr a
|
||||
let mutationTx :: (PG.FromRes a) => PG.TxE QErr a
|
||||
mutationTx =
|
||||
-- See Note [Prepared statements in Mutations]
|
||||
PG.rawQE dmlTxErrorHandler sqlText (toList p) False
|
||||
|
@ -48,7 +48,6 @@ import Hasura.GraphQL.Schema.BoolExp.AggregationPredicates as Agg
|
||||
import Hasura.GraphQL.Schema.Build qualified as GSB
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.Mutation qualified as GSB
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Parser
|
||||
( Definition,
|
||||
FieldParser,
|
||||
@ -79,6 +78,7 @@ import Hasura.RQL.IR.Value qualified as IR
|
||||
import Hasura.RQL.Types.Backend (Backend (..))
|
||||
import Hasura.RQL.Types.BackendType (BackendType (Postgres), PostgresKind (Citus, Cockroach, Vanilla))
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.RQL.Types.Source
|
||||
import Hasura.RQL.Types.SourceCustomization
|
||||
|
@ -15,6 +15,7 @@ import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
|
||||
toTxtValue :: ColumnValue ('Postgres pgKind) -> SQLExp
|
||||
|
@ -21,7 +21,6 @@ import Hasura.Backends.Postgres.SQL.Types
|
||||
import Hasura.Backends.Postgres.Translate.Select
|
||||
import Hasura.Backends.Postgres.Translate.Select.Internal.Helpers (customSQLToTopLevelCTEs)
|
||||
import Hasura.Backends.Postgres.Translate.Types (CustomSQLCTEs)
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase)
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.IR.BoolExp
|
||||
import Hasura.RQL.IR.Returning
|
||||
@ -30,6 +29,7 @@ import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.Table.Cache
|
||||
|
||||
|
@ -78,7 +78,6 @@ import Hasura.Backends.Postgres.Translate.Select.Internal.JoinTree
|
||||
)
|
||||
import Hasura.Backends.Postgres.Translate.Select.Internal.OrderBy (processOrderByItems)
|
||||
import Hasura.Backends.Postgres.Translate.Types
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase)
|
||||
import Hasura.GraphQL.Schema.Node (currentNodeIdVersion, nodeIdVersionInt)
|
||||
import Hasura.NativeQuery.IR (NativeQuery (..))
|
||||
import Hasura.Prelude
|
||||
@ -89,6 +88,7 @@ import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
import Hasura.RQL.Types.Relationships.Local
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
|
||||
|
@ -21,7 +21,6 @@ import Hasura.Base.Error
|
||||
import Hasura.Base.ErrorMessage (toErrorMessage)
|
||||
import Hasura.GraphQL.Parser qualified as P
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Parser
|
||||
import Hasura.Name qualified as Name
|
||||
import Hasura.Prelude
|
||||
@ -31,6 +30,7 @@ import Hasura.RQL.IR.Select
|
||||
import Hasura.RQL.IR.Value (UnpreparedValue, ValueWithOrigin (ValueNoOrigin))
|
||||
import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Schema.Options (StringifyNumbers)
|
||||
import Hasura.RQL.Types.Source
|
||||
import Hasura.SQL.AnyBackend qualified as AB
|
||||
|
@ -44,7 +44,6 @@ import Data.Text.Casing (GQLNameIdentifier)
|
||||
import Hasura.Function.Cache
|
||||
import Hasura.GraphQL.ApolloFederation (ApolloFederationParserFunction)
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Parser hiding (Type)
|
||||
import Hasura.LogicalModel.Cache (LogicalModelInfo)
|
||||
import Hasura.NativeQuery.Cache (NativeQueryInfo)
|
||||
@ -58,6 +57,7 @@ import Hasura.RQL.Types.Column hiding (EnumValueInfo)
|
||||
import Hasura.RQL.Types.Column qualified as Column
|
||||
import Hasura.RQL.Types.Common (RelName)
|
||||
import Hasura.RQL.Types.ComputedField
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Relationships.Local
|
||||
import Hasura.RQL.Types.SchemaCache
|
||||
import Hasura.RQL.Types.Source
|
||||
@ -96,12 +96,12 @@ type MonadBuildSchema b r m n =
|
||||
--
|
||||
-- See <#modelling Note BackendSchema modelling principles>.
|
||||
class
|
||||
Backend b =>
|
||||
(Backend b) =>
|
||||
BackendSchema (b :: BackendType)
|
||||
where
|
||||
-- top level parsers
|
||||
buildTableQueryAndSubscriptionFields ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
MkRootFieldName ->
|
||||
TableName b ->
|
||||
TableInfo b ->
|
||||
@ -114,14 +114,14 @@ class
|
||||
Maybe (G.Name, Parser 'Output n (ApolloFederationParserFunction n))
|
||||
)
|
||||
buildTableStreamingSubscriptionFields ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
MkRootFieldName ->
|
||||
TableName b ->
|
||||
TableInfo b ->
|
||||
GQLNameIdentifier ->
|
||||
SchemaT r m [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))]
|
||||
buildTableRelayQueryFields ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
MkRootFieldName ->
|
||||
TableName b ->
|
||||
TableInfo b ->
|
||||
@ -129,7 +129,7 @@ class
|
||||
NESeq (ColumnInfo b) ->
|
||||
SchemaT r m [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))]
|
||||
buildTableInsertMutationFields ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
MkRootFieldName ->
|
||||
Scenario ->
|
||||
TableName b ->
|
||||
@ -144,7 +144,7 @@ class
|
||||
-- The suggested way to implement this is using building blocks in GSB, c.f.
|
||||
-- its namesake @GSB.@'Hasura.GraphQL.Schema.Build.buildTableUpdateMutationFields'.
|
||||
buildTableUpdateMutationFields ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
Scenario ->
|
||||
-- | table info
|
||||
TableInfo b ->
|
||||
@ -153,7 +153,7 @@ class
|
||||
SchemaT r m [FieldParser n (AnnotatedUpdateG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))]
|
||||
|
||||
buildTableDeleteMutationFields ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
MkRootFieldName ->
|
||||
Scenario ->
|
||||
TableName b ->
|
||||
@ -162,7 +162,7 @@ class
|
||||
SchemaT r m [FieldParser n (AnnDelG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))]
|
||||
|
||||
buildFunctionQueryFields ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
MkRootFieldName ->
|
||||
FunctionName b ->
|
||||
FunctionInfo b ->
|
||||
@ -170,7 +170,7 @@ class
|
||||
SchemaT r m [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))]
|
||||
|
||||
buildFunctionRelayQueryFields ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
MkRootFieldName ->
|
||||
FunctionName b ->
|
||||
FunctionInfo b ->
|
||||
@ -179,7 +179,7 @@ class
|
||||
SchemaT r m [FieldParser n (QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))]
|
||||
|
||||
buildFunctionMutationFields ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
MkRootFieldName ->
|
||||
FunctionName b ->
|
||||
FunctionInfo b ->
|
||||
@ -187,7 +187,7 @@ class
|
||||
SchemaT r m [FieldParser n (MutationDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))]
|
||||
|
||||
buildNativeQueryRootFields ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
NativeQueryInfo b ->
|
||||
SchemaT
|
||||
r
|
||||
@ -196,7 +196,7 @@ class
|
||||
buildNativeQueryRootFields _ = pure Nothing
|
||||
|
||||
buildStoredProcedureRootFields ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
StoredProcedureInfo b ->
|
||||
SchemaT
|
||||
r
|
||||
@ -207,7 +207,7 @@ class
|
||||
-- | Make a parser for relationships. Default implementaton elides
|
||||
-- relationships altogether.
|
||||
mkRelationshipParser ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
RelInfo b ->
|
||||
SchemaT r m (Maybe (InputFieldsParser n (Maybe (IR.AnnotatedInsertField b (UnpreparedValue b)))))
|
||||
mkRelationshipParser _ = pure Nothing
|
||||
@ -219,19 +219,19 @@ class
|
||||
|
||||
-- individual components
|
||||
columnParser ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
ColumnType b ->
|
||||
G.Nullability -> -- TODO maybe use Hasura.GraphQL.Parser.Schema.Nullability instead?
|
||||
SchemaT r m (Parser 'Both n (ValueWithOrigin (ColumnValue b)))
|
||||
enumParser ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
TableName b ->
|
||||
NonEmpty (EnumValue, Column.EnumValueInfo) ->
|
||||
Maybe G.Name ->
|
||||
G.Nullability ->
|
||||
SchemaT r m (Parser 'Both n (ScalarValue b))
|
||||
possiblyNullable ::
|
||||
MonadParse m =>
|
||||
(MonadParse m) =>
|
||||
ScalarType b ->
|
||||
G.Nullability ->
|
||||
Parser 'Both m (ScalarValue b) ->
|
||||
@ -239,7 +239,7 @@ class
|
||||
|
||||
-- | Parser for arguments on scalar fields in a selection set
|
||||
scalarSelectionArgumentsParser ::
|
||||
MonadParse n =>
|
||||
(MonadParse n) =>
|
||||
ColumnType b ->
|
||||
InputFieldsParser n (Maybe (ScalarSelectionArguments b))
|
||||
|
||||
@ -249,14 +249,14 @@ class
|
||||
(G.Name, NonEmpty (Definition EnumValueInfo, (BasicOrderType b, NullsOrderType b)))
|
||||
|
||||
comparisonExps ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
ColumnType b ->
|
||||
SchemaT r m (Parser 'Input n [ComparisonExp b])
|
||||
|
||||
-- | The input fields parser, for "count" aggregate field, yielding a function
|
||||
-- which generates @'CountType b' from optional "distinct" field value
|
||||
countTypeInput ::
|
||||
MonadParse n =>
|
||||
(MonadParse n) =>
|
||||
Maybe (Parser 'Both n (Column b)) ->
|
||||
InputFieldsParser n (CountDistinct -> CountType b)
|
||||
|
||||
@ -264,7 +264,7 @@ class
|
||||
|
||||
-- | Computed field parser
|
||||
computedField ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
ComputedFieldInfo b ->
|
||||
TableName b ->
|
||||
TableInfo b ->
|
||||
@ -281,19 +281,19 @@ class
|
||||
--
|
||||
-- Default implementations exist for all of these in
|
||||
-- 'Hasura.GraphQL.Schema.Select'.
|
||||
class Backend b => BackendTableSelectSchema (b :: BackendType) where
|
||||
class (Backend b) => BackendTableSelectSchema (b :: BackendType) where
|
||||
tableArguments ::
|
||||
MonadBuildSourceSchema b r m n =>
|
||||
(MonadBuildSourceSchema b r m n) =>
|
||||
TableInfo b ->
|
||||
SchemaT r m (InputFieldsParser n (IR.SelectArgsG b (UnpreparedValue b)))
|
||||
|
||||
tableSelectionSet ::
|
||||
MonadBuildSourceSchema b r m n =>
|
||||
(MonadBuildSourceSchema b r m n) =>
|
||||
TableInfo b ->
|
||||
SchemaT r m (Maybe (Parser 'Output n (AnnotatedFields b)))
|
||||
|
||||
selectTable ::
|
||||
MonadBuildSourceSchema b r m n =>
|
||||
(MonadBuildSourceSchema b r m n) =>
|
||||
-- | table info
|
||||
TableInfo b ->
|
||||
-- | field display name
|
||||
@ -303,7 +303,7 @@ class Backend b => BackendTableSelectSchema (b :: BackendType) where
|
||||
SchemaT r m (Maybe (FieldParser n (SelectExp b)))
|
||||
|
||||
selectTableAggregate ::
|
||||
MonadBuildSourceSchema b r m n =>
|
||||
(MonadBuildSourceSchema b r m n) =>
|
||||
-- | table info
|
||||
TableInfo b ->
|
||||
-- | field display name
|
||||
@ -314,21 +314,21 @@ class Backend b => BackendTableSelectSchema (b :: BackendType) where
|
||||
|
||||
type ComparisonExp b = OpExpG b (UnpreparedValue b)
|
||||
|
||||
class Backend b => BackendLogicalModelSelectSchema (b :: BackendType) where
|
||||
class (Backend b) => BackendLogicalModelSelectSchema (b :: BackendType) where
|
||||
logicalModelArguments ::
|
||||
MonadBuildSourceSchema b r m n =>
|
||||
(MonadBuildSourceSchema b r m n) =>
|
||||
LogicalModelInfo b ->
|
||||
SchemaT r m (InputFieldsParser n (IR.SelectArgsG b (UnpreparedValue b)))
|
||||
|
||||
logicalModelSelectionSet ::
|
||||
MonadBuildSourceSchema b r m n =>
|
||||
(MonadBuildSourceSchema b r m n) =>
|
||||
InsOrdHashMap RelName (RelInfo b) ->
|
||||
LogicalModelInfo b ->
|
||||
SchemaT r m (Maybe (Parser 'Output n (AnnotatedFields b)))
|
||||
|
||||
class BackendLogicalModelSelectSchema b => BackendNativeQuerySelectSchema (b :: BackendType) where
|
||||
class (BackendLogicalModelSelectSchema b) => BackendNativeQuerySelectSchema (b :: BackendType) where
|
||||
selectNativeQuery ::
|
||||
MonadBuildSourceSchema b r m n =>
|
||||
(MonadBuildSourceSchema b r m n) =>
|
||||
NativeQueryInfo b ->
|
||||
G.Name ->
|
||||
Maybe G.Description ->
|
||||
@ -336,7 +336,7 @@ class BackendLogicalModelSelectSchema b => BackendNativeQuerySelectSchema (b ::
|
||||
selectNativeQuery _ _ _ = pure Nothing
|
||||
|
||||
selectNativeQueryObject ::
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
NativeQueryInfo b ->
|
||||
G.Name ->
|
||||
Maybe G.Description ->
|
||||
@ -346,7 +346,7 @@ class BackendLogicalModelSelectSchema b => BackendNativeQuerySelectSchema (b ::
|
||||
(Maybe (FieldParser n (AnnObjectSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))))
|
||||
selectNativeQueryObject _ _ _ = pure Nothing
|
||||
|
||||
class Backend b => BackendUpdateOperatorsSchema (b :: BackendType) where
|
||||
class (Backend b) => BackendUpdateOperatorsSchema (b :: BackendType) where
|
||||
-- | Intermediate Representation of the set of update operators that act
|
||||
-- upon table fields during an update mutation. (For example, _set and _inc)
|
||||
--
|
||||
@ -356,7 +356,7 @@ class Backend b => BackendUpdateOperatorsSchema (b :: BackendType) where
|
||||
|
||||
parseUpdateOperators ::
|
||||
forall m n r.
|
||||
MonadBuildSchema b r m n =>
|
||||
(MonadBuildSchema b r m n) =>
|
||||
TableInfo b ->
|
||||
UpdPermInfo b ->
|
||||
SchemaT r m (InputFieldsParser n (HashMap (Column b) (UpdateOperators b (UnpreparedValue b))))
|
||||
|
@ -20,7 +20,6 @@ import Hasura.Function.Cache
|
||||
import Hasura.GraphQL.Parser.Class
|
||||
import Hasura.GraphQL.Schema.Backend
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Parser
|
||||
( InputFieldsParser,
|
||||
Kind (..),
|
||||
@ -40,6 +39,7 @@ import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.BackendType (BackendType)
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.ComputedField
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Relationships.Local
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.RQL.Types.SchemaCache hiding (askTableInfo)
|
||||
|
@ -20,7 +20,6 @@ import Hasura.GraphQL.Parser qualified as P
|
||||
import Hasura.GraphQL.Schema.Backend
|
||||
import Hasura.GraphQL.Schema.BoolExp
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Parser
|
||||
( InputFieldsParser,
|
||||
Kind (..),
|
||||
@ -36,6 +35,7 @@ import Hasura.RQL.Types.Backend qualified as B
|
||||
import Hasura.RQL.Types.BackendType (BackendType)
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.Common (relNameToTxt)
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Relationships.Local
|
||||
import Hasura.RQL.Types.Schema.Options (IncludeAggregationPredicates (..))
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
|
@ -20,7 +20,6 @@ import Data.Text.Extended
|
||||
import Hasura.GraphQL.Schema.Backend
|
||||
import Hasura.GraphQL.Schema.BoolExp
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase)
|
||||
import Hasura.GraphQL.Schema.Parser
|
||||
( FieldParser,
|
||||
InputFieldsParser,
|
||||
@ -43,6 +42,7 @@ import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.Metadata.Object
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
import Hasura.RQL.Types.Relationships.Local
|
||||
import Hasura.RQL.Types.SchemaCache hiding (askTableInfo)
|
||||
import Hasura.RQL.Types.Source
|
||||
|
@ -1,44 +1,14 @@
|
||||
{-# LANGUAGE OverloadedLists #-}
|
||||
|
||||
module Hasura.GraphQL.Schema.NamingCase
|
||||
( NamingCase (..),
|
||||
isGraphqlCase,
|
||||
parseNamingConventionFromText,
|
||||
( isGraphqlCase,
|
||||
hasNamingConventionChanged,
|
||||
)
|
||||
where
|
||||
|
||||
import Autodocodec qualified as AC
|
||||
import Data.Aeson qualified as J
|
||||
import Data.HashSet qualified as Set
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.Server.Types (ExperimentalFeature (..))
|
||||
|
||||
-- | Represents the different possible type cases for fields and types, i.e.
|
||||
-- @HasuraCase@ and @GraphqlCase@ (@CamelCase@ fields and @PascalCase@ types).
|
||||
data NamingCase = HasuraCase | GraphqlCase
|
||||
deriving (Eq, Show, Generic)
|
||||
|
||||
instance AC.HasCodec NamingCase where
|
||||
codec =
|
||||
AC.named "NamingCase" $
|
||||
AC.stringConstCodec [(HasuraCase, "hasura-default"), (GraphqlCase, "graphql-default")]
|
||||
|
||||
instance J.ToJSON NamingCase where
|
||||
toJSON HasuraCase = J.String "hasura-default"
|
||||
toJSON GraphqlCase = J.String "graphql-default"
|
||||
|
||||
instance J.FromJSON NamingCase where
|
||||
parseJSON = J.withText "NamingCase" $ \s -> case parseNamingConventionFromText s of
|
||||
(Right nc) -> pure nc
|
||||
(Left err) -> fail err
|
||||
|
||||
-- Used for both the environment variable and JSON.
|
||||
parseNamingConventionFromText :: Text -> Either String NamingCase
|
||||
parseNamingConventionFromText "hasura-default" = Right HasuraCase
|
||||
parseNamingConventionFromText "graphql-default" = Right GraphqlCase
|
||||
parseNamingConventionFromText _ = Left "naming_convention can either be \"hasura-default\" or \"graphql-default\""
|
||||
|
||||
isGraphqlCase :: NamingCase -> Bool
|
||||
isGraphqlCase GraphqlCase = True
|
||||
isGraphqlCase _ = False
|
||||
|
@ -16,7 +16,6 @@ import Hasura.Function.Cache
|
||||
import Hasura.GraphQL.Parser.Class
|
||||
import Hasura.GraphQL.Schema.Backend
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Parser
|
||||
( InputFieldsParser,
|
||||
Kind (..),
|
||||
@ -37,6 +36,7 @@ import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.ComputedField
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Relationships.Local
|
||||
import Hasura.RQL.Types.SchemaCache hiding (askTableInfo)
|
||||
import Hasura.RQL.Types.Source
|
||||
|
@ -52,7 +52,6 @@ import Hasura.GraphQL.Parser.Internal.Parser qualified as IP
|
||||
import Hasura.GraphQL.Schema.Backend
|
||||
import Hasura.GraphQL.Schema.BoolExp
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.OrderBy
|
||||
import Hasura.GraphQL.Schema.Parser
|
||||
( FieldParser,
|
||||
@ -76,6 +75,7 @@ import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.ComputedField
|
||||
import Hasura.RQL.Types.CustomTypes
|
||||
import Hasura.RQL.Types.Metadata.Object
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Permission qualified as Permission
|
||||
import Hasura.RQL.Types.Relationships.Local
|
||||
import Hasura.RQL.Types.Relationships.Remote
|
||||
|
@ -16,7 +16,6 @@ import Hasura.GraphQL.Parser.Class
|
||||
import Hasura.GraphQL.Schema.Backend
|
||||
import Hasura.GraphQL.Schema.BoolExp (AggregationPredicatesSchema)
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Parser
|
||||
( InputFieldsParser,
|
||||
Kind (..),
|
||||
@ -32,6 +31,7 @@ import Hasura.RQL.IR.Select qualified as IR
|
||||
import Hasura.RQL.IR.Value qualified as IR
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.Metadata.Object
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.RQL.Types.SchemaCache
|
||||
import Hasura.RQL.Types.Source
|
||||
|
@ -12,7 +12,6 @@ import Hasura.GraphQL.Schema.Backend (BackendTableSelectSchema (..), BackendUpda
|
||||
import Hasura.GraphQL.Schema.BoolExp (AggregationPredicatesSchema, tableBoolExp)
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.Mutation (mutationSelectionSet, primaryKeysArguments)
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Parser qualified as P
|
||||
import Hasura.GraphQL.Schema.Table (tableColumns)
|
||||
import Hasura.GraphQL.Schema.Typename
|
||||
@ -28,6 +27,7 @@ import Hasura.RQL.Types.Backend (Backend (..))
|
||||
import Hasura.RQL.Types.Column (ColumnInfo (..))
|
||||
import Hasura.RQL.Types.Common (Comment (..))
|
||||
import Hasura.RQL.Types.Metadata.Object
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.RQL.Types.Source
|
||||
import Hasura.RQL.Types.SourceCustomization
|
||||
|
@ -59,12 +59,13 @@ import Data.Word (Word16)
|
||||
import GHC.AssertNF.CPP
|
||||
import GHC.Int (Int64)
|
||||
import Hasura.GraphQL.ParameterizedQueryHash (ParameterizedQueryHash)
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase (..), hasNamingConventionChanged)
|
||||
import Hasura.GraphQL.Schema.NamingCase (hasNamingConventionChanged)
|
||||
import Hasura.GraphQL.Transport.HTTP.Protocol
|
||||
import Hasura.GraphQL.Transport.WebSocket.Protocol
|
||||
import Hasura.Logging qualified as L
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.Common (MetricsConfig (..), SQLGenCtx (..))
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase (..))
|
||||
import Hasura.RQL.Types.SchemaCache
|
||||
import Hasura.Server.Auth (AuthMode, compareAuthMode)
|
||||
import Hasura.Server.Cors (CorsPolicy)
|
||||
@ -157,15 +158,15 @@ $( J.deriveToJSON
|
||||
''WSLog
|
||||
)
|
||||
|
||||
class Monad m => MonadWSLog m where
|
||||
class (Monad m) => MonadWSLog m where
|
||||
-- | Takes WS server log data and logs it
|
||||
-- logWSServer
|
||||
logWSLog :: L.Logger L.Hasura -> WSLog -> m ()
|
||||
|
||||
instance MonadWSLog m => MonadWSLog (ExceptT e m) where
|
||||
instance (MonadWSLog m) => MonadWSLog (ExceptT e m) where
|
||||
logWSLog l ws = lift $ logWSLog l ws
|
||||
|
||||
instance MonadWSLog m => MonadWSLog (ReaderT r m) where
|
||||
instance (MonadWSLog m) => MonadWSLog (ReaderT r m) where
|
||||
logWSLog l ws = lift $ logWSLog l ws
|
||||
|
||||
instance L.ToEngineLog WSLog L.Hasura where
|
||||
@ -213,7 +214,7 @@ closeConn wsConn = closeConnWithCode wsConn 1000 -- 1000 is "normal close"
|
||||
|
||||
-- | Closes a connection with code 1012, which means "Server is restarting"
|
||||
-- good clients will implement a retry logic with a backoff of a few seconds
|
||||
forceConnReconnect :: MonadIO m => WSConn a -> BL.ByteString -> m ()
|
||||
forceConnReconnect :: (MonadIO m) => WSConn a -> BL.ByteString -> m ()
|
||||
forceConnReconnect wsConn bs = liftIO $ closeConnWithCode wsConn 1012 bs
|
||||
|
||||
closeConnWithCode :: WSConn a -> Word16 -> BL.ByteString -> IO ()
|
||||
|
@ -45,7 +45,6 @@ import Hasura.Function.API
|
||||
import Hasura.Function.Cache
|
||||
import Hasura.Function.Metadata (FunctionMetadata (..))
|
||||
import Hasura.GraphQL.Schema (buildGQLContext)
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.Incremental qualified as Inc
|
||||
import Hasura.Logging
|
||||
import Hasura.LogicalModel.Cache (LogicalModelCache, LogicalModelInfo (..))
|
||||
@ -81,6 +80,7 @@ import Hasura.RQL.Types.EventTrigger
|
||||
import Hasura.RQL.Types.Metadata
|
||||
import Hasura.RQL.Types.Metadata.Backend
|
||||
import Hasura.RQL.Types.Metadata.Object
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.OpenTelemetry
|
||||
import Hasura.RQL.Types.QueryCollection
|
||||
import Hasura.RQL.Types.Relationships.Remote
|
||||
|
@ -8,10 +8,10 @@ module Hasura.RQL.DDL.Schema.Cache.Config
|
||||
)
|
||||
where
|
||||
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase)
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.Common (SQLGenCtx)
|
||||
import Hasura.RQL.Types.Metadata (MetadataDefaults)
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.Server.Types
|
||||
|
||||
@ -39,16 +39,16 @@ data CacheStaticConfig = CacheStaticConfig
|
||||
_cscAreStoredProceduresEnabled :: Bool
|
||||
}
|
||||
|
||||
class Monad m => HasCacheStaticConfig m where
|
||||
class (Monad m) => HasCacheStaticConfig m where
|
||||
askCacheStaticConfig :: m CacheStaticConfig
|
||||
|
||||
instance HasCacheStaticConfig m => HasCacheStaticConfig (ReaderT r m) where
|
||||
instance (HasCacheStaticConfig m) => HasCacheStaticConfig (ReaderT r m) where
|
||||
askCacheStaticConfig = lift askCacheStaticConfig
|
||||
|
||||
instance HasCacheStaticConfig m => HasCacheStaticConfig (ExceptT e m) where
|
||||
instance (HasCacheStaticConfig m) => HasCacheStaticConfig (ExceptT e m) where
|
||||
askCacheStaticConfig = lift askCacheStaticConfig
|
||||
|
||||
instance HasCacheStaticConfig m => HasCacheStaticConfig (StateT s m) where
|
||||
instance (HasCacheStaticConfig m) => HasCacheStaticConfig (StateT s m) where
|
||||
askCacheStaticConfig = lift askCacheStaticConfig
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -14,13 +14,13 @@ where
|
||||
|
||||
import Control.Lens.TH (makeLenses)
|
||||
import Data.Kind (Type)
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase)
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.IR.BoolExp
|
||||
import Hasura.RQL.IR.Returning
|
||||
import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
|
||||
data AnnDelG (b :: BackendType) (r :: Type) v = AnnDel
|
||||
{ _adTable :: TableName b,
|
||||
|
@ -43,7 +43,6 @@ where
|
||||
import Control.Lens ((^?))
|
||||
import Control.Lens.TH (makeLenses, makePrisms)
|
||||
import Data.Kind (Type)
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase)
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.IR.BoolExp
|
||||
import Hasura.RQL.IR.Conflict
|
||||
@ -51,6 +50,7 @@ import Hasura.RQL.IR.Returning
|
||||
import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
import Hasura.RQL.Types.Relationships.Local
|
||||
|
||||
-- | Overall representation of an insert mutation, corresponding to one root
|
||||
|
@ -12,7 +12,6 @@ where
|
||||
|
||||
import Data.Bifoldable
|
||||
import Data.Kind (Type)
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase)
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.IR.Select.Args
|
||||
import Hasura.RQL.IR.Select.From
|
||||
@ -20,6 +19,7 @@ import Hasura.RQL.IR.Select.TablePerm
|
||||
import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
import Hasura.RQL.Types.Schema.Options (StringifyNumbers)
|
||||
|
||||
-- Select
|
||||
|
@ -16,13 +16,13 @@ where
|
||||
|
||||
import Control.Lens.TH (makeLenses)
|
||||
import Data.Kind (Type)
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase)
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.IR.BoolExp
|
||||
import Hasura.RQL.IR.Returning
|
||||
import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.Column
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -10,7 +10,6 @@ import Data.Environment qualified as Env
|
||||
import Data.Has (Has)
|
||||
import Hasura.Base.Error
|
||||
import Hasura.Function.Cache
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.Incremental qualified as Inc
|
||||
import Hasura.Logging (Hasura, Logger)
|
||||
import Hasura.LogicalModel.Metadata (LogicalModelMetadata)
|
||||
@ -26,6 +25,7 @@ import Hasura.RQL.Types.ComputedField
|
||||
import Hasura.RQL.Types.EventTrigger
|
||||
import Hasura.RQL.Types.Metadata
|
||||
import Hasura.RQL.Types.Metadata.Object
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
import Hasura.RQL.Types.Relationships.Local
|
||||
import Hasura.RQL.Types.SchemaCache
|
||||
import Hasura.RQL.Types.SchemaCache.Build
|
||||
|
36
server/src-lib/Hasura/RQL/Types/NamingCase.hs
Normal file
36
server/src-lib/Hasura/RQL/Types/NamingCase.hs
Normal file
@ -0,0 +1,36 @@
|
||||
{-# LANGUAGE OverloadedLists #-}
|
||||
|
||||
module Hasura.RQL.Types.NamingCase
|
||||
( NamingCase (..),
|
||||
parseNamingConventionFromText,
|
||||
)
|
||||
where
|
||||
|
||||
import Autodocodec qualified as AC
|
||||
import Data.Aeson qualified as J
|
||||
import Hasura.Prelude
|
||||
|
||||
-- | Represents the different possible type cases for fields and types, i.e.
|
||||
-- @HasuraCase@ and @GraphqlCase@ (@CamelCase@ fields and @PascalCase@ types).
|
||||
data NamingCase = HasuraCase | GraphqlCase
|
||||
deriving (Eq, Show, Generic)
|
||||
|
||||
instance AC.HasCodec NamingCase where
|
||||
codec =
|
||||
AC.named "NamingCase" $
|
||||
AC.stringConstCodec [(HasuraCase, "hasura-default"), (GraphqlCase, "graphql-default")]
|
||||
|
||||
instance J.ToJSON NamingCase where
|
||||
toJSON HasuraCase = J.String "hasura-default"
|
||||
toJSON GraphqlCase = J.String "graphql-default"
|
||||
|
||||
instance J.FromJSON NamingCase where
|
||||
parseJSON = J.withText "NamingCase" $ \s -> case parseNamingConventionFromText s of
|
||||
(Right nc) -> pure nc
|
||||
(Left err) -> fail err
|
||||
|
||||
-- Used for both the environment variable and JSON.
|
||||
parseNamingConventionFromText :: Text -> Either String NamingCase
|
||||
parseNamingConventionFromText "hasura-default" = Right HasuraCase
|
||||
parseNamingConventionFromText "graphql-default" = Right GraphqlCase
|
||||
parseNamingConventionFromText _ = Left "naming_convention can either be \"hasura-default\" or \"graphql-default\""
|
@ -86,11 +86,11 @@ import Data.Text qualified as T
|
||||
import Data.Text.Casing (GQLNameIdentifier (..))
|
||||
import Data.Text.Casing qualified as C
|
||||
import Hasura.Base.Error (Code (NotSupported), QErr, throw400)
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Typename
|
||||
import Hasura.Name qualified as Name
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.Backend (SupportedNamingCase (..))
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase (..))
|
||||
import Hasura.Table.Cache (CustomRootField (..), TableConfig (..), TableCoreInfoG (..), TableInfo (..))
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
|
||||
|
@ -12,8 +12,8 @@ where
|
||||
import Data.Aeson.TH
|
||||
import Data.HashSet qualified as Set
|
||||
import Hasura.GraphQL.Execute.Subscription.Options qualified as ES
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.Server.Auth
|
||||
import Hasura.Server.Auth.JWT
|
||||
|
@ -75,10 +75,10 @@ import Database.PG.Query qualified as Query
|
||||
import Hasura.Backends.Postgres.Connection.MonadTx qualified as MonadTx
|
||||
import Hasura.Cache.Bounded qualified as Bounded
|
||||
import Hasura.GraphQL.Execute.Subscription.Options qualified as Subscription.Options
|
||||
import Hasura.GraphQL.Schema.NamingCase qualified as NC
|
||||
import Hasura.Logging qualified as Logging
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.Metadata (MetadataDefaults, emptyMetadataDefaults)
|
||||
import Hasura.RQL.Types.NamingCase qualified as NC
|
||||
import Hasura.RQL.Types.Roles (RoleName)
|
||||
import Hasura.RQL.Types.Roles qualified as Roles
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
@ -98,7 +98,7 @@ import Witch qualified
|
||||
--------------------------------------------------------------------------------
|
||||
-- Serve Command
|
||||
|
||||
serveCommandParser :: Logging.EnabledLogTypes impl => Opt.Parser (Config.ServeOptionsRaw impl)
|
||||
serveCommandParser :: (Logging.EnabledLogTypes impl) => Opt.Parser (Config.ServeOptionsRaw impl)
|
||||
serveCommandParser =
|
||||
Config.ServeOptionsRaw
|
||||
<$> parseServerPort
|
||||
@ -737,7 +737,7 @@ enableAllowlistOption =
|
||||
Config._helpMessage = "Only accept allowed GraphQL queries"
|
||||
}
|
||||
|
||||
parseEnabledLogs :: forall impl. Logging.EnabledLogTypes impl => Opt.Parser (Maybe (HashSet (Logging.EngineLogType impl)))
|
||||
parseEnabledLogs :: forall impl. (Logging.EnabledLogTypes impl) => Opt.Parser (Maybe (HashSet (Logging.EngineLogType impl)))
|
||||
parseEnabledLogs =
|
||||
Opt.optional $
|
||||
Opt.option
|
||||
@ -746,7 +746,7 @@ parseEnabledLogs =
|
||||
<> Opt.help (Config._helpMessage (enabledLogsOption @impl))
|
||||
)
|
||||
|
||||
enabledLogsOption :: Logging.EnabledLogTypes impl => Config.Option (HashSet (Logging.EngineLogType impl))
|
||||
enabledLogsOption :: (Logging.EnabledLogTypes impl) => Config.Option (HashSet (Logging.EngineLogType impl))
|
||||
enabledLogsOption =
|
||||
Config.Option
|
||||
{ Config._default = Logging.defaultEnabledLogTypes,
|
||||
|
@ -88,11 +88,11 @@ import Data.URL.Template qualified as Template
|
||||
import Database.PG.Query qualified as Query
|
||||
import Hasura.Backends.Postgres.Connection.MonadTx qualified as MonadTx
|
||||
import Hasura.GraphQL.Execute.Subscription.Options qualified as Subscription.Options
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase)
|
||||
import Hasura.Logging qualified as Logging
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.Common qualified as Common
|
||||
import Hasura.RQL.Types.Metadata (MetadataDefaults)
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
import Hasura.RQL.Types.Roles (RoleName, adminRoleName)
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Schema.Options
|
||||
import Hasura.Server.Auth qualified as Auth
|
||||
|
@ -34,11 +34,11 @@ import Hasura.Backends.Postgres.Connection.MonadTx (ExtensionsSchema)
|
||||
import Hasura.Backends.Postgres.Connection.MonadTx qualified as MonadTx
|
||||
import Hasura.Cache.Bounded qualified as Cache
|
||||
import Hasura.GraphQL.Execute.Subscription.Options qualified as Subscription.Options
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase)
|
||||
import Hasura.GraphQL.Schema.NamingCase qualified as NamingCase
|
||||
import Hasura.Logging qualified as Logging
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.Metadata (Metadata, MetadataDefaults (..))
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase)
|
||||
import Hasura.RQL.Types.NamingCase qualified as NamingCase
|
||||
import Hasura.RQL.Types.Roles (RoleName, mkRoleName)
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.Server.Auth qualified as Auth
|
||||
@ -111,12 +111,12 @@ withOptionDefault parsed Config.Option {..} =
|
||||
--
|
||||
-- A 'Monoid' instance would be super valuable to cleanup arg/env
|
||||
-- parsing but this solution feels somewhat unsatisfying.
|
||||
withOptionSwitch :: Monad m => Bool -> Config.Option Bool -> WithEnvT m Bool
|
||||
withOptionSwitch :: (Monad m) => Bool -> Config.Option Bool -> WithEnvT m Bool
|
||||
withOptionSwitch parsed option = withOptionSwitch' parsed (id, id) option
|
||||
|
||||
-- | Given an 'Iso a Bool' we can apply the same boolean env merging
|
||||
-- semantics as we do for 'Bool' in `withOptionsSwitch' to @a@.
|
||||
withOptionSwitch' :: Monad m => a -> (a -> Bool, Bool -> a) -> Config.Option a -> WithEnvT m a
|
||||
withOptionSwitch' :: (Monad m) => a -> (a -> Bool, Bool -> a) -> Config.Option a -> WithEnvT m a
|
||||
withOptionSwitch' parsed (fwd, bwd) option =
|
||||
if fwd parsed
|
||||
then pure (bwd True)
|
||||
@ -177,7 +177,7 @@ instance FromEnv Warp.HostPreference where
|
||||
instance FromEnv Text where
|
||||
fromEnv = Right . Text.pack
|
||||
|
||||
instance FromEnv a => FromEnv (Maybe a) where
|
||||
instance (FromEnv a) => FromEnv (Maybe a) where
|
||||
fromEnv = fmap Just . fromEnv
|
||||
|
||||
instance FromEnv Auth.AuthHookType where
|
||||
@ -332,7 +332,7 @@ instance FromEnv Auth.JWTConfig where
|
||||
instance FromEnv [Auth.JWTConfig] where
|
||||
fromEnv = readJson
|
||||
|
||||
instance Logging.EnabledLogTypes impl => FromEnv (HashSet (Logging.EngineLogType impl)) where
|
||||
instance (Logging.EnabledLogTypes impl) => FromEnv (HashSet (Logging.EngineLogType impl)) where
|
||||
fromEnv = fmap HashSet.fromList . Logging.parseEnabledLogTypes
|
||||
|
||||
instance FromEnv Logging.LogLevel where
|
||||
|
@ -48,7 +48,6 @@ import Hasura.GraphQL.Context
|
||||
import Hasura.GraphQL.Namespace
|
||||
import Hasura.GraphQL.Parser.Name qualified as GName
|
||||
import Hasura.GraphQL.Schema.Common (textToGQLIdentifier)
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.Incremental qualified as Inc
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.DDL.Schema.Cache.Common
|
||||
@ -62,6 +61,7 @@ import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.Metadata
|
||||
import Hasura.RQL.Types.Metadata.Backend
|
||||
import Hasura.RQL.Types.Metadata.Object
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.SchemaCache
|
||||
import Hasura.RQL.Types.SchemaCache.Build
|
||||
import Hasura.RQL.Types.SchemaCacheTypes
|
||||
|
@ -21,7 +21,6 @@ import Hasura.GraphQL.Schema.BoolExp.AggregationPredicates
|
||||
defaultAggregationPredicatesParser,
|
||||
)
|
||||
import Hasura.GraphQL.Schema.Introspection (queryInputFieldsParserIntrospection)
|
||||
import Hasura.GraphQL.Schema.NamingCase (NamingCase (..))
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.IR.BoolExp (GBoolExp (..), OpExpG (AEQ))
|
||||
import Hasura.RQL.IR.BoolExp.AggregationPredicates
|
||||
@ -29,6 +28,7 @@ import Hasura.RQL.IR.Value (Provenance (Unknown), UnpreparedValue (UVParameter))
|
||||
import Hasura.RQL.Types.BackendType (BackendSourceKind (PostgresVanillaKind), BackendType (Postgres), PostgresKind (Vanilla))
|
||||
import Hasura.RQL.Types.Column (ColumnType (ColumnScalar), ColumnValue (..))
|
||||
import Hasura.RQL.Types.Common (InsertOrder (..), RelName (..), RelType (..), SourceName (..))
|
||||
import Hasura.RQL.Types.NamingCase (NamingCase (..))
|
||||
import Hasura.RQL.Types.Relationships.Local (RelInfo (..), RelTarget (..))
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.RQL.Types.Source (DBObjectsIntrospection (..), SourceInfo (..))
|
||||
|
@ -15,10 +15,10 @@ import Data.Time (NominalDiffTime)
|
||||
import Data.URL.Template qualified as Template
|
||||
import Database.PG.Query qualified as PG
|
||||
import Hasura.GraphQL.Execute.Subscription.Options qualified as ES
|
||||
import Hasura.GraphQL.Schema.NamingCase qualified as NC
|
||||
import Hasura.Logging qualified as Logging
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.Metadata (Metadata, MetadataDefaults (..), overrideMetadataDefaults, _metaBackendConfigs)
|
||||
import Hasura.RQL.Types.NamingCase qualified as NC
|
||||
import Hasura.RQL.Types.Roles qualified as Roles
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.SQL.BackendMap qualified as BackendMap
|
||||
|
@ -11,10 +11,10 @@ import Data.HashSet qualified as Set
|
||||
import Data.Time (NominalDiffTime)
|
||||
import Database.PG.Query qualified as Query
|
||||
import Hasura.GraphQL.Execute.Subscription.Options qualified as Subscription.Options
|
||||
import Hasura.GraphQL.Schema.NamingCase qualified as NamingCase
|
||||
import Hasura.Logging (Hasura)
|
||||
import Hasura.Logging qualified as Logging
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.NamingCase qualified as NamingCase
|
||||
import Hasura.RQL.Types.Roles qualified as Roles
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
import Hasura.SQL.Types qualified as MonadTx
|
||||
|
@ -21,7 +21,6 @@ import Hasura.Backends.Postgres.Types.Update (PgUpdateVariant (..), UpdateOpExpr
|
||||
import Hasura.GraphQL.Parser.Internal.Parser (FieldParser (..))
|
||||
import Hasura.GraphQL.Parser.Schema (Definition (..))
|
||||
import Hasura.GraphQL.Parser.Variable (Variable (..))
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.IR.BoolExp (AnnBoolExpFld (..), GBoolExp (..), OpExpG (..))
|
||||
import Hasura.RQL.IR.Returning (MutationOutputG (..))
|
||||
@ -32,6 +31,7 @@ import Hasura.RQL.IR.Value (UnpreparedValue)
|
||||
import Hasura.RQL.Types.BackendType (BackendSourceKind (PostgresVanillaKind), BackendType (Postgres), PostgresKind (Vanilla))
|
||||
import Hasura.RQL.Types.Column (ColumnInfo (..))
|
||||
import Hasura.RQL.Types.Common (SourceName (..))
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Source (DBObjectsIntrospection (..), SourceInfo (..))
|
||||
import Hasura.RQL.Types.SourceCustomization (ResolvedSourceCustomization (..))
|
||||
import Hasura.Table.Cache (TableInfo (..))
|
||||
|
@ -21,10 +21,10 @@ import Hasura.Base.ErrorMessage
|
||||
import Hasura.GraphQL.Parser.Class
|
||||
import Hasura.GraphQL.Parser.ErrorCode
|
||||
import Hasura.GraphQL.Schema.Common
|
||||
import Hasura.GraphQL.Schema.NamingCase
|
||||
import Hasura.GraphQL.Schema.Typename
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.BackendType
|
||||
import Hasura.RQL.Types.NamingCase
|
||||
import Hasura.RQL.Types.Roles (adminRoleName)
|
||||
import Hasura.RQL.Types.Schema.Options (SchemaOptions (..))
|
||||
import Hasura.RQL.Types.Schema.Options qualified as Options
|
||||
@ -35,7 +35,7 @@ import Language.Haskell.TH.Syntax qualified as TH
|
||||
import Test.HUnit.Lang (assertFailure)
|
||||
|
||||
-- | Placeholder value for test inputs that are not relevant yet.
|
||||
notImplementedYet :: HasCallStack => String -> a
|
||||
notImplementedYet :: (HasCallStack) => String -> a
|
||||
notImplementedYet thing =
|
||||
withFrozenCallStack $
|
||||
error $
|
||||
|
Loading…
Reference in New Issue
Block a user