Skip to content

Commit 59a314f

Browse files
committed
Fixed unicode string error when accessing cursor data
1 parent 30da96d commit 59a314f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

graphql_relay/connection/arrayconnection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from promise import Promise
22

3-
from ..utils import base64, unbase64
3+
from ..utils import base64, unbase64, is_str
44
from .connectiontypes import Connection, PageInfo, Edge
55

66

@@ -148,7 +148,7 @@ def get_offset_with_default(cursor=None, default_offset=0):
148148
to use; if the cursor contains a valid offset, that will be used,
149149
otherwise it will be the default.
150150
'''
151-
if not isinstance(cursor, str):
151+
if not is_str(cursor):
152152
return default_offset
153153

154154
offset = cursor_to_offset(cursor)

graphql_relay/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44
str_type = basestring
55
base64 = _base64
66
unbase64 = _unbase64
7+
8+
def is_str(s):
9+
return isinstance(s, basestring)
10+
711
except NameError:
812
def base64(s):
913
return _base64(bytes(s, 'utf-8')).decode('utf-8')
1014

1115
def unbase64(s):
1216
return _unbase64(s).decode('utf-8')
1317

18+
def is_str(s):
19+
return isinstance(s, str)
20+
1421

1522
def resolve_maybe_thunk(f):
1623
if callable(f):

0 commit comments

Comments
 (0)