I'm working on this project where I have 3 "tables". 2 of them are independent and one is M:M relationship. However, my database was working fine until I realized it could not liaise the 2 independent table in the 3rd one, so I decided to change up the ids with "_" and make it work like that. However, it keeps returning me the 400 Error and I cant seem to figure out why.
{
"students": [
{
"id": 3021,
"nume": "Name",
"prenume": "Surname",
"an": 3,
"departament": "1"
}
],
"exams": [
{
"id": 1,
"subiect": "Subject",
"data_examen": "02/06/2022 10:00",
"profesor": {
"nume": "Name Surname"
}
}
],
"listexams": [
{
"id": 1,
"exam_id": 1,
"student_id": 3021
}
]
}
Insertion code:
function send() {
dategraph.forEach((graph) => {
deInserat = { examenId: graph.examId, studentId: graph.studentId };
obiectInterogare = {
query: `mutation adaugare($examenId:Int!,$studentId:Int!)
{createListaexamene(examId:$examenId, studentId:$studentId) {id examId studentId}}`,
variables: JSON.stringify(deInserat)
}
textInterogare = JSON.stringify(obiectInterogare)
configurari = {
url: "http://localhost:3000/",
type: "POST",
data: textInterogare,
contentType: "application/json",
success: procesareRaspunsql,
error: (error) => {
console.log('Error', error);
}
}
$.ajax(configurari);
});
}
It's taking the variables from another place but that is working just fine (because it worked prior to changing the fields) but it won't now. Any ideas what it could be?
The error that gets thrown out is
Beware of the implicit GraphQL schema. The reason why it kept throwing out 400 Error is because I had the M:M relationship keys defined as "int!" instead of "ID!".