Skip to content

Commit 8307340

Browse files
committed
changed filter to "get"
1 parent adfcdf3 commit 8307340

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

backend/family_tree/student/schema.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ class Meta:
1212
class Query(graphene.ObjectType):
1313
students=graphene.List(StudentType)
1414
student_path= graphene.List(StudentType, roll=graphene.String())
15+
1516
def resolve_students(root,info):
1617
return Student.objects.all()
18+
1719
def resolve_student_path(root, info, roll):
1820
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))
2326
return pathObjects
24-
2527

26-
2728

2829
schema=graphene.Schema(query=Query)

0 commit comments

Comments
 (0)