Skip to content

Commit 778fbd7

Browse files
committed
fix: catch import error in older sqlalchemy versions
Signed-off-by: Erik Wrede <erikwrede2@gmail.com>
1 parent d66f1d0 commit 778fbd7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

graphene_sqlalchemy/converter.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from sqlalchemy import types as sqa_types
99
from sqlalchemy.dialects import postgresql
1010
from sqlalchemy.ext.hybrid import hybrid_property
11-
from sqlalchemy.orm import MapperProperty, interfaces, strategies
11+
from sqlalchemy.orm import interfaces, strategies
1212

1313
import graphene
1414
from graphene.types.json import JSONString
@@ -27,6 +27,13 @@
2727
value_equals_strict,
2828
)
2929

30+
# We just use MapperProperties for type hints, they don't exist in sqlalchemy < 1.4
31+
try:
32+
from sqlalchemy import MapperProperty
33+
except ImportError:
34+
# sqlalchemy < 1.4
35+
MapperProperty = Any
36+
3037
try:
3138
from typing import ForwardRef
3239
except ImportError:

0 commit comments

Comments
 (0)