Skip to content

Commit 7b05df7

Browse files
authored
Merge pull request #76 from Cito/missing_sqlalchemy_utils_issue
Missing sqlalchemy utils issue
2 parents 7e2508e + 908e326 commit 7b05df7

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

graphene_sqlalchemy/converter.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,10 @@
1010
from .fields import createConnectionField
1111

1212
try:
13-
from sqlalchemy_utils import ChoiceType, JSONType, ScalarListType, TSVectorType
13+
from sqlalchemy_utils import (
14+
ChoiceType, JSONType, ScalarListType, TSVectorType)
1415
except ImportError:
15-
class ChoiceType(object):
16-
pass
17-
18-
class ScalarListType(object):
19-
pass
20-
21-
class JSONType(object):
22-
pass
16+
ChoiceType = JSONType = ScalarListType = TSVectorType = object
2317

2418

2519
def get_column_doc(column):
@@ -38,10 +32,9 @@ def dynamic_type():
3832
_type = registry.get_type_for_model(model)
3933
if not _type:
4034
return None
41-
if (direction == interfaces.MANYTOONE or not relationship.uselist):
35+
if direction == interfaces.MANYTOONE or not relationship.uselist:
4236
return Field(_type)
43-
elif (direction == interfaces.ONETOMANY or
44-
direction == interfaces.MANYTOMANY):
37+
elif direction in (interfaces.ONETOMANY, interfaces.MANYTOMANY):
4538
if _type._meta.connection:
4639
return createConnectionField(_type)
4740
return Field(List(_type))

graphene_sqlalchemy/types.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def construct_fields(model, registry, only_fields, exclude_fields):
2828
is_excluded = name in exclude_fields # or is_already_created
2929
if is_not_in_only or is_excluded:
3030
# We skip this field if we specify only_fields and is not
31-
# in there. Or when we excldue this field in exclude_fields
31+
# in there. Or when we exclude this field in exclude_fields
3232
continue
3333
converted_column = convert_sqlalchemy_column(column, registry)
3434
fields[name] = converted_column
@@ -39,7 +39,7 @@ def construct_fields(model, registry, only_fields, exclude_fields):
3939
is_excluded = name in exclude_fields # or is_already_created
4040
if is_not_in_only or is_excluded:
4141
# We skip this field if we specify only_fields and is not
42-
# in there. Or when we excldue this field in exclude_fields
42+
# in there. Or when we exclude this field in exclude_fields
4343
continue
4444
converted_composite = convert_sqlalchemy_composite(composite, registry)
4545
fields[name] = converted_composite
@@ -55,7 +55,7 @@ def construct_fields(model, registry, only_fields, exclude_fields):
5555

5656
if is_not_in_only or is_excluded:
5757
# We skip this field if we specify only_fields and is not
58-
# in there. Or when we excldue this field in exclude_fields
58+
# in there. Or when we exclude this field in exclude_fields
5959
continue
6060

6161
converted_hybrid_property = convert_sqlalchemy_hybrid_method(
@@ -70,7 +70,7 @@ def construct_fields(model, registry, only_fields, exclude_fields):
7070
is_excluded = relationship.key in exclude_fields # or is_already_created
7171
if is_not_in_only or is_excluded:
7272
# We skip this field if we specify only_fields and is not
73-
# in there. Or when we excldue this field in exclude_fields
73+
# in there. Or when we exclude this field in exclude_fields
7474
continue
7575
converted_relationship = convert_sqlalchemy_relationship(relationship, registry)
7676
name = relationship.key

0 commit comments

Comments
 (0)