File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed
Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change 11from __future__ import absolute_import
22
3+ import mongoengine
34from collections import OrderedDict
45from functools import partial , reduce
56
@@ -69,7 +70,6 @@ def args(self):
6970 )
7071 return args
7172
72-
7373 @args .setter
7474 def args (self , args ):
7575 self ._base_args = args
@@ -94,7 +94,7 @@ def reference_args(self):
9494 def get_reference_field (r , kv ):
9595 if callable (getattr (kv [1 ], 'get_type' , None )):
9696 node = kv [1 ].get_type ()._type ._meta
97- if not isinstance ( kv [ 1 ], Dynamic ):
97+ if not issubclass ( node . model , mongoengine . EmbeddedDocument ):
9898 r .update ({kv [0 ]: node .fields ['id' ]._type .of_type ()})
9999 return r
100100 return reduce (get_reference_field , self .fields .items (), {})
Original file line number Diff line number Diff line change @@ -729,7 +729,7 @@ class Query(graphene.ObjectType):
729729 assert json .dumps (result .data , sort_keys = True ) == json .dumps (
730730 expected , sort_keys = True )
731731
732- # @pytest.mark.skip(reason="no way of currently testing this")
732+
733733def test_should_query_with_embedded_document (fixtures ):
734734
735735 class Query (graphene .ObjectType ):
@@ -741,7 +741,10 @@ class Query(graphene.ObjectType):
741741 allProfessors {
742742 edges {
743743 node {
744- vec
744+ vec,
745+ metadata {
746+ firstName
747+ }
745748 }
746749 }
747750 }
@@ -752,7 +755,10 @@ class Query(graphene.ObjectType):
752755 'edges' : [
753756 {
754757 'node' : {
755- 'vec' : [1.0 , 2.3 ]
758+ 'vec' : [1.0 , 2.3 ],
759+ 'metadata' : {
760+ 'firstName' : 'Steven'
761+ }
756762 }
757763
758764 }
@@ -761,6 +767,5 @@ class Query(graphene.ObjectType):
761767 }
762768 schema = graphene .Schema (query = Query )
763769 result = schema .execute (query )
764- print (result .data )
765- # assert not result.errors
766- # assert dict(result.data['allProfessors']) == expected['allProfessors']
770+ assert not result .errors
771+ assert dict (result .data ['allProfessors' ]) == expected ['allProfessors' ]
You can’t perform that action at this time.
0 commit comments