mentorenwahl/docker/backend/src/mw/schema/vote.cr
2022-01-08 13:29:22 +01:00

32 lines
621 B
Crystal

require "graphql"
module MW
module Schema
@[GraphQL::Object]
class Vote < GraphQL::BaseObject
include Helpers::DbObject
db_object Db::Vote
@[GraphQL::Field]
def student : Student
Student.new(find!.student)
end
@[GraphQL::Field]
def teacher_votes : Array(TeacherVote)
find!.teacher_votes.map { |tv| TeacherVote.new(tv) }
end
end
@[GraphQL::InputObject]
class VoteCreateInput < GraphQL::BaseInputObject
getter teacher_ids
@[GraphQL::Field]
def initialize(@teacher_ids : Array(String))
end
end
end
end