-- | 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.GraphQL.Schema.Action
import Hasura.GraphQL.Schema.Common
import Hasura.GraphQL.Schema.Parser
import Hasura.Prelude
import Hasura.RQL.IR
import Hasura.RQL.Types.Action
import Hasura.RQL.Types.CustomTypes
import Hasura.RQL.Types.Metadata.Object

buildActionQueryFields ::
  (MonadBuildActionSchema r m n) =>
  AnnotatedCustomTypes ->
  ActionInfo ->
  SchemaT r m [FieldParser n (QueryRootField UnpreparedValue)]
buildActionQueryFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildActionSchema r m n =>
AnnotatedCustomTypes
-> ActionInfo
-> SchemaT r m [FieldParser n (QueryRootField UnpreparedValue)]
buildActionQueryFields AnnotatedCustomTypes
customTypes ActionInfo
actionInfo =
  Maybe (FieldParser n (QueryRootField UnpreparedValue))
-> [FieldParser n (QueryRootField UnpreparedValue)]
forall a. Maybe a -> [a]
maybeToList
    (Maybe (FieldParser n (QueryRootField UnpreparedValue))
 -> [FieldParser n (QueryRootField UnpreparedValue)])
-> (Maybe (FieldParser n (QueryRootField UnpreparedValue))
    -> Maybe (FieldParser n (QueryRootField UnpreparedValue)))
-> Maybe (FieldParser n (QueryRootField UnpreparedValue))
-> [FieldParser n (QueryRootField UnpreparedValue)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionInfo
-> Maybe (FieldParser n (QueryRootField UnpreparedValue))
-> Maybe (FieldParser n (QueryRootField UnpreparedValue))
forall (n :: * -> *) a.
ActionInfo -> Maybe (FieldParser n a) -> Maybe (FieldParser n a)
applyActionOrigin ActionInfo
actionInfo
    (Maybe (FieldParser n (QueryRootField UnpreparedValue))
 -> [FieldParser n (QueryRootField UnpreparedValue)])
-> SchemaT
     r m (Maybe (FieldParser n (QueryRootField UnpreparedValue)))
-> SchemaT r m [FieldParser n (QueryRootField UnpreparedValue)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case ActionDefinition
  (GType, AnnotatedInputType) (EnvRecord ResolvedWebhook)
-> ActionType
forall arg webhook. ActionDefinition arg webhook -> ActionType
_adType (ActionInfo
-> ActionDefinition
     (GType, AnnotatedInputType) (EnvRecord ResolvedWebhook)
_aiDefinition ActionInfo
actionInfo) of
      ActionType
ActionQuery ->
        (FieldParser
   MetadataObjId
   n
   (AnnActionExecution (RemoteRelationshipField UnpreparedValue))
 -> FieldParser n (QueryRootField UnpreparedValue))
-> Maybe
     (FieldParser
        MetadataObjId
        n
        (AnnActionExecution (RemoteRelationshipField UnpreparedValue)))
-> Maybe (FieldParser n (QueryRootField UnpreparedValue))
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((AnnActionExecution (RemoteRelationshipField UnpreparedValue)
 -> QueryRootField UnpreparedValue)
-> FieldParser
     MetadataObjId
     n
     (AnnActionExecution (RemoteRelationshipField UnpreparedValue))
-> FieldParser n (QueryRootField UnpreparedValue)
forall a b.
(a -> b)
-> FieldParser MetadataObjId n a -> FieldParser MetadataObjId n b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (QueryActionRoot UnpreparedValue -> QueryRootField UnpreparedValue
forall action (db :: BackendType -> *) remote raw.
action -> RootField db remote action raw
RFAction (QueryActionRoot UnpreparedValue -> QueryRootField UnpreparedValue)
-> (AnnActionExecution (RemoteRelationshipField UnpreparedValue)
    -> QueryActionRoot UnpreparedValue)
-> AnnActionExecution (RemoteRelationshipField UnpreparedValue)
-> QueryRootField UnpreparedValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AnnActionExecution (RemoteRelationshipField UnpreparedValue)
-> QueryActionRoot UnpreparedValue
forall r. AnnActionExecution r -> ActionQuery r
AQQuery)) (Maybe
   (FieldParser
      MetadataObjId
      n
      (AnnActionExecution (RemoteRelationshipField UnpreparedValue)))
 -> Maybe (FieldParser n (QueryRootField UnpreparedValue)))
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           MetadataObjId
           n
           (AnnActionExecution (RemoteRelationshipField UnpreparedValue))))
