def gen_operation(self, graphql_text: str, operation: str, *args: GraphQLArg) -> dict:
arg_strings = []
for name, arg_type, _value in args:
arg_strings.append("${name}: {arg_type}".format(name=name, arg_type=arg_type))
arg_list = ', '.join(arg_strings)
full_query = (
'{operation} ({arg_list}) '.format(arg_list=arg_list, operation=operation) + '{' +
graphql_text + '}'
)
arg_dict = {arg.name: arg.value for arg in args}
result = await (
exec_in_mem_graphql(
self.graphql_schema, self.context, full_query, self.root_value, arg_dict
)
)
if result.errors:
_process_error(result)
return cast(dict, result.data)
评论列表
文章目录