mentorenwahl/docker/api/src/api/schema/vote.cr
Dominic Grimm a9fc6a43b1
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Renamed backend to api
2022-01-20 21:17:24 +01:00

32 lines
621 B
Crystal

require "graphql"
module API
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(Int32))
end
end
end
end