-> SchemaT
     r m (Maybe (FieldParser n (QueryRootField UnpreparedValue)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AnnotatedCustomTypes
-> ActionInfo
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           MetadataObjId
           n
           (AnnActionExecution (RemoteRelationshipField UnpreparedValue))))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildActionSchema r m n =>
AnnotatedCustomTypes
-> ActionInfo
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           n (AnnActionExecution (RemoteRelationshipField UnpreparedValue))))
actionExecute AnnotatedCustomTypes
customTypes ActionInfo
actionInfo
      ActionMutation ActionMutationKind
ActionSynchronous -> Maybe (FieldParser n (QueryRootField UnpreparedValue))
-> SchemaT
     r m (Maybe (FieldParser n (QueryRootField UnpreparedValue)))
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (FieldParser n (QueryRootField UnpreparedValue))
forall a. Maybe a
Nothing
      ActionMutation ActionMutationKind
ActionAsynchronous ->
        (FieldParser
   MetadataObjId
   n
   (AnnActionAsyncQuery
      ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue))
 -> FieldParser n (QueryRootField UnpreparedValue))
-> Maybe
     (FieldParser
        MetadataObjId
        n
        (AnnActionAsyncQuery
           ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue)))
-> Maybe (FieldParser n (QueryRootField UnpreparedValue))
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((AnnActionAsyncQuery
   ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue)
 -> QueryRootField UnpreparedValue)
-> FieldParser
     MetadataObjId
     n
     (AnnActionAsyncQuery
        ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue))
-> FieldParser n (QueryRootField UnpreparedValue)
forall a b.
(a -> b)
-> FieldParser MetadataObjId n a -> FieldParser MetadataObjId n b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (QueryActionRoot UnpreparedValue -> QueryRootField UnpreparedValue
forall action (db :: BackendType -> *) remote raw.
action -> RootField db remote action raw
RFAction (QueryActionRoot UnpreparedValue -> QueryRootField UnpreparedValue)
-> (AnnActionAsyncQuery
      ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue)
    -> QueryActionRoot UnpreparedValue)
-> AnnActionAsyncQuery
     ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue)
-> QueryRootField UnpreparedValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AnnActionAsyncQuery
  ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue)
-> QueryActionRoot UnpreparedValue
forall r.
AnnActionAsyncQuery ('Postgres 'Vanilla) r -> ActionQuery r
AQAsync)) (Maybe
   (FieldParser
      MetadataObjId
      n
      (AnnActionAsyncQuery
         ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue)))
 -> Maybe (FieldParser n (QueryRootField UnpreparedValue)))
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           MetadataObjId
           n
           (AnnActionAsyncQuery
              ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue))))
-> SchemaT
     r m (Maybe (FieldParser n (QueryRootField UnpreparedValue)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HashMap Name AnnotatedObjectType
-> ActionInfo
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           MetadataObjId
           n
           (AnnActionAsyncQuery
              ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue))))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildActionSchema r m n =>
HashMap Name AnnotatedObjectType
-> ActionInfo
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           n
           (AnnActionAsyncQuery
              ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue))))
actionAsyncQuery (AnnotatedCustomTypes -> HashMap Name AnnotatedObjectType
_actObjectTypes AnnotatedCustomTypes
customTypes) ActionInfo
actionInfo

buildActionMutationFields ::
  (MonadBuildActionSchema r m n) =>
  AnnotatedCustomTypes ->
  ActionInfo ->
  SchemaT r m [FieldParser n (MutationRootField UnpreparedValue)]
buildActionMutationFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildActionSchema r m n =>
AnnotatedCustomTypes
-> ActionInfo
-> SchemaT r m [FieldParser n (MutationRootField UnpreparedValue)]
buildActionMutationFields AnnotatedCustomTypes
customTypes ActionInfo
actionInfo =
  Maybe (FieldParser n (MutationRootField UnpreparedValue))
-> [FieldParser n (MutationRootField UnpreparedValue)]
forall a. Maybe a -> [a]
maybeToList
    (Maybe (FieldParser n (MutationRootField UnpreparedValue))
 -> [FieldParser n (MutationRootField UnpreparedValue)])
