Skip to content

Commit 131cbeb

Browse files
authored
Merge pull request #832 from danpalmer/patch-6
Add basic type documentation for Relay fields
2 parents 8d5843d + 2a3d926 commit 131cbeb

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

graphene/relay/connection.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212

1313

1414
class PageInfo(ObjectType):
15+
class Meta:
16+
description = (
17+
"The Relay compliant `PageInfo` type, containing data necessary to"
18+
" paginate this connection."
19+
)
20+
1521
has_next_page = Boolean(
1622
required=True,
1723
name="hasNextPage",
@@ -64,21 +70,40 @@ class EdgeBase(object):
6470
node = Field(_node, description="The item at the end of the edge")
6571
cursor = String(required=True, description="A cursor for use in pagination")
6672

73+
class EdgeMeta:
74+
description = "A Relay edge containing a `{}` and its cursor.".format(
75+
base_name
76+
)
77+
6778
edge_name = "{}Edge".format(base_name)
6879
if edge_class:
6980
edge_bases = (edge_class, EdgeBase, ObjectType)
7081
else:
7182
edge_bases = (EdgeBase, ObjectType)
7283

73-
edge = type(edge_name, edge_bases, {})
84+
edge = type(edge_name, edge_bases, {"Meta": EdgeMeta})
7485
cls.Edge = edge
7586

7687
options["name"] = name
7788
_meta.node = node
7889
_meta.fields = OrderedDict(
7990
[
80-
("page_info", Field(PageInfo, name="pageInfo", required=True)),
81-
("edges", Field(NonNull(List(edge)))),
91+
(
92+
"page_info",
93+
Field(
94+
PageInfo,
95+
name="pageInfo",
96+
required=True,
97+
description="Pagination data for this connection.",
98+
),
99+
),
100+
(
101+
"edges",
102+
Field(
103+
NonNull(List(edge)),
104+
description="Contains the nodes in this connection.",
105+
),
106+
),
82107
]
83108
)
84109
return super(Connection, cls).__init_subclass_with_meta__(

0 commit comments

Comments
 (0)