def test_should_support_last():
class ArticleNode(PynamoObjectType):
class Meta:
model = Article
interfaces = (Node,)
class ReporterNode(PynamoObjectType):
class Meta:
model = Reporter
interfaces = (Node,)
class Query(graphene.ObjectType):
node = Node.Field()
reporter = graphene.Field(ReporterNode)
def resolve_reporter(self, *args, **kwargs):
return Reporter.get(1)
query = '''
query ReporterQuery {
reporter {
id,
firstName,
articles(last: 1) {
edges {
node {
id
headline
}
}
}
lastName,
email
}
}
'''
expected = {
'reporter': {
'articles': {
'edges': [{
'node': {
'id': 'QXJ0aWNsZU5vZGU6Mw==',
'headline': 'My Article'
}
}]
}
}
}
schema = graphene.Schema(query=Query)
result = schema.execute(query)
assert not result.errors
assert result.data['reporter']['articles']['edges'] == expected['reporter']['articles']['edges']
评论列表
文章目录