File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
backend/family_tree/student Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ class Query(graphene.ObjectType):
28
28
student_sibling = graphene .List (StudentType , roll = graphene .String ())
29
29
student_search = graphene .List (StudentType , search_query = graphene .String ())
30
30
student_batch = graphene .List (graphene .List (StudentType ), roll = graphene .String ())
31
+ student_node = graphene .Field (StudentType , roll = graphene .String ())
32
+
33
+ def resolve_student_node (root ,info ,roll ):
34
+ return Student .objects .get (roll_no = roll )
31
35
32
36
def resolve_students (root ,info ):
33
37
return Student .objects .all ()
Original file line number Diff line number Diff line change @@ -120,4 +120,17 @@ def test_student_search(self):
120
120
self .assertDictEqual (content ['data' ]['studentSearch' ][4 ], {'id' : str (self .student5 .id ), 'name' : self .student5 .name })
121
121
self .assertDictEqual (content ['data' ]['studentSearch' ][5 ], {'id' : str (self .student6 .id ), 'name' : self .student6 .name })
122
122
self .assertDictEqual (content ['data' ]['studentSearch' ][6 ], {'id' : str (self .student7 .id ), 'name' : self .student7 .name })
123
- self .assertDictEqual (content ['data' ]['studentSearch' ][7 ], {'id' : str (self .student8 .id ), 'name' : self .student8 .name })
123
+ self .assertDictEqual (content ['data' ]['studentSearch' ][7 ], {'id' : str (self .student8 .id ), 'name' : self .student8 .name })
124
+
125
+ def test_student_node (self ):
126
+ response = self .query ('''
127
+ query {
128
+ studentNode(roll: "1") {
129
+ id
130
+ name
131
+ }
132
+ }
133
+ ''' )
134
+ content = json .loads (response .content )
135
+ self .assertResponseNoErrors (response )
136
+ self .assertDictEqual (content ['data' ]['studentNode' ], {'id' : str (self .student1 .id ), 'name' : self .student1 .name })
You can’t perform that action at this time.
0 commit comments