I am new to GraphQl and learning it. Currently I have single database Table - student_courses
as shown below:
student_id| student_name | course_code | course_name
1 ABC S-101 DataStructures
1 ABC S-150 NLP
1 ABC S-250 Machine learning
2 PQR S-101 DataStructures
3 XYZ S-101 DataStructures
3 XYZ S-150 NLP
I have mapped the model to single GraphQL object. So I am getting GraphQL API response as individual json objects for each row in table.
I wanted to understand how to group the results of this table by student_id, student_name
and get results in below format:
student_id, student_name, {course_code : course_name}
For eg: 1, "ABC", {"S-101":"DataStructures", "S-150":"NLP", "S-250":"Machine learning"}
My current GraphQL query -
{
student_courses() {
data {
student_id
student_name
course_code
course_name
}
}
}