File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
backend/family_tree/student Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -12,17 +12,18 @@ class Meta:
12
12
class Query (graphene .ObjectType ):
13
13
students = graphene .List (StudentType )
14
14
student_path = graphene .List (StudentType , roll = graphene .String ())
15
+
15
16
def resolve_students (root ,info ):
16
17
return Student .objects .all ()
18
+
17
19
def resolve_student_path (root , info , roll ):
18
20
pathObjects = []
19
- while (Student .objects .filter (roll_no = roll )[0 ].parentId != "root" ):
20
- pathObjects .append (Student .objects .filter (roll_no = roll )[0 ])
21
- roll = Student .objects .filter (roll_no = roll )[0 ].parentId
22
- pathObjects .append (Student .objects .filter (roll_no = roll )[0 ])
21
+ while (Student .objects .get (roll_no = roll ).parentId != "root" ):
22
+ k = Student .objects .get (roll_no = roll )
23
+ pathObjects .append (k )
24
+ roll = k .parentId
25
+ pathObjects .append (Student .objects .get (roll_no = roll ))
23
26
return pathObjects
24
-
25
27
26
-
27
28
28
29
schema = graphene .Schema (query = Query )
You can’t perform that action at this time.
0 commit comments