File tree Expand file tree Collapse file tree 4 files changed +59
-5
lines changed
Expand file tree Collapse file tree 4 files changed +59
-5
lines changed Original file line number Diff line number Diff line change @@ -93,12 +93,15 @@ def is_filterable(k):
9393 return False
9494 return True
9595
96- def get_type (v ):
97- if isinstance (v .type , Structure ):
98- return v .type .of_type ()
99- return v .type ()
96+ def get_filter_type (_type ):
97+ """
98+ Returns the scalar type.
99+ """
100+ if isinstance (_type , Structure ):
101+ return get_filter_type (_type .of_type )
102+ return _type ()
100103
101- return {k : get_type ( v ) for k , v in items if is_filterable (k )}
104+ return {k : get_filter_type ( v . type ) for k , v in items if is_filterable (k )}
102105
103106 @property
104107 def field_args (self ):
Original file line number Diff line number Diff line change @@ -156,3 +156,11 @@ class ErroneousModel(mongoengine.Document):
156156 meta = {'collection' : 'test_colliding_objects_model' }
157157
158158 objects = mongoengine .ListField (mongoengine .StringField ())
159+
160+
161+ class Bar (mongoengine .EmbeddedDocument ):
162+ some_list_field = mongoengine .ListField (mongoengine .StringField (), required = True )
163+
164+
165+ class Foo (mongoengine .Document ):
166+ bars = mongoengine .EmbeddedDocumentListField (Bar )
Original file line number Diff line number Diff line change @@ -99,3 +99,15 @@ class ErroneousModelNode(MongoengineObjectType):
9999 class Meta :
100100 model = models .ErroneousModel
101101 interfaces = (Node , )
102+
103+
104+ class BarNode (MongoengineObjectType ):
105+ class Meta :
106+ model = models .Bar
107+ interfaces = (Node , )
108+
109+
110+ class FooNode (MongoengineObjectType ):
111+ class Meta :
112+ model = models .Foo
113+ interfaces = (Node , )
Original file line number Diff line number Diff line change @@ -1079,6 +1079,37 @@ class Query(graphene.ObjectType):
10791079 assert json .dumps (result .data , sort_keys = True ) == json .dumps (expected , sort_keys = True )
10801080
10811081
1082+ def test_should_query_document_with_embedded (fixtures ):
1083+
1084+ class Query (graphene .ObjectType ):
1085+ foos = MongoengineConnectionField (nodes .FooNode )
1086+
1087+ def resolve_multiple_foos (self , * args , ** kwargs ):
1088+ return list (models .Foo .objects .all ())
1089+
1090+ query = '''
1091+ query {
1092+ foos {
1093+ edges {
1094+ node {
1095+ bars {
1096+ edges {
1097+ node {
1098+ someListField
1099+ }
1100+ }
1101+ }
1102+ }
1103+ }
1104+ }
1105+ }
1106+ '''
1107+
1108+ schema = graphene .Schema (query = Query )
1109+ result = schema .execute (query )
1110+ assert not result .errors
1111+
1112+
10821113def test_should_filter_mongoengine_queryset_with_list (fixtures ):
10831114
10841115 class Query (graphene .ObjectType ):
You can’t perform that action at this time.
0 commit comments