From b8ecc3929d55e69de9abb1d8c4cf75ffd45ac656 Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Sun, 9 Sep 2018 18:19:58 +0100 Subject: [PATCH] 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. --- graphene/relay/connection.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/graphene/relay/connection.py b/graphene/relay/connection.py index 2782865c..a0f5a14c 100644 --- a/graphene/relay/connection.py +++ b/graphene/relay/connection.py @@ -12,6 +12,12 @@ from .node import is_node class PageInfo(ObjectType): + class Meta: + description = ( + "The Relay compliant `PageInfo` type, containing data necessary to" + " paginate this connection." + ) + has_next_page = Boolean( required=True, name="hasNextPage", @@ -64,13 +70,18 @@ class Connection(ObjectType): node = Field(_node, description="The item at the end of the edge") cursor = String(required=True, description="A cursor for use in pagination") + class EdgeMeta: + description = "A Relay edge containing a `{}` and its cursor.".format( + base_name + ) + edge_name = "{}Edge".format(base_name) if edge_class: edge_bases = (edge_class, EdgeBase, ObjectType) else: edge_bases = (EdgeBase, ObjectType) - edge = type(edge_name, edge_bases, {}) + edge = type(edge_name, edge_bases, {"Meta": EdgeMeta}) cls.Edge = edge options["name"] = name