Skip to content

Commit b8ecc39

Browse files
authored
Add basic type documentation for Relay fields
This adds documentation in the API for `PageInfo`s and `Edges`. This is useful to include in Graphene because `PageInfo` is always the same, and Edges always have the same format, so documentation for both can be created automatically.
1 parent 8d5843d commit b8ecc39

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

graphene/relay/connection.py

Lines changed: 12 additions & 1 deletion
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,13 +70,18 @@ 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

0 commit comments

Comments
 (0)