Skip to content

Commit 29935c2

Browse files
author
=
committed
Test Last works
1 parent de59d26 commit 29935c2

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

graphene_django/tests/test_query.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,48 @@ def resolve_all_reporters(self, info, **args):
695695
assert not result.errors
696696
assert result.data == expected
697697

698+
def test_should_query_promise_connectionfields_with_last():
699+
from promise import Promise
700+
701+
class ReporterType(DjangoObjectType):
702+
703+
class Meta:
704+
model = Reporter
705+
interfaces = (Node, )
706+
707+
class Query(graphene.ObjectType):
708+
all_reporters = DjangoConnectionField(ReporterType)
709+
710+
def resolve_all_reporters(self, info, **args):
711+
return Promise.resolve([Reporter(id=1)])
712+
713+
schema = graphene.Schema(query=Query)
714+
query = '''
715+
query ReporterPromiseConnectionQuery {
716+
allReporters(last: 1) {
717+
edges {
718+
node {
719+
id
720+
}
721+
}
722+
}
723+
}
724+
'''
725+
726+
expected = {
727+
'allReporters': {
728+
'edges': [{
729+
'node': {
730+
'id': 'UmVwb3J0ZXJUeXBlOjE='
731+
}
732+
}]
733+
}
734+
}
735+
736+
result = schema.execute(query)
737+
assert not result.errors
738+
assert result.data == expected
739+
698740

699741
def test_should_query_dataloader_fields():
700742
from promise import Promise

0 commit comments

Comments
 (0)