Student
Discipline
Enrollment
_id
name
course
_id
_id
discipline_id
student_id
name
code
Student
Discipline
Enrollment
_id
course
_id
_id
discipline_id
student_id
name
code
Student
_id
name
course
nova
disciplina
novo
aluno
nova
matrícula
schema.graphql
Student.ts
createStudent.ts
Handler
- listenCreation
- listenDeletion
StudentHandler
- listenUpdates
- cancelUpdates
Define:
- tipos
- métodos
API
Sink
type Student {
_id: ID!
name: String!
email: String!
course: String!
}
type Query {
getStudent(_id: ID!): Student!
}
type Mutation {
createStudent(name: String!, ...): Student!
updateStudent(_id: ID!, name: String!, ...): Student!
deleteStudent(_id: ID!): Student!
}
const StudentSchema: Schema = new Schema({
_id: String,
name: String,
email: String,
course: String,
});
const Student = model<Student>('Student', StudentSchema);
async function createStudent(_: any, args: any, ctx: any, __: any): Promise<Student> {
// ...
validate(args);
const student = {
_id: uuidv4(),
...args,
}
const e = new CreatedStudentEvent(student);
stan.publish(e.topic, e.serialized());
return student;
}
export default createStudent;