49 lines
850 B
Crystal
49 lines
850 B
Crystal
require "graphql"
|
|
|
|
module API
|
|
module Schema
|
|
@[GraphQL::Object]
|
|
class Student < GraphQL::BaseObject
|
|
include Helpers::DbObject
|
|
|
|
db_object Db::Student
|
|
|
|
@[GraphQL::Field]
|
|
def user : User
|
|
User.new(find!.user)
|
|
end
|
|
|
|
@[GraphQL::Field]
|
|
def skif : Bool
|
|
find!.skif
|
|
end
|
|
|
|
@[GraphQL::Field]
|
|
def vote : Vote?
|
|
vote = find!.vote
|
|
|
|
Vote.new(vote) if vote
|
|
end
|
|
end
|
|
|
|
@[GraphQL::InputObject]
|
|
class StudentInput < GraphQL::BaseInputObject
|
|
getter skif
|
|
|
|
@[GraphQL::Field]
|
|
def initialize(@skif : Bool)
|
|
end
|
|
end
|
|
|
|
@[GraphQL::InputObject]
|
|
class StudentCreateInput < StudentInput
|
|
getter user_id
|
|
|
|
@[GraphQL::Field]
|
|
def initialize(@user_id : Int32, skif : Bool)
|
|
super(skif)
|
|
end
|
|
end
|
|
end
|
|
end
|