20 lines
360 B
Crystal
20 lines
360 B
Crystal
|
require "uuid"
|
||
|
|
||
|
module Backend::Api::Schema::Scalars
|
||
|
@[GraphQL::Scalar]
|
||
|
class UUID < GraphQL::BaseScalar
|
||
|
property value
|
||
|
|
||
|
def initialize(@value : ::UUID)
|
||
|
end
|
||
|
|
||
|
def self.from_json(string_or_io)
|
||
|
self.new(::UUID.from_json(string_or_io))
|
||
|
end
|
||
|
|
||
|
def to_json(builder : JSON::Builder)
|
||
|
builder.scalar(@value.to_s)
|
||
|
end
|
||
|
end
|
||
|
end
|