Skip to content

Commit 149acbb

Browse files
committed
test: test_relay_query pass, but make test failed
1 parent 3b7874b commit 149acbb

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

graphene_mongo/fields.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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

graphene_mongo/tests/test_relay_query.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff 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
]

graphene_mongo/types.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff 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)):

0 commit comments

Comments
 (0)