Skip to content

Commit

Permalink
Merge pull request #293 from dwsutherland/mutation-reconstruction-filter
Browse files Browse the repository at this point in the history
multi-mutation request filtered reconstruction
  • Loading branch information
oliver-sanders authored Dec 6, 2021
2 parents 8953636 + 6145685 commit 0fef3c4
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions cylc/uiserver/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
"""GraphQL resolvers for use in data accessing and mutation of workflows."""

import os
from copy import deepcopy
from subprocess import Popen, PIPE, DEVNULL

from graphql.language.base import print_ast

from cylc.flow.network.resolvers import BaseResolvers
from cylc.flow.data_store_mgr import WORKFLOW

Expand Down Expand Up @@ -194,9 +197,15 @@ async def mutator(self, info, *m_args):
return [{
'response': (False, 'No matching workflows')}]
# Pass the request to the workflow GraphQL endpoints
req_str, variables, _, _ = info.context.get('graphql_params')
_, variables, _, _ = info.context.get('graphql_params')

# Create a modified request string,
# containing only the current mutation/field.
operation_ast = deepcopy(info.operation)
operation_ast.selection_set.selections = info.field_asts

graphql_args = {
'request_string': req_str,
'request_string': print_ast(operation_ast),
'variables': variables,
}
return await self.workflows_mgr.multi_request(
Expand All @@ -221,9 +230,15 @@ async def nodes_mutator(self, info, *m_args):
return [{
'response': (False, 'No matching workflows')}]
# Pass the multi-node request to the workflow GraphQL endpoints
req_str, variables, _, _ = info.context.get('graphql_params')
_, variables, _, _ = info.context.get('graphql_params')

# Create a modified request string,
# containing only the current mutation/field.
operation_ast = deepcopy(info.operation)
operation_ast.selection_set.selections = info.field_asts

graphql_args = {
'request_string': req_str,
'request_string': print_ast(operation_ast),
'variables': variables,
}
multi_args = {w_id: graphql_args for w_id in w_ids}
Expand Down

0 comments on commit 0fef3c4

Please sign in to comment.