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):
103
103
104
104
@property
105
105
def reference_args (self ):
106
+ from .advanced_types import FsFile
107
+
106
108
def get_reference_field (r , kv ):
107
109
field = kv [1 ]
108
110
mongo_field = getattr (self .model , kv [0 ], None )
@@ -112,7 +114,7 @@ def get_reference_field(r, kv):
112
114
_type = field .get_type ()
113
115
if _type :
114
116
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 ) ):
116
118
r .update ({kv [0 ]: node .fields ['id' ]._type .of_type ()})
117
119
return r
118
120
Original file line number Diff line number Diff line change @@ -141,7 +141,10 @@ class Query(graphene.ObjectType):
141
141
node {
142
142
id,
143
143
firstName,
144
- lastName
144
+ lastName,
145
+ avatar {
146
+ contentType
147
+ }
145
148
}
146
149
}
147
150
}
@@ -154,22 +157,31 @@ class Query(graphene.ObjectType):
154
157
'node' : {
155
158
'id' : 'RWRpdG9yTm9kZTox' ,
156
159
'firstName' : 'Penny' ,
157
- 'lastName' : 'Hardaway'
160
+ 'lastName' : 'Hardaway' ,
161
+ 'avatar' : {
162
+ 'contentType' : 'image/jpeg'
163
+ }
158
164
}
159
165
},
160
166
{
161
167
'node' : {
162
168
'id' : 'RWRpdG9yTm9kZToy' ,
163
169
'firstName' : 'Grant' ,
164
- 'lastName' : 'Hill'
170
+ 'lastName' : 'Hill' ,
171
+ 'avatar' : {
172
+ 'contentType' : None
173
+ }
165
174
}
166
175
167
176
},
168
177
{
169
178
'node' : {
170
179
'id' : 'RWRpdG9yTm9kZToz' ,
171
180
'firstName' : 'Dennis' ,
172
- 'lastName' : 'Rodman'
181
+ 'lastName' : 'Rodman' ,
182
+ 'avatar' : {
183
+ 'contentType' : None
184
+ }
173
185
}
174
186
}
175
187
]
Original file line number Diff line number Diff line change @@ -163,15 +163,9 @@ def rescan_fields(cls):
163
163
# noqa
164
164
@classmethod
165
165
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 )
173
166
if isinstance (root , cls ):
174
167
return True
168
+ # XXX: Take care FileField
175
169
if isinstance (root , mongoengine .GridFSProxy ):
176
170
return True
177
171
if not is_valid_mongoengine_model (type (root )):
You can’t perform that action at this time.
0 commit comments