Skip to content

Commit f26d023

Browse files
add first and last handling
1 parent 27ef570 commit f26d023

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

graphene_mongo/fields.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,16 @@ def fields(self):
8282

8383
@classmethod
8484
def get_query(cls, model, info, **args):
85+
objs = model.objects()
8586
if args:
86-
return model.objects().filter(**args)
87-
return model.objects()
87+
objs = objs.filter(**args)
88+
89+
if 'first' in args:
90+
objs = objs[:args['first']]
91+
if 'last' in args:
92+
objs = objs[:-args['last']]
93+
94+
return objs
8895

8996
@classmethod
9097
def merge_querysets(cls, default_queryset, queryset):

0 commit comments

Comments
 (0)