/
connectiontypes.py
42 lines (26 loc) · 1.01 KB
/
connectiontypes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from typing import Any, Dict, List, NamedTuple, Optional
__all__ = ["Connection", "ConnectionArguments", "ConnectionCursor", "Edge", "PageInfo"]
"""A type alias for cursors in this implementation."""
ConnectionCursor = str
class PageInfo(NamedTuple):
"""A type designed to be exposed as `PageInfo` over GraphQL."""
startCursor: Optional[ConnectionCursor]
endCursor: Optional[ConnectionCursor]
hasPreviousPage: Optional[bool]
hasNextPage: Optional[bool]
class Edge(NamedTuple):
"""A type designed to be exposed as a `Edge` over GraphQL."""
node: Any
cursor: ConnectionCursor
class Connection(NamedTuple):
"""A type designed to be exposed as a `Connection` over GraphQL."""
edges: List[Edge]
pageInfo: PageInfo
"""A type describing the arguments a connection field receives in GraphQL.
The following kinds of arguments are expected (all optional):
before: ConnectionCursor
after: ConnectionCursor
first: int
last: int
"""
ConnectionArguments = Dict[str, Any]