我在 python 中使用 GraphQL 正在尝试解析列表数据,但字段解析为空。我怎样才能让他们返回实际的列表数据?
这是我的代码片段
import graphene
class User(graphene.ObjectType):
""" Type definition for User """
id = graphene.Int()
username = graphene.String()
email = graphene.String()
class Query(graphene.ObjectType):
users = graphene.List(User)
def resolve_users(self, args):
resp = [{'id': 39330, 'username': 'RCraig', 'email':
'WRussell@dolor.gov', 'teamId': 0}, {'id': 39331,
'username': 'AHohmann','email': 'AMarina@sapien.com',
'teamId': 0}]
return resp
schema = graphene.Schema(query=Query)
该片段可以在石墨烯游乐场进行测试