我目前有一个采用这种形式的工作查询:
class Query(graphene.AbstractType):
algorithms = graphene.String(id=graphene.String())
def resolve_algorithms(self, args, context, info):
# Much code here that goes to external server to get data
algorithms = {} # Instantiate dictionary
# Code here to populate this dictionary
return algorithms
虽然这确实有效,但它是一个杂项,因为我强制将字典对象作为字符串返回。我四处寻找文章,向我展示如何将类型更改为 graphene.ObjectType() 但没有成功。
可能有人知道怎么做?
罗伯特