From ca8058563682085d70862532cbbdbb252023eef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Br=C3=A9mond?= Date: Thu, 23 Jul 2020 16:14:56 -0700 Subject: [PATCH] Fix backward Relay pagination --- graphene_django/fields.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/graphene_django/fields.py b/graphene_django/fields.py index 67559aa..634d8f7 100644 --- a/graphene_django/fields.py +++ b/graphene_django/fields.py @@ -150,7 +150,11 @@ class DjangoConnectionField(ConnectionField): after = min(get_offset_with_default(args.get("after"), -1) + 1, list_length) if max_limit is not None and "first" not in args: - args["first"] = max_limit + if "last" in args: + args["first"] = list_length + list_slice_length = list_length + else: + args["first"] = max_limit connection = connection_from_list_slice( iterable[after:],