如何获取在测试中发送到解析器的info参数

时间:2019-06-19 19:16:15

标签: django graphene-django

我想测试一个检查查询是否请求字段的函数:

def field_in_query(field, info):
fragments = {}
node = ast_to_dict(info.field_asts[0])
for name, value in info.fragments.items():
    fragments[name] = ast_to_dict(value)

while node.get('selection_set'):
    for leaf in node['selection_set']['selections']:
        if leaf['name']['value'] == field:
            return True
        else:
            node = fragments[leaf['name']['value']] if leaf['kind'] == 'FragmentSpread' else leaf
return False

但是我不知道如何获取info参数。 有什么办法吗?

0 个答案:

没有答案