石墨烯查询问题

时间:2020-06-10 20:59:52

标签: python graphene-python

我一直在使用Graphene,但不幸的是,我的查询在运行时中断了我的程序,并抛出以下错误:

AssertionError: Query fields must be a mapping (dict / OrderedDict) with field names as keys or a function which returns such a mapping.

它抛出了该程序的最后一行(分配了模式),我确定它与Query方法中分配tag = Tag的部分有关。有人知道这里可能出什么问题吗?另外,如果您通常对石墨烯有任何资源,它们将对您有很大的帮助。对此很新。

import graphene

class Tag(graphene.ObjectType):
    id = graphene.ID()
    name = graphene.String()
    Categories = graphene.List(graphene.String) #change to List(category) later
    Synonyms = graphene.List(graphene.String) #same

class Query(graphene.ObjectType):
    tag = Tag()

    def resolve_tag(self, info, **kwargs):
        return Tag(
        name="adderall",
        Categories=["Anticonvulsant Drug Therapy","Behavioral Issues"],
        Synonyms=["addy","speed"] )

schema = graphene.Schema(query=Query)

0 个答案:

没有答案