32 lines
621 B
Crystal
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
|