module Hasura.GraphQL.Execute.Mutation
( convertMutationSelectionSet,
)
where
import Data.Environment qualified as Env
import Data.HashMap.Strict qualified as Map
import Data.HashMap.Strict.InsOrd qualified as OMap
import Data.Tagged qualified as Tagged
import Hasura.Base.Error
import Hasura.GraphQL.Context
import Hasura.GraphQL.Execute.Action
import Hasura.GraphQL.Execute.Backend
import Hasura.GraphQL.Execute.Common
import Hasura.GraphQL.Execute.Instances ()
import Hasura.GraphQL.Execute.Remote
import Hasura.GraphQL.Execute.RemoteJoin.Collect qualified as RJ
import Hasura.GraphQL.Execute.Resolve
import Hasura.GraphQL.Namespace
import Hasura.GraphQL.ParameterizedQueryHash
import Hasura.GraphQL.Parser.Directives
import Hasura.GraphQL.Schema.Parser (runParse, toQErr)
import Hasura.GraphQL.Transport.HTTP.Protocol qualified as GH
import Hasura.Logging qualified as L
import Hasura.Metadata.Class
import Hasura.Prelude
import Hasura.QueryTags
import Hasura.RQL.IR
import Hasura.RQL.Types.Action
import Hasura.RQL.Types.Backend
import Hasura.RQL.Types.Common
import Hasura.RQL.Types.GraphqlSchemaIntrospection
import Hasura.SQL.AnyBackend qualified as AB
import Hasura.Server.Types (RequestId (..))
import Hasura.Session
import Hasura.Tracing qualified as Tracing
import Language.GraphQL.Draft.Syntax qualified as G
import Network.HTTP.Client qualified as HTTP
import Network.HTTP.Types qualified as HTTP
convertMutationAction ::
( MonadIO m,
MonadError QErr m,
MonadMetadataStorage (MetadataStorageT m)
) =>
Env.Environment ->
L.Logger L.Hasura ->
UserInfo ->
HTTP.Manager ->
HTTP.RequestHeaders ->
Maybe GH.GQLQueryText ->
ActionMutation Void ->
m ActionExecutionPlan
convertMutationAction :: Environment
-> Logger Hasura
-> UserInfo
-> Manager
-> RequestHeaders
-> Maybe GQLQueryText
-> ActionMutation Void
-> m ActionExecutionPlan
convertMutationAction Environment
env Logger Hasura
logger UserInfo
userInfo Manager
manager RequestHeaders
reqHeaders Maybe GQLQueryText
gqlQueryText = \case
AMSync AnnActionExecution Void
s -> ActionExecutionPlan -> m ActionExecutionPlan
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ActionExecutionPlan -> m ActionExecutionPlan)
-> ActionExecutionPlan -> m ActionExecutionPlan
forall a b. (a -> b) -> a -> b
$ ActionExecution -> ActionExecutionPlan
AEPSync (ActionExecution -> ActionExecutionPlan)
-> ActionExecution -> ActionExecutionPlan
forall a b. (a -> b) -> a -> b
$ Environment
-> Logger Hasura
-> UserInfo
-> AnnActionExecution Void
-> ActionExecContext
-> Maybe GQLQueryText
-> ActionExecution
resolveActionExecution Environment
env Logger Hasura
logger UserInfo
userInfo AnnActionExecution Void
s ActionExecContext
actionExecContext Maybe GQLQueryText
gqlQueryText
AMAsync AnnActionMutationAsync
s ->
ActionId -> ActionExecutionPlan
AEPAsyncMutation
(ActionId -> ActionExecutionPlan)
-> m ActionId -> m ActionExecutionPlan
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (Either QErr ActionId) -> m ActionId
forall e (m :: * -> *) a. MonadError e m => m (Either e a) -> m a
liftEitherM (MetadataStorageT m ActionId -> m (Either QErr ActionId)
forall (m :: * -> *) a. MetadataStorageT m a -> m (Either QErr a)
runMetadataStorageT (MetadataStorageT m ActionId -> m (Either QErr ActionId))
-> MetadataStorageT m ActionId -> m (Either QErr ActionId)
forall a b. (a -> b) -> a -> b
$ AnnActionMutationAsync
-> RequestHeaders
-> SessionVariables
-> MetadataStorageT m ActionId
forall (m :: * -> *).
MonadMetadataStorage m =>
AnnActionMutationAsync
-> RequestHeaders -> SessionVariables -> m ActionId
resolveActionMutationAsync AnnActionMutationAsync
s RequestHeaders
reqHeaders SessionVariables
userSession)
where
userSession :: SessionVariables
userSession = UserInfo -> SessionVariables
_uiSession UserInfo
userInfo
actionExecContext :: ActionExecContext
actionExecContext = Manager -> RequestHeaders -> SessionVariables -> ActionExecContext
ActionExecContext Manager
manager RequestHeaders
reqHeaders (SessionVariables -> ActionExecContext)
-> SessionVariables -> ActionExecContext
forall a b. (a -> b) -> a -> b
$ UserInfo -> SessionVariables
_uiSession UserInfo
userInfo
convertMutationSelectionSet ::
forall m.
( Tracing.MonadTrace m,
MonadIO m,
MonadError QErr m,
MonadMetadataStorage (MetadataStorageT m),
MonadGQLExecutionCheck m,
MonadQueryTags m
) =>
Env.Environment ->
L.Logger L.Hasura ->
GQLContext ->
SQLGenCtx ->
UserInfo ->
HTTP.Manager ->
HTTP.RequestHeaders ->
[G.Directive G.Name] ->
G.SelectionSet G.NoFragments G.Name ->
[G.VariableDefinition] ->
GH.GQLReqUnparsed ->
SetGraphqlIntrospectionOptions ->
RequestId ->
Maybe G.Name ->
m (ExecutionPlan, ParameterizedQueryHash)
convertMutationSelectionSet :: Environment
-> Logger Hasura
-> GQLContext
-> SQLGenCtx
-> UserInfo
-> Manager
-> RequestHeaders
-> [Directive Name]
-> SelectionSet NoFragments Name
-> [VariableDefinition]
-> GQLReqUnparsed
-> SetGraphqlIntrospectionOptions
-> RequestId
-> Maybe Name
-> m (ExecutionPlan, ParameterizedQueryHash)
convertMutationSelectionSet
Environment
env
Logger Hasura
logger
GQLContext
gqlContext
SQLGenCtx {StringifyNumbers
stringifyNum :: SQLGenCtx -> StringifyNumbers
stringifyNum :: StringifyNumbers
stringifyNum}
UserInfo
userInfo
Manager
manager
RequestHeaders
reqHeaders
[Directive Name]
directives
SelectionSet NoFragments Name
fields
[VariableDefinition]
varDefs
GQLReqUnparsed
gqlUnparsed
SetGraphqlIntrospectionOptions
introspectionDisabledRoles
RequestId
reqId
Maybe Name
maybeOperationName = do
ParserFn (RootFieldMap (MutationRootField UnpreparedValue))
mutationParser <-
Maybe (ParserFn (RootFieldMap (MutationRootField UnpreparedValue)))
-> m (ParserFn (RootFieldMap (MutationRootField UnpreparedValue)))
-> m (ParserFn (RootFieldMap (MutationRootField UnpreparedValue)))
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
onNothing (GQLContext
-> Maybe
(ParserFn (RootFieldMap (MutationRootField UnpreparedValue)))
gqlMutationParser GQLContext
gqlContext) (m (ParserFn (RootFieldMap (MutationRootField UnpreparedValue)))
-> m (ParserFn (RootFieldMap (MutationRootField UnpreparedValue))))
-> m (ParserFn (RootFieldMap (MutationRootField UnpreparedValue)))
-> m (ParserFn (RootFieldMap (MutationRootField UnpreparedValue)))
forall a b. (a -> b) -> a -> b
$
Code
-> Text
-> m (ParserFn (RootFieldMap (MutationRootField UnpreparedValue)))
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
ValidationFailed Text
"no mutations exist"
([Directive Variable]
resolvedDirectives, SelectionSet NoFragments Variable
resolvedSelSet) <- [VariableDefinition]
-> VariableValues
-> [Directive Name]
-> SelectionSet NoFragments Name
-> m ([Directive Variable], SelectionSet NoFragments Variable)
forall (m :: * -> *) (fragments :: * -> *).
(MonadError QErr m, Traversable fragments) =>
[VariableDefinition]
-> VariableValues
-> [Directive Name]
-> SelectionSet fragments Name
-> m ([Directive Variable], SelectionSet fragments Variable)
resolveVariables [VariableDefinition]
varDefs (VariableValues -> Maybe VariableValues -> VariableValues
forall a. a -> Maybe a -> a
fromMaybe VariableValues
forall k v. HashMap k v
Map.empty (GQLReqUnparsed -> Maybe VariableValues
forall a. GQLReq a -> Maybe VariableValues
GH._grVariables GQLReqUnparsed
gqlUnparsed)) [Directive Name]
directives SelectionSet NoFragments Name
fields
RootFieldMap (MutationRootField UnpreparedValue)
unpreparedQueries ::
RootFieldMap (MutationRootField UnpreparedValue) <-
Either QErr (RootFieldMap (MutationRootField UnpreparedValue))
-> m (RootFieldMap (MutationRootField UnpreparedValue))
forall e (m :: * -> *) a. MonadError e m => Either e a -> m a
liftEither (Either QErr (RootFieldMap (MutationRootField UnpreparedValue))
-> m (RootFieldMap (MutationRootField UnpreparedValue)))
-> Either QErr (RootFieldMap (MutationRootField UnpreparedValue))
-> m (RootFieldMap (MutationRootField UnpreparedValue))
forall a b. (a -> b) -> a -> b
$ ParserFn (RootFieldMap (MutationRootField UnpreparedValue))
mutationParser SelectionSet NoFragments Variable
resolvedSelSet
DirectiveMap
_dirMap <- Either ParseError DirectiveMap -> m DirectiveMap
forall (m :: * -> *) a.
MonadError QErr m =>
Either ParseError a -> m a
toQErr (Either ParseError DirectiveMap -> m DirectiveMap)
-> Either ParseError DirectiveMap -> m DirectiveMap
forall a b. (a -> b) -> a -> b
$ Parse DirectiveMap -> Either ParseError DirectiveMap
forall (m :: * -> *) a. MonadError ParseError m => Parse a -> m a
runParse ([Directive Any Parse]
-> DirectiveLocation -> [Directive Variable] -> Parse DirectiveMap
forall origin (m :: * -> *).
MonadParse m =>
[Directive origin m]
-> DirectiveLocation -> [Directive Variable] -> m DirectiveMap
parseDirectives [Directive Any Parse]
forall (m :: * -> *) origin. MonadParse m => [Directive origin m]
customDirectives (ExecutableDirectiveLocation -> DirectiveLocation
G.DLExecutable ExecutableDirectiveLocation
G.EDLMUTATION) [Directive Variable]
resolvedDirectives)
let parameterizedQueryHash :: ParameterizedQueryHash
parameterizedQueryHash = SelectionSet NoFragments Variable -> ParameterizedQueryHash
calculateParameterizedQueryHash SelectionSet NoFragments Variable
resolvedSelSet
resolveExecutionSteps :: RootFieldAlias
-> MutationRootField UnpreparedValue -> m ExecutionStep
resolveExecutionSteps RootFieldAlias
rootFieldName MutationRootField UnpreparedValue
rootFieldUnpreparedValue = do
case MutationRootField UnpreparedValue
rootFieldUnpreparedValue of
RFDB SourceName
sourceName AnyBackend
(SourceConfigWith
(MutationDBRoot
(RemoteRelationshipField UnpreparedValue) UnpreparedValue))
exists ->
AnyBackend
(SourceConfigWith
(MutationDBRoot
(RemoteRelationshipField UnpreparedValue) UnpreparedValue))
-> (forall (b :: BackendType).
BackendExecute b =>
SourceConfigWith
(MutationDBRoot
(RemoteRelationshipField UnpreparedValue) UnpreparedValue)
b
-> m ExecutionStep)
-> m ExecutionStep
forall (c :: BackendType -> Constraint) (i :: BackendType -> *) r.
AllBackendsSatisfy c =>
AnyBackend i -> (forall (b :: BackendType). c b => i b -> r) -> r
AB.dispatchAnyBackend @BackendExecute
AnyBackend
(SourceConfigWith
(MutationDBRoot
(RemoteRelationshipField UnpreparedValue) UnpreparedValue))
exists
\(SourceConfigWith (sourceConfig :: SourceConfig b) Maybe QueryTagsConfig
queryTagsConfig (MDBR db)) -> do
let mutationQueryTagsAttributes :: QueryTagsAttributes
mutationQueryTagsAttributes = QueryTags -> QueryTagsAttributes
encodeQueryTags (QueryTags -> QueryTagsAttributes)
-> QueryTags -> QueryTagsAttributes
forall a b. (a -> b) -> a -> b
$ MutationMetadata -> QueryTags
QTMutation (MutationMetadata -> QueryTags) -> MutationMetadata -> QueryTags
forall a b. (a -> b) -> a -> b
$ RequestId
-> Maybe Name
-> RootFieldAlias
-> ParameterizedQueryHash
-> MutationMetadata
MutationMetadata RequestId
reqId Maybe Name
maybeOperationName RootFieldAlias
rootFieldName ParameterizedQueryHash
parameterizedQueryHash
queryTagsComment :: QueryTagsComment
queryTagsComment = Tagged m QueryTagsComment -> QueryTagsComment
forall k (s :: k) b. Tagged s b -> b
Tagged.untag (Tagged m QueryTagsComment -> QueryTagsComment)
-> Tagged m QueryTagsComment -> QueryTagsComment
forall a b. (a -> b) -> a -> b
$ QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
forall (m :: * -> *).
MonadQueryTags m =>
QueryTagsAttributes
-> Maybe QueryTagsConfig -> Tagged m QueryTagsComment
createQueryTags @m QueryTagsAttributes
mutationQueryTagsAttributes Maybe QueryTagsConfig
queryTagsConfig
(MutationDB b Void (UnpreparedValue b)
noRelsDBAST, Maybe RemoteJoins
remoteJoins) = MutationDB
b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
-> (MutationDB b Void (UnpreparedValue b), Maybe RemoteJoins)
forall (b :: BackendType).
Backend b =>
MutationDB
b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
-> (MutationDB b Void (UnpreparedValue b), Maybe RemoteJoins)
RJ.getRemoteJoinsMutationDB MutationDB
b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
db
DBStepInfo b
dbStepInfo <- (ReaderT QueryTagsComment m (DBStepInfo b)
-> QueryTagsComment -> m (DBStepInfo b))
-> QueryTagsComment
-> ReaderT QueryTagsComment m (DBStepInfo b)
-> m (DBStepInfo b)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ReaderT QueryTagsComment m (DBStepInfo b)
-> QueryTagsComment -> m (DBStepInfo b)
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT QueryTagsComment
queryTagsComment (ReaderT QueryTagsComment m (DBStepInfo b) -> m (DBStepInfo b))
-> ReaderT QueryTagsComment m (DBStepInfo b) -> m (DBStepInfo b)
forall a b. (a -> b) -> a -> b
$ UserInfo
-> StringifyNumbers
-> SourceName
-> SourceConfig b
-> MutationDB b Void (UnpreparedValue b)
-> ReaderT QueryTagsComment m (DBStepInfo b)
forall (b :: BackendType) (m :: * -> *).
(BackendExecute b, MonadError QErr m, MonadQueryTags m,
MonadReader QueryTagsComment m) =>
UserInfo
-> StringifyNumbers
-> SourceName
-> SourceConfig b
-> MutationDB b Void (UnpreparedValue b)
-> m (DBStepInfo b)
mkDBMutationPlan @b UserInfo
userInfo StringifyNumbers
stringifyNum SourceName
sourceName SourceConfig b
sourceConfig MutationDB b Void (UnpreparedValue b)
noRelsDBAST
ExecutionStep -> m ExecutionStep
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ExecutionStep -> m ExecutionStep)
-> ExecutionStep -> m ExecutionStep
forall a b. (a -> b) -> a -> b
$ RequestHeaders
-> AnyBackend DBStepInfo -> Maybe RemoteJoins -> ExecutionStep
ExecStepDB [] (DBStepInfo b -> AnyBackend DBStepInfo
forall (b :: BackendType) (i :: BackendType -> *).
HasTag b =>
i b -> AnyBackend i
AB.mkAnyBackend DBStepInfo b
dbStepInfo) Maybe RemoteJoins
remoteJoins
RFRemote RemoteSchemaRootField
(RemoteRelationshipField UnpreparedValue) RemoteSchemaVariable
remoteField -> do
RemoteSchemaRootField RemoteSchemaInfo
remoteSchemaInfo ResultCustomizer
resultCustomizer GraphQLField (RemoteRelationshipField UnpreparedValue) Variable
resolvedRemoteField <- StateT
RemoteJSONVariableMap
m
(RemoteSchemaRootField
(RemoteRelationshipField UnpreparedValue) Variable)
-> m (RemoteSchemaRootField
(RemoteRelationshipField UnpreparedValue) Variable)
forall (m :: * -> *) a.
Monad m =>
StateT RemoteJSONVariableMap m a -> m a
runVariableCache (StateT
RemoteJSONVariableMap
m
(RemoteSchemaRootField
(RemoteRelationshipField UnpreparedValue) Variable)
-> m (RemoteSchemaRootField
(RemoteRelationshipField UnpreparedValue) Variable))
-> StateT
RemoteJSONVariableMap
m
(RemoteSchemaRootField
(RemoteRelationshipField UnpreparedValue) Variable)
-> m (RemoteSchemaRootField
(RemoteRelationshipField UnpreparedValue) Variable)
forall a b. (a -> b) -> a -> b
$ UserInfo
-> RemoteSchemaRootField
(RemoteRelationshipField UnpreparedValue) RemoteSchemaVariable
-> StateT
RemoteJSONVariableMap
m
(RemoteSchemaRootField
(RemoteRelationshipField UnpreparedValue) Variable)
forall (m :: * -> *) r.
MonadError QErr m =>
UserInfo
-> RemoteSchemaRootField r RemoteSchemaVariable
-> StateT
RemoteJSONVariableMap m (RemoteSchemaRootField r Variable)
resolveRemoteField UserInfo
userInfo RemoteSchemaRootField
(RemoteRelationshipField UnpreparedValue) RemoteSchemaVariable
remoteField
let (GraphQLField Void Variable
noRelsRemoteField, Maybe RemoteJoins
remoteJoins) = GraphQLField (RemoteRelationshipField UnpreparedValue) Variable
-> (GraphQLField Void Variable, Maybe RemoteJoins)
forall var.
GraphQLField (RemoteRelationshipField UnpreparedValue) var
-> (GraphQLField Void var, Maybe RemoteJoins)
RJ.getRemoteJoinsGraphQLField GraphQLField (RemoteRelationshipField UnpreparedValue) Variable
resolvedRemoteField
ExecutionStep -> m ExecutionStep
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ExecutionStep -> m ExecutionStep)
-> ExecutionStep -> m ExecutionStep
forall a b. (a -> b) -> a -> b
$
RemoteSchemaInfo
-> ResultCustomizer
-> OperationType
-> GraphQLField Void Variable
-> Maybe RemoteJoins
-> Maybe OperationName
-> ExecutionStep
buildExecStepRemote RemoteSchemaInfo
remoteSchemaInfo ResultCustomizer
resultCustomizer OperationType
G.OperationTypeMutation GraphQLField Void Variable
noRelsRemoteField Maybe RemoteJoins
remoteJoins (GQLReqUnparsed -> Maybe OperationName
forall a. GQLReq a -> Maybe OperationName
GH._grOperationName GQLReqUnparsed
gqlUnparsed)
RFAction ActionMutation (RemoteRelationshipField UnpreparedValue)
action -> do
let (ActionMutation Void
noRelsDBAST, Maybe RemoteJoins
remoteJoins) = ActionMutation (RemoteRelationshipField UnpreparedValue)
-> (ActionMutation Void, Maybe RemoteJoins)
RJ.getRemoteJoinsActionMutation ActionMutation (RemoteRelationshipField UnpreparedValue)
action
(ActionName
actionName, Bool
_fch) <- (ActionName, Bool) -> m (ActionName, Bool)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((ActionName, Bool) -> m (ActionName, Bool))
-> (ActionName, Bool) -> m (ActionName, Bool)
forall a b. (a -> b) -> a -> b
$ case ActionMutation Void
noRelsDBAST of
AMSync AnnActionExecution Void
s -> (AnnActionExecution Void -> ActionName
forall r. AnnActionExecution r -> ActionName
_aaeName AnnActionExecution Void
s, AnnActionExecution Void -> Bool
forall r. AnnActionExecution r -> Bool
_aaeForwardClientHeaders AnnActionExecution Void
s)
AMAsync AnnActionMutationAsync
s -> (AnnActionMutationAsync -> ActionName
_aamaName AnnActionMutationAsync
s, AnnActionMutationAsync -> Bool
_aamaForwardClientHeaders AnnActionMutationAsync
s)
ActionExecutionPlan
plan <- Environment
-> Logger Hasura
-> UserInfo
-> Manager
-> RequestHeaders
-> Maybe GQLQueryText
-> ActionMutation Void
-> m ActionExecutionPlan
forall (m :: * -> *).
(MonadIO m, MonadError QErr m,
MonadMetadataStorage (MetadataStorageT m)) =>
Environment
-> Logger Hasura
-> UserInfo
-> Manager
-> RequestHeaders
-> Maybe GQLQueryText
-> ActionMutation Void
-> m ActionExecutionPlan
convertMutationAction Environment
env Logger Hasura
logger UserInfo
userInfo Manager
manager RequestHeaders
reqHeaders (GQLQueryText -> Maybe GQLQueryText
forall a. a -> Maybe a
Just (GQLReqUnparsed -> GQLQueryText
forall a. GQLReq a -> a
GH._grQuery GQLReqUnparsed
gqlUnparsed)) ActionMutation Void
noRelsDBAST
ExecutionStep -> m ExecutionStep
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ExecutionStep -> m ExecutionStep)
-> ExecutionStep -> m ExecutionStep
forall a b. (a -> b) -> a -> b
$ ActionExecutionPlan
-> ActionsInfo -> Maybe RemoteJoins -> ExecutionStep
ExecStepAction ActionExecutionPlan
plan (ActionName -> Bool -> ActionsInfo
ActionsInfo ActionName
actionName Bool
_fch) Maybe RemoteJoins
remoteJoins
RFRaw Value
customFieldVal -> (Either QErr ExecutionStep
-> (QErr -> m ExecutionStep) -> m ExecutionStep)
-> (QErr -> m ExecutionStep)
-> Either QErr ExecutionStep
-> m ExecutionStep
forall a b c. (a -> b -> c) -> b -> a -> c
flip Either QErr ExecutionStep
-> (QErr -> m ExecutionStep) -> m ExecutionStep
forall (m :: * -> *) e a.
Applicative m =>
Either e a -> (e -> m a) -> m a
onLeft QErr -> m ExecutionStep
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (Either QErr ExecutionStep -> m ExecutionStep)
-> m (Either QErr ExecutionStep) -> m ExecutionStep
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< UserInfo
-> Value
-> SetGraphqlIntrospectionOptions
-> m (Either QErr ExecutionStep)
forall (m :: * -> *).
MonadGQLExecutionCheck m =>
UserInfo
-> Value
-> SetGraphqlIntrospectionOptions
-> m (Either QErr ExecutionStep)
executeIntrospection UserInfo
userInfo Value
customFieldVal SetGraphqlIntrospectionOptions
introspectionDisabledRoles
RFMulti [MutationRootField UnpreparedValue]
lst -> do
[ExecutionStep]
allSteps <- (MutationRootField UnpreparedValue -> m ExecutionStep)
-> [MutationRootField UnpreparedValue] -> m [ExecutionStep]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (RootFieldAlias
-> MutationRootField UnpreparedValue -> m ExecutionStep
resolveExecutionSteps RootFieldAlias
rootFieldName) [MutationRootField UnpreparedValue]
lst
ExecutionStep -> m ExecutionStep
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ExecutionStep -> m ExecutionStep)
-> ExecutionStep -> m ExecutionStep
forall a b. (a -> b) -> a -> b
$ [ExecutionStep] -> ExecutionStep
ExecStepMulti [ExecutionStep]
allSteps
ExecutionPlan
txs <- ((RootFieldAlias
-> MutationRootField UnpreparedValue -> m ExecutionStep)
-> RootFieldMap (MutationRootField UnpreparedValue)
-> m ExecutionPlan)
-> RootFieldMap (MutationRootField UnpreparedValue)
-> (RootFieldAlias
-> MutationRootField UnpreparedValue -> m ExecutionStep)
-> m ExecutionPlan
forall a b c. (a -> b -> c) -> b -> a -> c
flip (RootFieldAlias
-> MutationRootField UnpreparedValue -> m ExecutionStep)
-> RootFieldMap (MutationRootField UnpreparedValue)
-> m ExecutionPlan
forall (f :: * -> *) k a b.
Applicative f =>
(k -> a -> f b) -> InsOrdHashMap k a -> f (InsOrdHashMap k b)
OMap.traverseWithKey RootFieldMap (MutationRootField UnpreparedValue)
unpreparedQueries ((RootFieldAlias
-> MutationRootField UnpreparedValue -> m ExecutionStep)
-> m ExecutionPlan)
-> (RootFieldAlias
-> MutationRootField UnpreparedValue -> m ExecutionStep)
-> m ExecutionPlan
forall a b. (a -> b) -> a -> b
$ RootFieldAlias
-> MutationRootField UnpreparedValue -> m ExecutionStep
resolveExecutionSteps
(ExecutionPlan, ParameterizedQueryHash)
-> m (ExecutionPlan, ParameterizedQueryHash)
forall (m :: * -> *) a. Monad m => a -> m a
return (ExecutionPlan
txs, ParameterizedQueryHash
parameterizedQueryHash)