-> (Maybe (FieldParser n (MutationRootField UnpreparedValue))
    -> Maybe (FieldParser n (MutationRootField UnpreparedValue)))
-> Maybe (FieldParser n (MutationRootField UnpreparedValue))
-> [FieldParser n (MutationRootField UnpreparedValue)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionInfo
-> Maybe (FieldParser n (MutationRootField UnpreparedValue))
-> Maybe (FieldParser n (MutationRootField UnpreparedValue))
forall (n :: * -> *) a.
ActionInfo -> Maybe (FieldParser n a) -> Maybe (FieldParser n a)
applyActionOrigin ActionInfo
actionInfo
    (Maybe (FieldParser n (MutationRootField UnpreparedValue))
 -> [FieldParser n (MutationRootField UnpreparedValue)])
-> SchemaT
     r m (Maybe (FieldParser n (MutationRootField UnpreparedValue)))
-> SchemaT r m [FieldParser n (MutationRootField UnpreparedValue)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case ActionDefinition
  (GType, AnnotatedInputType) (EnvRecord ResolvedWebhook)
-> ActionType
forall arg webhook. ActionDefinition arg webhook -> ActionType
_adType (ActionInfo
-> ActionDefinition
     (GType, AnnotatedInputType) (EnvRecord ResolvedWebhook)
_aiDefinition ActionInfo
actionInfo) of
      ActionType
ActionQuery -> Maybe (FieldParser n (MutationRootField UnpreparedValue))
-> SchemaT
     r m (Maybe (FieldParser n (MutationRootField UnpreparedValue)))
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (FieldParser n (MutationRootField UnpreparedValue))
forall a. Maybe a
Nothing
      ActionMutation ActionMutationKind
ActionSynchronous ->
        (FieldParser
   MetadataObjId
   n
   (AnnActionExecution (RemoteRelationshipField UnpreparedValue))
 -> FieldParser n (MutationRootField UnpreparedValue))
-> Maybe
     (FieldParser
        MetadataObjId
        n
        (AnnActionExecution (RemoteRelationshipField UnpreparedValue)))
-> Maybe (FieldParser n (MutationRootField UnpreparedValue))
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((AnnActionExecution (RemoteRelationshipField UnpreparedValue)
 -> MutationRootField UnpreparedValue)
-> FieldParser
     MetadataObjId
     n
     (AnnActionExecution (RemoteRelationshipField UnpreparedValue))
-> FieldParser n (MutationRootField UnpreparedValue)
forall a b.
(a -> b)
-> FieldParser MetadataObjId n a -> FieldParser MetadataObjId n b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (MutationActionRoot UnpreparedValue
-> MutationRootField UnpreparedValue
forall action (db :: BackendType -> *) remote raw.
action -> RootField db remote action raw
RFAction (MutationActionRoot UnpreparedValue
 -> MutationRootField UnpreparedValue)
-> (AnnActionExecution (RemoteRelationshipField UnpreparedValue)
    -> MutationActionRoot UnpreparedValue)
-> AnnActionExecution (RemoteRelationshipField UnpreparedValue)
-> MutationRootField UnpreparedValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AnnActionExecution (RemoteRelationshipField UnpreparedValue)
-> MutationActionRoot UnpreparedValue
forall r. AnnActionExecution r -> ActionMutation r
AMSync)) (Maybe
   (FieldParser
      MetadataObjId
      n
      (AnnActionExecution (RemoteRelationshipField UnpreparedValue)))
 -> Maybe (FieldParser n (MutationRootField UnpreparedValue)))
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           MetadataObjId
           n
           (AnnActionExecution (RemoteRelationshipField UnpreparedValue))))
-> SchemaT
     r m (Maybe (FieldParser n (MutationRootField UnpreparedValue)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AnnotatedCustomTypes
-> ActionInfo
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           MetadataObjId
           n
           (AnnActionExecution (RemoteRelationshipField UnpreparedValue))))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildActionSchema r m n =>
AnnotatedCustomTypes
-> ActionInfo
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           n (AnnActionExecution (RemoteRelationshipField UnpreparedValue))))
actionExecute AnnotatedCustomTypes
customTypes ActionInfo
actionInfo
      ActionMutation ActionMutationKind
ActionAsynchronous ->
        (FieldParser MetadataObjId n AnnActionMutationAsync
 -> FieldParser n (MutationRootField UnpreparedValue))
-> Maybe (FieldParser MetadataObjId n AnnActionMutationAsync)
-> Maybe (FieldParser n (MutationRootField UnpreparedValue))
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((AnnActionMutationAsync -> MutationRootField UnpreparedValue)
-> FieldParser MetadataObjId n AnnActionMutationAsync
-> FieldParser n (MutationRootField UnpreparedValue)
forall a b.
(a -> b)
-> FieldParser MetadataObjId n a -> FieldParser MetadataObjId n b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (MutationActionRoot UnpreparedValue
-> MutationRootField UnpreparedValue
forall action (db :: BackendType -> *) remote raw.
action -> RootField db remote action raw
RFAction (MutationActionRoot UnpreparedValue
 -> MutationRootField UnpreparedValue)
-> (AnnActionMutationAsync -> MutationActionRoot UnpreparedValue)
-> AnnActionMutationAsync
-> MutationRootField UnpreparedValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AnnActionMutationAsync -> MutationActionRoot UnpreparedValue
forall r. AnnActionMutationAsync -> ActionMutation r
AMAsync)) (Maybe (FieldParser MetadataObjId n AnnActionMutationAsync)
 -> Maybe (FieldParser n (MutationRootField UnpreparedValue)))
-> SchemaT
     r m (Maybe (FieldParser MetadataObjId n AnnActionMutationAsync))
-> SchemaT
     r m (Maybe (FieldParser n (MutationRootField UnpreparedValue)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HashMap Name AnnotatedInputType
-> ActionInfo
-> SchemaT
     r m (Maybe (FieldParser MetadataObjId n AnnActionMutationAsync))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildActionSchema r m n =>
HashMap Name AnnotatedInputType
-> ActionInfo
-> SchemaT r m (Maybe (FieldParser n AnnActionMutationAsync))
actionAsyncMutation (AnnotatedCustomTypes -> HashMap Name AnnotatedInputType
_actInputTypes AnnotatedCustomTypes
customTypes) ActionInfo
actionInfo

buildActionSubscriptionFields ::
  (MonadBuildActionSchema r m n) =>
  AnnotatedCustomTypes ->
  ActionInfo ->
  SchemaT r m [FieldParser n (QueryRootField UnpreparedValue)]
buildActionSubscriptionFields :: forall r (m :: * -> *) (n :: * -> *).
MonadBuildActionSchema r m n =>
AnnotatedCustomTypes
-> ActionInfo
-> SchemaT r m [FieldParser n (QueryRootField UnpreparedValue)]
buildActionSubscriptionFields AnnotatedCustomTypes
customTypes ActionInfo
actionInfo =
  Maybe (FieldParser n (QueryRootField UnpreparedValue))
-> [FieldParser n (QueryRootField UnpreparedValue)]
forall a. Maybe a -> [a]
maybeToList
    (Maybe (FieldParser n (QueryRootField UnpreparedValue))
 -> [FieldParser n (QueryRootField UnpreparedValue)])
-> (Maybe (FieldParser n (QueryRootField UnpreparedValue))
    -> Maybe (FieldParser n (QueryRootField UnpreparedValue)))
-> Maybe (FieldParser n (QueryRootField UnpreparedValue))
-> [FieldParser n (QueryRootField UnpreparedValue)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionInfo
-> Maybe (FieldParser n (QueryRootField UnpreparedValue))
-> Maybe (FieldParser n (QueryRootField UnpreparedValue))
forall (n :: * -> *) a.
ActionInfo -> Maybe (FieldParser n a) -> Maybe (FieldParser n a)
applyActionOrigin ActionInfo
actionInfo
    (Maybe (FieldParser n (QueryRootField UnpreparedValue))
 -> [FieldParser n (QueryRootField UnpreparedValue)])
-> SchemaT
     r m (Maybe (FieldParser n (QueryRootField UnpreparedValue)))
-> SchemaT r m [FieldParser n (QueryRootField UnpreparedValue)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case ActionDefinition
  (GType, AnnotatedInputType) (EnvRecord ResolvedWebhook)
-> ActionType
forall arg webhook. ActionDefinition arg webhook -> ActionType
_adType (ActionInfo
-> ActionDefinition
     (GType, AnnotatedInputType) (EnvRecord ResolvedWebhook)
_aiDefinition ActionInfo
actionInfo) of
      ActionType
ActionQuery -> Maybe (FieldParser n (QueryRootField UnpreparedValue))
-> SchemaT
     r m (Maybe (FieldParser n (QueryRootField UnpreparedValue)))
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (FieldParser n (QueryRootField UnpreparedValue))
forall a. Maybe a
Nothing
      ActionMutation ActionMutationKind
ActionSynchronous -> Maybe (FieldParser n (QueryRootField UnpreparedValue))
-> SchemaT
     r m (Maybe (FieldParser n (QueryRootField UnpreparedValue)))
forall a. a -> SchemaT r m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (FieldParser n (QueryRootField UnpreparedValue))
forall a. Maybe a
Nothing
      ActionMutation ActionMutationKind
ActionAsynchronous ->
        (FieldParser
   MetadataObjId
   n
   (AnnActionAsyncQuery
      ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue))
 -> FieldParser n (QueryRootField UnpreparedValue))
-> Maybe
     (FieldParser
        MetadataObjId
        n
        (AnnActionAsyncQuery
           ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue)))
-> Maybe (FieldParser n (QueryRootField UnpreparedValue))
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((AnnActionAsyncQuery
   ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue)
 -> QueryRootField UnpreparedValue)
-> FieldParser
     MetadataObjId
     n
     (AnnActionAsyncQuery
        ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue))
-> FieldParser n (QueryRootField UnpreparedValue)
forall a b.
(a -> b)
-> FieldParser MetadataObjId n a -> FieldParser MetadataObjId n b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (QueryActionRoot UnpreparedValue -> QueryRootField UnpreparedValue
forall action (db :: BackendType -> *) remote raw.
action -> RootField db remote action raw
RFAction (QueryActionRoot UnpreparedValue -> QueryRootField UnpreparedValue)
-> (AnnActionAsyncQuery
      ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue)
    -> QueryActionRoot UnpreparedValue)
-> AnnActionAsyncQuery
     ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue)
-> QueryRootField UnpreparedValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AnnActionAsyncQuery
  ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue)
-> QueryActionRoot UnpreparedValue
forall r.
AnnActionAsyncQuery ('Postgres 'Vanilla) r -> ActionQuery r
AQAsync)) (Maybe
   (FieldParser
      MetadataObjId
      n
      (AnnActionAsyncQuery
         ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue)))
 -> Maybe (FieldParser n (QueryRootField UnpreparedValue)))
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           MetadataObjId
           n
           (AnnActionAsyncQuery
              ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue))))
-> SchemaT
     r m (Maybe (FieldParser n (QueryRootField UnpreparedValue)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HashMap Name AnnotatedObjectType
-> ActionInfo
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           MetadataObjId
           n
           (AnnActionAsyncQuery
              ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue))))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildActionSchema r m n =>
HashMap Name AnnotatedObjectType
-> ActionInfo
-> SchemaT
     r
     m
     (Maybe
        (FieldParser
           n
           (AnnActionAsyncQuery
              ('Postgres 'Vanilla) (RemoteRelationshipField UnpreparedValue))))
actionAsyncQuery (AnnotatedCustomTypes -> HashMap Name AnnotatedObjectType
_actObjectTypes AnnotatedCustomTypes
customTypes) ActionInfo
actionInfo

applyActionOrigin ::
  ActionInfo ->
  Maybe (FieldParser n a) ->
  Maybe (FieldParser n a)
applyActionOrigin :: forall (n :: * -> *) a.
ActionInfo -> Maybe (FieldParser n a) -> Maybe (FieldParser n a)
applyActionOrigin ActionInfo
actionInfo = (FieldParser n a -> FieldParser n a)
-> Maybe (FieldParser n a) -> Maybe (FieldParser n a)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (MetadataObjId -> FieldParser n a -> FieldParser n a
forall (m :: * -> *) origin a.
origin -> FieldParser origin m a -> FieldParser origin m a
setFieldParserOrigin (ActionName -> MetadataObjId
MOAction (ActionInfo -> ActionName
_aiName ActionInfo
actionInfo)))