Skip to content

Commit 223868e

Browse files
Mongoengine version updated for python3
Support added for Mongoengine Enum Field for python3
1 parent 5db17de commit 223868e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

graphene_mongo/converter.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
13
import graphene
24
import mongoengine
35
import uuid
@@ -421,3 +423,11 @@ def dynamic_type():
421423
)
422424

423425
return graphene.Dynamic(dynamic_type)
426+
427+
428+
if sys.version_info[0] > 3:
429+
@convert_mongoengine_field.register(mongoengine.EnumField)
430+
def convert_field_to_enum(field, registry=None):
431+
return graphene.Field(graphene.Enum.from_enum(field._enum_cls),
432+
description=get_field_description(field, registry), required=field.required
433+
)

graphene_mongo/fields.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ def chained_resolver(self, resolver, is_partial, root, info, **args):
391391
args_copy.pop(arg_name)
392392
if arg_name == '_id' and isinstance(arg, dict):
393393
args_copy['pk__in'] = arg['$in']
394+
elif "$ne" in arg:
395+
args_copy['pk__ne'] = arg['$ne']
394396
if '.' in arg_name:
395397
operation = list(arg.keys())[0]
396398
args_copy[arg_name.replace('.', '__') + operation.replace('$', '__')] = arg[operation]

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ future==0.18.2
66
graphene>=2.1.8,<3
77
iso8601==0.1.13
88
mongoengine==0.19.1; python_version <= '3.4'
9-
mongoengine==0.20.0; python_version > '3.4'
9+
mongoengine==0.21.0; python_version > '3.4'
1010
mongomock==3.21.0
11-
pymongo==3.11.0
11+
pymongo==3.11.2
1212
pytest==4.6.11; python_version <= '3.4'
1313
pytest==6.1.2; python_version > '3.4'
1414
pytest-cov==2.8.1; python_version == '3.4'

0 commit comments

Comments
 (0)