-
-
Save DanyF-github/7a81f3ee4f1d415aa42c6a16071280cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server/src/graphql/student.js | |
// import the "database" service | |
const { students } = require('../services/db'); | |
... | |
const saveStudent = async (_, student, __, ___) => { | |
try { | |
// push the new student into the array | |
students.push(student); | |
// return the newly created student | |
return student; | |
} catch (err) { | |
console.error('Error while trying to create student', err); | |
throw new Error(INTERNAL_ERROR); | |
} | |
}; | |
const getStudents = (_, __, ___, ____) => { | |
// return all the students | |
return students; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment