mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
server: fix missing/wrong graphql-default
field name transformations
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4927 GitOrigin-RevId: 02dc61f05e06f46c193be3685abbef9c8535edef
This commit is contained in:
parent
edcbe129a7
commit
680cf5b3c0
@ -338,22 +338,22 @@ orderByOperators ::
|
||||
orderByOperators tCase =
|
||||
(Name._order_by,) $
|
||||
NE.fromList
|
||||
[ ( define (applyFieldNameCaseCust tCase Name._asc) "in ascending order, nulls last",
|
||||
[ ( define (applyEnumValueCase tCase Name._asc) "in ascending order, nulls last",
|
||||
(PG.OTAsc, PG.NLast)
|
||||
),
|
||||
( define (applyFieldNameCaseCust tCase Name._asc_nulls_first) "in ascending order, nulls first",
|
||||
( define (applyEnumValueCase tCase Name._asc_nulls_first) "in ascending order, nulls first",
|
||||
(PG.OTAsc, PG.NFirst)
|
||||
),
|
||||
( define (applyFieldNameCaseCust tCase Name._asc_nulls_last) "in ascending order, nulls last",
|
||||
( define (applyEnumValueCase tCase Name._asc_nulls_last) "in ascending order, nulls last",
|
||||
(PG.OTAsc, PG.NLast)
|
||||
),
|
||||
( define (applyFieldNameCaseCust tCase Name._desc) "in descending order, nulls first",
|
||||
( define (applyEnumValueCase tCase Name._desc) "in descending order, nulls first",
|
||||
(PG.OTDesc, PG.NFirst)
|
||||
),
|
||||
( define (applyFieldNameCaseCust tCase Name._desc_nulls_first) "in descending order, nulls first",
|
||||
( define (applyEnumValueCase tCase Name._desc_nulls_first) "in descending order, nulls first",
|
||||
(PG.OTDesc, PG.NFirst)
|
||||
),
|
||||
( define (applyFieldNameCaseCust tCase Name._desc_nulls_last) "in descending order, nulls last",
|
||||
( define (applyEnumValueCase tCase Name._desc_nulls_last) "in descending order, nulls last",
|
||||
(PG.OTDesc, PG.NLast)
|
||||
)
|
||||
]
|
||||
@ -388,8 +388,8 @@ comparisonExps = memoize 'comparisonExps \columnType -> do
|
||||
lqueryParser <- columnParser (ColumnScalar PGLquery) (G.Nullability False)
|
||||
-- `ltxtquery` represents a full-text-search-like pattern for matching `ltree` values.
|
||||
ltxtqueryParser <- columnParser (ColumnScalar PGLtxtquery) (G.Nullability False)
|
||||
maybeCastParser <- castExp columnType
|
||||
tCase <- asks getter
|
||||
maybeCastParser <- castExp columnType tCase
|
||||
let name = applyTypeNameCaseCust tCase $ P.getName typedParser <> Name.__comparison_exp
|
||||
desc =
|
||||
G.Description $
|
||||
@ -675,8 +675,8 @@ comparisonExps = memoize 'comparisonExps \columnType -> do
|
||||
(ColumnScalar $ PG.PGArray scalarType)
|
||||
(PG.PGValArray $ cvValue <$> columnValues)
|
||||
|
||||
castExp :: ColumnType ('Postgres pgKind) -> m (Maybe (Parser 'Input n (CastExp ('Postgres pgKind) (IR.UnpreparedValue ('Postgres pgKind)))))
|
||||
castExp sourceType = do
|
||||
castExp :: ColumnType ('Postgres pgKind) -> NamingCase -> m (Maybe (Parser 'Input n (CastExp ('Postgres pgKind) (IR.UnpreparedValue ('Postgres pgKind)))))
|
||||
castExp sourceType tCase = do
|
||||
let maybeScalars = case sourceType of
|
||||
ColumnScalar PGGeography -> Just (PGGeography, PGGeometry)
|
||||
ColumnScalar PGGeometry -> Just (PGGeometry, PGGeography)
|
||||
@ -684,10 +684,11 @@ comparisonExps = memoize 'comparisonExps \columnType -> do
|
||||
_ -> Nothing
|
||||
|
||||
forM maybeScalars $ \(sourceScalar, targetScalar) -> do
|
||||
sourceName <- mkScalarTypeName sourceScalar <&> (<> Name.__cast_exp)
|
||||
scalarTypeName <- C.fromName <$> mkScalarTypeName sourceScalar
|
||||
targetName <- mkScalarTypeName targetScalar
|
||||
targetOpExps <- comparisonExps $ ColumnScalar targetScalar
|
||||
let field = P.fieldOptional targetName Nothing $ (targetScalar,) <$> targetOpExps
|
||||
sourceName = applyTypeNameCaseIdentifier tCase (scalarTypeName <> (C.fromTuple $$(G.litGQLIdentifier ["cast", "exp"])))
|
||||
pure $ P.object sourceName Nothing $ M.fromList . maybeToList <$> field
|
||||
|
||||
geographyWithinDistanceInput ::
|
||||
|
@ -7,6 +7,7 @@ module Hasura.GraphQL.Schema.OrderBy
|
||||
where
|
||||
|
||||
import Data.Has
|
||||
import Data.Text.Casing qualified as C
|
||||
import Data.Text.Extended
|
||||
import Hasura.GraphQL.Parser.Class
|
||||
import Hasura.GraphQL.Schema.Backend
|
||||
@ -99,7 +100,7 @@ orderByExp sourceInfo tableInfo = memoizeOn 'orderByExp (_siName sourceInfo, tab
|
||||
otherTableOrderBy <- join <$> P.fieldOptional fieldName Nothing (P.nullable otherTableParser)
|
||||
pure $ fmap (map $ fmap $ IR.AOCObjectRelation relationshipInfo newPerms) otherTableOrderBy
|
||||
ArrRel -> do
|
||||
let aggregateFieldName = fieldName <> Name.__aggregate
|
||||
let aggregateFieldName = applyFieldNameCaseIdentifier tCase $ C.fromTuple (fieldName, [G.convertNameToSuffix Name._aggregate])
|
||||
aggregationParser <- lift $ orderByAggregation sourceInfo remoteTableInfo
|
||||
pure $ do
|
||||
aggregationOrderBy <- join <$> P.fieldOptional aggregateFieldName Nothing (P.nullable aggregationParser)
|
||||
@ -123,7 +124,7 @@ orderByExp sourceInfo tableInfo = memoizeOn 'orderByExp (_siName sourceInfo, tab
|
||||
(orderByOperator @b tCase sourceInfo)
|
||||
<&> fmap (pure . mkOrderByItemG @b (IR.AOCComputedField computedFieldOrderBy)) . join
|
||||
ReturnsTable table -> do
|
||||
let aggregateFieldName = fieldName <> Name.__aggregate
|
||||
let aggregateFieldName = applyFieldNameCaseIdentifier tCase $ C.fromTuple (fieldName, [G.convertNameToSuffix Name._aggregate])
|
||||
tableInfo' <- askTableInfo sourceInfo table
|
||||
perms <- MaybeT $ tableSelectPermissions tableInfo'
|
||||
let newPerms = fmap partialSQLExpToUnpreparedValue <$> spiFilter perms
|
||||
@ -238,7 +239,7 @@ orderByOperator' ::
|
||||
Parser 'Both n (Maybe (BasicOrderType b, NullsOrderType b))
|
||||
orderByOperator' tCase sourceInfo =
|
||||
let (sourcePrefix, orderOperators) = orderByOperators @b sourceInfo tCase
|
||||
in P.nullable $ P.enum (applyFieldNameCaseCust tCase sourcePrefix) (Just "column ordering options") $ orderOperators
|
||||
in P.nullable $ P.enum (applyTypeNameCaseCust tCase sourcePrefix) (Just "column ordering options") $ orderOperators
|
||||
|
||||
mkOrderByItemG :: forall b a. a -> (BasicOrderType b, NullsOrderType b) -> IR.OrderByItemG b a
|
||||
mkOrderByItemG column (orderType, nullsOrder) =
|
||||
|
@ -7,6 +7,7 @@ import Control.Lens
|
||||
import Data.Has
|
||||
import Data.HashMap.Strict.Extended qualified as Map
|
||||
import Data.List.NonEmpty qualified as NE
|
||||
import Data.Text.Casing qualified as C
|
||||
import Data.Text.Extended
|
||||
import Hasura.Base.Error
|
||||
import Hasura.GraphQL.Schema.Backend
|
||||
@ -29,7 +30,7 @@ import Hasura.RQL.Types.RemoteSchema
|
||||
import Hasura.RQL.Types.ResultCustomization
|
||||
import Hasura.RQL.Types.SchemaCache hiding (askTableInfo)
|
||||
import Hasura.RQL.Types.Source
|
||||
import Hasura.RQL.Types.SourceCustomization (NamingCase (..), mkCustomizedTypename)
|
||||
import Hasura.RQL.Types.SourceCustomization
|
||||
import Hasura.SQL.AnyBackend
|
||||
import Hasura.Session
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
@ -182,6 +183,7 @@ remoteRelationshipToSourceField ::
|
||||
m [FieldParser n (IR.RemoteSourceSelect (IR.RemoteRelationshipField IR.UnpreparedValue) IR.UnpreparedValue tgt)]
|
||||
remoteRelationshipToSourceField sourceCache RemoteSourceFieldInfo {..} =
|
||||
P.withTypenameCustomization (mkCustomizedTypename (Just _rsfiSourceCustomization) HasuraCase) do
|
||||
tCase <- asks getter
|
||||
sourceInfo <-
|
||||
onNothing (unsafeSourceInfo @tgt =<< Map.lookup _rsfiSource sourceCache) $
|
||||
throw500 $ "source not found " <> dquote _rsfiSource
|
||||
@ -202,7 +204,7 @@ remoteRelationshipToSourceField sourceCache RemoteSourceFieldInfo {..} =
|
||||
IR.SourceRelationshipObject $
|
||||
IR.AnnObjectSelectG fields _rsfiTable $ IR._tpFilter $ tablePermissionsInfo tablePerms
|
||||
ArrRel -> do
|
||||
let aggFieldName = fieldName <> Name.__aggregate
|
||||
let aggFieldName = applyFieldNameCaseIdentifier tCase $ C.fromTuple (fieldName, [G.convertNameToSuffix Name._aggregate])
|
||||
selectionSetParser <- selectTable sourceInfo tableInfo fieldName Nothing
|
||||
aggSelectionSetParser <- selectTableAggregate sourceInfo tableInfo aggFieldName Nothing
|
||||
pure $
|
||||
|
Loading…
Reference in New Issue
Block a user