48 lines
986 B
Crystal
48 lines
986 B
Crystal
module Backend
|
|
module API
|
|
module Schema
|
|
@[GraphQL::Object]
|
|
class Teacher < GraphQL::BaseObject
|
|
include Helpers::DbObject
|
|
|
|
db_object Db::Teacher
|
|
|
|
@[GraphQL::Field]
|
|
def user : User
|
|
User.new(find!.user)
|
|
end
|
|
|
|
@[GraphQL::Field]
|
|
def max_students : Int32
|
|
find!.max_students
|
|
end
|
|
|
|
@[GraphQL::Field]
|
|
def skif : Bool
|
|
find!.skif
|
|
end
|
|
end
|
|
|
|
@[GraphQL::InputObject]
|
|
class TeacherInput < GraphQL::BaseInputObject
|
|
getter max_students
|
|
getter skif
|
|
|
|
@[GraphQL::Field]
|
|
def initialize(@max_students : Int32, @skif : Bool)
|
|
end
|
|
end
|
|
|
|
@[GraphQL::InputObject]
|
|
class TeacherCreateInput < TeacherInput
|
|
getter user_id
|
|
|
|
@[GraphQL::Field]
|
|
def initialize(@user_id : Int32, max_students : Int32, skif : Bool)
|
|
super(max_students, skif)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|