Skip to content

Commit 958ff78

Browse files
authored
Merge branch 'main' into main
2 parents 15c92b3 + 6228ba5 commit 958ff78

File tree

8 files changed

+470
-31212
lines changed

8 files changed

+470
-31212
lines changed

backend/family_tree/student/schema.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import graphene
22
from graphene_django import DjangoObjectType
33
from student.models import Student
4+
from django.db.models import Q
45

56
class StudentType(DjangoObjectType):
67
class Meta:
@@ -13,6 +14,8 @@ class Query(graphene.ObjectType):
1314
students=graphene.List(StudentType)
1415
children=graphene.List(StudentType, parentId=graphene.String())
1516
student_path= graphene.List(StudentType, roll=graphene.String())
17+
student_sibling= graphene.List(StudentType, roll=graphene.String())
18+
student_search= graphene.List(StudentType, search_query=graphene.String())
1619

1720
def resolve_students(root,info):
1821
return Student.objects.all()
@@ -28,5 +31,14 @@ def resolve_student_path(root, info, roll):
2831
roll= student.parentId
2932
pathObjects.append(Student.objects.get(roll_no=roll))
3033
return pathObjects
34+
35+
def resolve_student_sibling(root,info, roll):
36+
student=Student.objects.get(roll_no=roll)
37+
return Student.objects.filter(parentId=student.parentId).exclude(roll_no=roll)
38+
39+
40+
def resolve_student_search(root,info, search_query):
41+
return Student.objects.filter(Q(name__icontains=search_query) | Q(roll_no__icontains= search_query))[0:8]
42+
3143

3244
schema=graphene.Schema(query=Query)

backend/family_tree/student/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def setUp(self):
1818
def test_children_query(self):
1919
response = self.query('''
2020
query {
21-
children(parentId: "1"){
22-
rollNo
21+
students {
22+
id
2323
name
2424
}
2525
}

0 commit comments

Comments
 (0)