File tree 4 files changed +59
-5
lines changed
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):
93
93
return False
94
94
return True
95
95
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 ()
100
103
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 )}
102
105
103
106
@property
104
107
def field_args (self ):
Original file line number Diff line number Diff line change @@ -156,3 +156,11 @@ class ErroneousModel(mongoengine.Document):
156
156
meta = {'collection' : 'test_colliding_objects_model' }
157
157
158
158
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):
99
99
class Meta :
100
100
model = models .ErroneousModel
101
101
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 @@ -1077,3 +1077,34 @@ class Query(graphene.ObjectType):
1077
1077
1078
1078
assert not result .errors
1079
1079
assert json .dumps (result .data , sort_keys = True ) == json .dumps (expected , sort_keys = True )
1080
+
1081
+
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
You can’t perform that action at this time.
0 commit comments