mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 13:02:11 +03:00
4b0f5f09c9
GJ IR changes cherry-picked from the original GJ branch. There is a separate (can be merged independently) PR for metadata changes (#1727) and there will be a different PR upcoming PR for execution changes. https://github.com/hasura/graphql-engine-mono/pull/1810 Co-authored-by: Vamshi Surabhi <6562944+0x777@users.noreply.github.com> GitOrigin-RevId: c31956af29dc9c9b75d002aba7d93c230697c5f4
55 lines
2.2 KiB
Haskell
55 lines
2.2 KiB
Haskell
-- | Postgres-specific schema combinators. Those should be moved to
|
|
-- the corresponding instance of `BackendSchema`, when actions are
|
|
-- generalized.
|
|
module Hasura.GraphQL.Schema.Postgres
|
|
( buildActionQueryFields
|
|
, buildActionSubscriptionFields
|
|
, buildActionMutationFields
|
|
) where
|
|
|
|
import Hasura.Prelude
|
|
|
|
import Hasura.GraphQL.Parser hiding (EnumValueInfo, field)
|
|
import Hasura.GraphQL.Schema.Action
|
|
import Hasura.GraphQL.Schema.Backend (MonadBuildSchema)
|
|
import Hasura.RQL.IR
|
|
import Hasura.RQL.Types
|
|
|
|
|
|
buildActionQueryFields
|
|
:: MonadBuildSchema ('Postgres 'Vanilla) r m n
|
|
=> NonObjectTypeMap
|
|
-> ActionInfo
|
|
-> m [FieldParser n (QueryRootField UnpreparedValue)]
|
|
buildActionQueryFields nonObjectCustomTypes actionInfo =
|
|
maybeToList <$> case _adType (_aiDefinition actionInfo) of
|
|
ActionQuery ->
|
|
fmap (fmap (RFAction . AQQuery)) <$> actionExecute nonObjectCustomTypes actionInfo
|
|
ActionMutation ActionSynchronous -> pure Nothing
|
|
ActionMutation ActionAsynchronous ->
|
|
fmap (fmap (RFAction . AQAsync)) <$> actionAsyncQuery actionInfo
|
|
|
|
buildActionMutationFields
|
|
:: MonadBuildSchema ('Postgres 'Vanilla) r m n
|
|
=> NonObjectTypeMap
|
|
-> ActionInfo
|
|
-> m [FieldParser n (MutationRootField UnpreparedValue)]
|
|
buildActionMutationFields nonObjectCustomTypes actionInfo =
|
|
maybeToList <$> case _adType (_aiDefinition actionInfo) of
|
|
ActionQuery -> pure Nothing
|
|
ActionMutation ActionSynchronous ->
|
|
fmap (fmap (RFAction . AMSync)) <$> actionExecute nonObjectCustomTypes actionInfo
|
|
ActionMutation ActionAsynchronous ->
|
|
fmap (fmap (RFAction . AMAsync)) <$> actionAsyncMutation nonObjectCustomTypes actionInfo
|
|
|
|
buildActionSubscriptionFields
|
|
:: MonadBuildSchema ('Postgres 'Vanilla) r m n
|
|
=> ActionInfo
|
|
-> m [FieldParser n (QueryRootField UnpreparedValue)]
|
|
buildActionSubscriptionFields actionInfo =
|
|
maybeToList <$> case _adType (_aiDefinition actionInfo) of
|
|
ActionQuery -> pure Nothing
|
|
ActionMutation ActionSynchronous -> pure Nothing
|
|
ActionMutation ActionAsynchronous ->
|
|
fmap (fmap (RFAction . AQAsync)) <$> actionAsyncQuery actionInfo
|