mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-14 05:36:45 +03:00
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.
This commit is contained in:
parent
8d5843dc21
commit
b8ecc3929d
|
@ -12,6 +12,12 @@ from .node import is_node
|
||||||
|
|
||||||
|
|
||||||
class PageInfo(ObjectType):
|
class PageInfo(ObjectType):
|
||||||
|
class Meta:
|
||||||
|
description = (
|
||||||
|
"The Relay compliant `PageInfo` type, containing data necessary to"
|
||||||
|
" paginate this connection."
|
||||||
|
)
|
||||||
|
|
||||||
has_next_page = Boolean(
|
has_next_page = Boolean(
|
||||||
required=True,
|
required=True,
|
||||||
name="hasNextPage",
|
name="hasNextPage",
|
||||||
|
@ -64,13 +70,18 @@ class Connection(ObjectType):
|
||||||
node = Field(_node, description="The item at the end of the edge")
|
node = Field(_node, description="The item at the end of the edge")
|
||||||
cursor = String(required=True, description="A cursor for use in pagination")
|
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)
|
edge_name = "{}Edge".format(base_name)
|
||||||
if edge_class:
|
if edge_class:
|
||||||
edge_bases = (edge_class, EdgeBase, ObjectType)
|
edge_bases = (edge_class, EdgeBase, ObjectType)
|
||||||
else:
|
else:
|
||||||
edge_bases = (EdgeBase, ObjectType)
|
edge_bases = (EdgeBase, ObjectType)
|
||||||
|
|
||||||
edge = type(edge_name, edge_bases, {})
|
edge = type(edge_name, edge_bases, {"Meta": EdgeMeta})
|
||||||
cls.Edge = edge
|
cls.Edge = edge
|
||||||
|
|
||||||
options["name"] = name
|
options["name"] = name
|
||||||
|
|
Loading…
Reference in New Issue
Block a user