graphql_client.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:graphscale 作者: schrockn 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号