Skip to content

Commit 14fbfaa

Browse files
author
Jian Li
committed
change page_info to fit relay's limitation
1 parent 0345fa4 commit 14fbfaa

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

graphene/relay/types.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,23 @@
1818

1919

2020
class PageInfo(ObjectType):
21-
has_next_page = Boolean(
21+
22+
def __init__(self, start_cursor="", end_cursor="",
23+
has_previous_page=False, has_next_page=False):
24+
self.startCursor = start_cursor
25+
self.endCursor = end_cursor
26+
self.hasPreviousPage = has_previous_page
27+
self.hasNextPage = has_next_page
28+
29+
hasNextPage = Boolean(
2230
required=True,
2331
description='When paginating forwards, are there more items?')
24-
has_previous_page = Boolean(
32+
hasPreviousPage = Boolean(
2533
required=True,
2634
description='When paginating backwards, are there more items?')
27-
start_cursor = String(
35+
startCursor = String(
2836
description='When paginating backwards, the cursor to continue.')
29-
end_cursor = String(
37+
endCursor = String(
3038
description='When paginating forwards, the cursor to continue.')
3139

3240

@@ -49,11 +57,16 @@ def for_node(cls, node):
4957

5058
class Connection(ObjectType):
5159
'''A connection to a list of items.'''
60+
61+
def __init__(self, edges, page_info):
62+
self.edges = edges
63+
self.pageInfo = page_info
64+
5265
class Meta:
5366
type_name = 'DefaultConnection'
5467

55-
page_info = Field(PageInfo, required=True,
56-
description='The Information to aid in pagination')
68+
pageInfo = Field(PageInfo, required=True,
69+
description='The Information to aid in pagination')
5770

5871
_connection_data = None
5972

0 commit comments

Comments
 (0)