mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-13 19:33:55 +03:00
chore(server): logical models, remove unused arg
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8751 GitOrigin-RevId: fcef0a4b3974206bd0920bd8e4b46af9407b90c0
This commit is contained in:
parent
5677446ff3
commit
cd024dcaa4
@ -9,7 +9,6 @@ where
|
||||
import Data.HashMap.Strict qualified as HM
|
||||
import Hasura.CustomReturnType.Cache (CustomReturnTypeInfo (..))
|
||||
import Hasura.CustomReturnType.IR (CustomReturnType (..))
|
||||
import Hasura.CustomReturnType.Types (CustomReturnTypeName (..))
|
||||
import Hasura.GraphQL.Schema.Backend
|
||||
( BackendCustomReturnTypeSelectSchema (..),
|
||||
MonadBuildSchema,
|
||||
@ -94,8 +93,7 @@ buildCustomReturnTypeFields ::
|
||||
)
|
||||
)
|
||||
buildCustomReturnTypeFields customReturnType = runMaybeT $ do
|
||||
let fieldName = getCustomReturnTypeName (_crtiName customReturnType)
|
||||
selectionSetParser <- MaybeT $ customReturnTypeSelectionList @b @r @m @n fieldName customReturnType
|
||||
customTypesArgsParser <- lift $ customReturnTypeArguments @b @r @m @n fieldName customReturnType
|
||||
selectionSetParser <- MaybeT $ customReturnTypeSelectionList @b @r @m @n customReturnType
|
||||
customTypesArgsParser <- lift $ customReturnTypeArguments @b @r @m @n customReturnType
|
||||
|
||||
pure (selectionSetParser, customTypesArgsParser)
|
||||
|
@ -305,13 +305,11 @@ type ComparisonExp b = OpExpG b (UnpreparedValue b)
|
||||
class Backend b => BackendCustomReturnTypeSelectSchema (b :: BackendType) where
|
||||
customReturnTypeArguments ::
|
||||
MonadBuildSourceSchema b r m n =>
|
||||
G.Name ->
|
||||
CustomReturnTypeInfo b ->
|
||||
SchemaT r m (InputFieldsParser n (IR.SelectArgsG b (UnpreparedValue b)))
|
||||
|
||||
customReturnTypeSelectionSet ::
|
||||
MonadBuildSourceSchema b r m n =>
|
||||
G.Name ->
|
||||
CustomReturnTypeInfo b ->
|
||||
SchemaT r m (Maybe (Parser 'Output n (AnnotatedFields b)))
|
||||
|
||||
|
@ -18,6 +18,7 @@ import Data.Text.Extended
|
||||
import Hasura.Base.Error (throw500)
|
||||
import Hasura.CustomReturnType.Cache (CustomReturnTypeInfo (..))
|
||||
import Hasura.CustomReturnType.Common
|
||||
import Hasura.CustomReturnType.Types (CustomReturnTypeName (..))
|
||||
import Hasura.Function.Cache
|
||||
import Hasura.GraphQL.Parser.Class
|
||||
import Hasura.GraphQL.Schema.Backend
|
||||
@ -177,14 +178,14 @@ customReturnTypeBoolExp ::
|
||||
( MonadBuildSchema b r m n,
|
||||
AggregationPredicatesSchema b
|
||||
) =>
|
||||
G.Name ->
|
||||
CustomReturnTypeInfo b ->
|
||||
SchemaT r m (Parser 'Input n (AnnBoolExp b (UnpreparedValue b)))
|
||||
customReturnTypeBoolExp name customReturnType =
|
||||
customReturnTypeBoolExp customReturnType =
|
||||
case toFieldInfo (_crtiFields customReturnType) of
|
||||
Nothing -> throw500 $ "Error creating fields for custom type " <> tshow (_crtiName customReturnType)
|
||||
Just fieldInfo -> do
|
||||
let gqlName = mkTableBoolExpTypeName (C.fromCustomName name)
|
||||
let name = getCustomReturnTypeName (_crtiName customReturnType)
|
||||
gqlName = mkTableBoolExpTypeName (C.fromCustomName name)
|
||||
|
||||
-- Aggregation parsers let us say things like, "select all authors
|
||||
-- with at least one article": they are predicates based on the
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
module Hasura.GraphQL.Schema.OrderBy
|
||||
( tableOrderByExp,
|
||||
customTypeOrderByExp,
|
||||
customReturnTypeOrderByExp,
|
||||
)
|
||||
where
|
||||
|
||||
@ -12,8 +12,9 @@ import Data.HashMap.Strict.Extended qualified as HashMap
|
||||
import Data.Text.Casing qualified as C
|
||||
import Data.Text.Extended
|
||||
import Hasura.Base.Error
|
||||
import Hasura.CustomReturnType.Cache (CustomReturnTypeInfo (_crtiFields))
|
||||
import Hasura.CustomReturnType.Cache (CustomReturnTypeInfo (_crtiFields, _crtiName))
|
||||
import Hasura.CustomReturnType.Common (toFieldInfo)
|
||||
import Hasura.CustomReturnType.Types (CustomReturnTypeName (..))
|
||||
import Hasura.Function.Cache
|
||||
import Hasura.GraphQL.Parser.Class
|
||||
import Hasura.GraphQL.Schema.Backend
|
||||
@ -65,22 +66,22 @@ orderByOperator tCase sourceInfo = case tCase of
|
||||
-- > coln: order_by
|
||||
-- > obj-rel: <remote-table>_order_by
|
||||
-- > }
|
||||
customTypeOrderByExp ::
|
||||
customReturnTypeOrderByExp ::
|
||||
forall b r m n.
|
||||
( MonadBuildSchema b r m n
|
||||
) =>
|
||||
G.Name ->
|
||||
CustomReturnTypeInfo b ->
|
||||
SchemaT r m (Parser 'Input n [IR.AnnotatedOrderByItemG b (IR.UnpreparedValue b)])
|
||||
customTypeOrderByExp name customReturnType =
|
||||
case toFieldInfo (_crtiFields customReturnType) of
|
||||
Nothing -> throw500 $ "Error creating fields for custom type " <> tshow name
|
||||
Just tableFields -> do
|
||||
let description =
|
||||
G.Description $
|
||||
"Ordering options when selecting data from " <> name <<> "."
|
||||
memoizeKey = name
|
||||
orderByExpInternal (C.fromCustomName name) description tableFields memoizeKey
|
||||
customReturnTypeOrderByExp customReturnType =
|
||||
let name = getCustomReturnTypeName (_crtiName customReturnType)
|
||||
in case toFieldInfo (_crtiFields customReturnType) of
|
||||
Nothing -> throw500 $ "Error creating fields for custom type " <> tshow name
|
||||
Just tableFields -> do
|
||||
let description =
|
||||
G.Description $
|
||||
"Ordering options when selecting data from " <> name <<> "."
|
||||
memoizeKey = name
|
||||
orderByExpInternal (C.fromCustomName name) description tableFields memoizeKey
|
||||
|
||||
-- | Corresponds to an object type for an order by.
|
||||
--
|
||||
|
@ -48,6 +48,7 @@ import Hasura.Backends.Postgres.SQL.Types qualified as Postgres
|
||||
import Hasura.Base.Error
|
||||
import Hasura.Base.ErrorMessage (toErrorMessage)
|
||||
import Hasura.CustomReturnType.Cache (CustomReturnTypeInfo (..))
|
||||
import Hasura.CustomReturnType.Types (CustomReturnTypeName (..))
|
||||
import Hasura.GraphQL.Parser.Class
|
||||
import Hasura.GraphQL.Parser.Internal.Parser qualified as IP
|
||||
import Hasura.GraphQL.Schema.Backend
|
||||
@ -492,10 +493,9 @@ defaultCustomReturnTypeSelectionSet ::
|
||||
forall b r m n.
|
||||
( MonadBuildSchema b r m n
|
||||
) =>
|
||||
G.Name ->
|
||||
CustomReturnTypeInfo b ->
|
||||
SchemaT r m (Maybe (Parser 'Output n (AnnotatedFields b)))
|
||||
defaultCustomReturnTypeSelectionSet name customReturnType = runMaybeT $ do
|
||||
defaultCustomReturnTypeSelectionSet customReturnType = runMaybeT $ do
|
||||
roleName <- retrieve scRole
|
||||
|
||||
selectableColumns <- hoistMaybe $ customReturnTypeColumnsForRole roleName customReturnType
|
||||
@ -520,7 +520,7 @@ defaultCustomReturnTypeSelectionSet name customReturnType = runMaybeT $ do
|
||||
P.selection columnName (G.Description <$> nstDescription) pathArg field
|
||||
<&> IR.mkAnnColumnField column columnType caseBoolExpUnpreparedValue
|
||||
|
||||
let fieldName = name
|
||||
let fieldName = getCustomReturnTypeName (_crtiName customReturnType)
|
||||
|
||||
-- which columns are we allowed to access given permissions?
|
||||
let allowedColumns =
|
||||
@ -541,11 +541,10 @@ defaultCustomReturnTypeSelectionSet name customReturnType = runMaybeT $ do
|
||||
|
||||
customReturnTypeSelectionList ::
|
||||
(MonadBuildSchema b r m n, BackendCustomReturnTypeSelectSchema b) =>
|
||||
G.Name ->
|
||||
CustomReturnTypeInfo b ->
|
||||
SchemaT r m (Maybe (Parser 'Output n (AnnotatedFields b)))
|
||||
customReturnTypeSelectionList name customReturnType =
|
||||
fmap nonNullableObjectList <$> customReturnTypeSelectionSet name customReturnType
|
||||
customReturnTypeSelectionList customReturnType =
|
||||
fmap nonNullableObjectList <$> customReturnTypeSelectionSet customReturnType
|
||||
|
||||
-- | Converts an output type parser from object_type to [object_type!]!
|
||||
nonNullableObjectList :: Parser 'Output m a -> Parser 'Output m a
|
||||
@ -697,11 +696,10 @@ customReturnTypeWhereArg ::
|
||||
( MonadBuildSchema b r m n,
|
||||
AggregationPredicatesSchema b
|
||||
) =>
|
||||
G.Name ->
|
||||
CustomReturnTypeInfo b ->
|
||||
SchemaT r m (InputFieldsParser n (Maybe (IR.AnnBoolExp b (IR.UnpreparedValue b))))
|
||||
customReturnTypeWhereArg name customReturnType = do
|
||||
boolExpParser <- customReturnTypeBoolExp name customReturnType
|
||||
customReturnTypeWhereArg customReturnType = do
|
||||
boolExpParser <- customReturnTypeBoolExp customReturnType
|
||||
pure $
|
||||
fmap join $
|
||||
P.fieldOptional whereName whereDesc $
|
||||
@ -716,12 +714,11 @@ customReturnTypeOrderByArg ::
|
||||
forall b r m n.
|
||||
( MonadBuildSchema b r m n
|
||||
) =>
|
||||
G.Name ->
|
||||
CustomReturnTypeInfo b ->
|
||||
SchemaT r m (InputFieldsParser n (Maybe (NonEmpty (IR.AnnotatedOrderByItemG b (IR.UnpreparedValue b)))))
|
||||
customReturnTypeOrderByArg name customReturnType = do
|
||||
customReturnTypeOrderByArg customReturnType = do
|
||||
tCase <- retrieve $ _rscNamingConvention . _siCustomization @b
|
||||
orderByParser <- customTypeOrderByExp name customReturnType
|
||||
orderByParser <- customReturnTypeOrderByExp customReturnType
|
||||
let orderByName = applyFieldNameCaseCust tCase Name._order_by
|
||||
orderByDesc = Just $ G.Description "sort the rows by one or more columns"
|
||||
pure $ do
|
||||
@ -738,10 +735,11 @@ customReturnTypeDistinctArg ::
|
||||
forall b r m n.
|
||||
( MonadBuildSchema b r m n
|
||||
) =>
|
||||
G.Name ->
|
||||
CustomReturnTypeInfo b ->
|
||||
SchemaT r m (InputFieldsParser n (Maybe (NonEmpty (Column b))))
|
||||
customReturnTypeDistinctArg name customReturnType = do
|
||||
customReturnTypeDistinctArg customReturnType = do
|
||||
let name = getCustomReturnTypeName (_crtiName customReturnType)
|
||||
|
||||
tCase <- retrieve $ _rscNamingConvention . _siCustomization @b
|
||||
|
||||
let maybeColumnDefinitions =
|
||||
@ -1212,13 +1210,12 @@ defaultCustomReturnTypeArgs ::
|
||||
( MonadBuildSchema b r m n,
|
||||
AggregationPredicatesSchema b
|
||||
) =>
|
||||
G.Name ->
|
||||
CustomReturnTypeInfo b ->
|
||||
SchemaT r m (InputFieldsParser n (SelectArgs b))
|
||||
defaultCustomReturnTypeArgs name customReturnType = do
|
||||
whereParser <- customReturnTypeWhereArg name customReturnType
|
||||
orderByParser <- customReturnTypeOrderByArg name customReturnType
|
||||
distinctParser <- customReturnTypeDistinctArg name customReturnType
|
||||
defaultCustomReturnTypeArgs customReturnType = do
|
||||
whereParser <- customReturnTypeWhereArg customReturnType
|
||||
orderByParser <- customReturnTypeOrderByArg customReturnType
|
||||
distinctParser <- customReturnTypeDistinctArg customReturnType
|
||||
|
||||
defaultArgsParser whereParser orderByParser distinctParser
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user