Skip to content

Commit ea5fc25

Browse files
committed
fix: Set relationship types to list
1 parent 8630a23 commit ea5fc25

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

graphene_mongo/tests/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ class ProfessorVector(Document):
103103
class ParentWithRelationship(Document):
104104

105105
meta = {'collection': 'test_parent_reference'}
106-
before_child = ReferenceField("ChildRegisteredBefore")
107-
after_child = ReferenceField("ChildRegisteredAfter")
106+
before_child = ListField(ReferenceField("ChildRegisteredBefore"))
107+
after_child = ListField(ReferenceField("ChildRegisteredAfter"))
108108
name = StringField()
109109

110110

graphene_mongo/tests/setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ def fixtures():
120120
child3.save()
121121
child4.save()
122122

123-
parent = ParentWithRelationship(name="Yui", before_child=child3, after_child=child4)
123+
parent = ParentWithRelationship(
124+
name="Yui",
125+
before_child=[child3],
126+
after_child=[child4]
127+
)
128+
124129
parent.save()
125130

126131
child3.parent = child4.parent = parent

graphene_mongo/tests/test_relay_query.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,20 @@ class Query(graphene.ObjectType):
665665
edges {
666666
node {
667667
beforeChild {
668-
name,
669-
parent { name }
668+
edges {
669+
node {
670+
name,
671+
parent { name }
672+
}
673+
}
670674
},
671675
afterChild {
672-
name,
673-
parent { name }
676+
edges {
677+
node {
678+
name,
679+
parent { name }
680+
}
681+
}
674682
}
675683
}
676684
}
@@ -683,12 +691,20 @@ class Query(graphene.ObjectType):
683691
"edges": [
684692
{"node": {
685693
"beforeChild": {
686-
"name": "Akari",
687-
"parent": {"name": "Yui"}
694+
"edges": [
695+
{"node": {
696+
"name": "Akari",
697+
"parent": {"name": "Yui"}
698+
}}
699+
]
688700
},
689701
"afterChild": {
690-
"name": "Kyouko",
691-
"parent": {"name": "Yui"}
702+
"edges": [
703+
{"node": {
704+
"name": "Kyouko",
705+
"parent": {"name": "Yui"}
706+
}}
707+
]
692708
}
693709
}}
694710
]

0 commit comments

Comments
 (0)