File tree Expand file tree Collapse file tree 3 files changed +20
-12
lines changed
Expand file tree Collapse file tree 3 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,8 @@ def field_args(self):
103103
104104 @property
105105 def reference_args (self ):
106+ from .advanced_types import FsFile
107+
106108 def get_reference_field (r , kv ):
107109 field = kv [1 ]
108110 mongo_field = getattr (self .model , kv [0 ], None )
@@ -112,7 +114,7 @@ def get_reference_field(r, kv):
112114 _type = field .get_type ()
113115 if _type :
114116 node = _type ._type ._meta
115- if 'id' in node .fields and not issubclass (node .model , mongoengine .EmbeddedDocument ):
117+ if 'id' in node .fields and not issubclass (node .model , ( mongoengine .EmbeddedDocument , FsFile ) ):
116118 r .update ({kv [0 ]: node .fields ['id' ]._type .of_type ()})
117119 return r
118120
Original file line number Diff line number Diff line change @@ -141,7 +141,10 @@ class Query(graphene.ObjectType):
141141 node {
142142 id,
143143 firstName,
144- lastName
144+ lastName,
145+ avatar {
146+ contentType
147+ }
145148 }
146149 }
147150 }
@@ -154,22 +157,31 @@ class Query(graphene.ObjectType):
154157 'node' : {
155158 'id' : 'RWRpdG9yTm9kZTox' ,
156159 'firstName' : 'Penny' ,
157- 'lastName' : 'Hardaway'
160+ 'lastName' : 'Hardaway' ,
161+ 'avatar' : {
162+ 'contentType' : 'image/jpeg'
163+ }
158164 }
159165 },
160166 {
161167 'node' : {
162168 'id' : 'RWRpdG9yTm9kZToy' ,
163169 'firstName' : 'Grant' ,
164- 'lastName' : 'Hill'
170+ 'lastName' : 'Hill' ,
171+ 'avatar' : {
172+ 'contentType' : None
173+ }
165174 }
166175
167176 },
168177 {
169178 'node' : {
170179 'id' : 'RWRpdG9yTm9kZToz' ,
171180 'firstName' : 'Dennis' ,
172- 'lastName' : 'Rodman'
181+ 'lastName' : 'Rodman' ,
182+ 'avatar' : {
183+ 'contentType' : None
184+ }
173185 }
174186 }
175187 ]
Original file line number Diff line number Diff line change @@ -163,15 +163,9 @@ def rescan_fields(cls):
163163 # noqa
164164 @classmethod
165165 def is_type_of (cls , root , info ):
166- print ('cls' )
167- print (cls )
168- print ('root' )
169- print (root .__dict__ )
170- print (root )
171- print (type (root ))
172- print ('*' * 20 )
173166 if isinstance (root , cls ):
174167 return True
168+ # XXX: Take care FileField
175169 if isinstance (root , mongoengine .GridFSProxy ):
176170 return True
177171 if not is_valid_mongoengine_model (type (root )):
You can’t perform that action at this time.
0 commit comments