forked from dvndrsn/graphql-python-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
16 lines (9 loc) · 375 Bytes
/
utils.py
File metadata and controls
16 lines (9 loc) · 375 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from collections import namedtuple
import graphql_relay
def to_global_id(type_, id_):
type_name = str(type_)
return graphql_relay.to_global_id(type_name, id_)
GlobalID = namedtuple('GlobalID', ('type_name', 'type_id'))
def from_global_id(global_id):
type_name, type_id = graphql_relay.from_global_id(global_id)
return GlobalID(type_name, int(type_id))