Grapql解析器未触发

时间:2019-05-29 21:56:14

标签: python boto3 graphene-python

我有以下查询类

class DexDynamoDbQuery(ObjectType):
    dex_dynamo_db_all_reports_by_hli_subject_id = Field(
        DexDynamoCacheList,
        hli_subject_id=String(
            required=True,
            description="Subject Identifier"),
    )

我有以下用于查询的解析器。

def resolve_dex_dynamo_db_all_reports_by_hli_subject_id(self, info, hli_subject_id):
    print("STARTING TO GATHER")
    try:
        resolver_dynamo_client = DynamodbClient(TABLE_NAME, REGION)
        resolver_dynamo_client.get_all_reports_by_hli_subject_id(
            hli_subject_id)
        print("Post dynamo")
        return generate_report_resolver(resolver_dynamo_client._reports)
    except Exception as error:
        raise GraphQLError(
            "Unable to retrieve data due to {}".format(str(error)))

我有如图所示的generate_report_resolver函数

def generate_report_resolver(reports):
    resolved_list = DexDynamoCacheList()
    temp_cache_list = []
    for report in reports:
        temp_dex_cache_type = DexDynamoCacheType()
        temp_dex_cache_type.JOB_ID = report["job_id"]
        temp_cache_list.append(temp_dex_cache_type)
    resolved_list.CACHE_TYPE_LIST = temp_cache_list
    return resolved_list

以及以下类型

class DexDynamoCacheType(ObjectType):
    JOB_ID = String(
        name="job_id", description="Job Id")
class DexDynamoCacheList(ObjectType):
    CACHE_TYPE_LIST = List(DexDynamoCacheType)

这是我的查询方式。

query = """
            query {
                dex_dynamo_db_all_reports_by_hli_subject_id(hli_subject_id:"test_id"){
                    cache_type_list {
                        job_id
                    }
                }

            }
        """
schema = DexDynamoDbSchema()
new_schema = schema.build_schema()
result = new_schema.execute(query)
print(result.data)

我的代码甚至没有达到我开始收集的水平。在完成解析器之前,我可以打印出我的报告并确认它们已正确填充。我的查询现在没有返回任何内容,而没有进入解析器。在查询写错之前,我已经看到过这个问题,但这是我第一次遇到Graphene.List类型对象的问题。

0 个答案:

没有答案