class GraphQL::Types::String

Public Class Methods

coerce_input(value, _ctx) click to toggle source
# File lib/graphql/types/string.rb, line 16
def self.coerce_input(value, _ctx)
  value.is_a?(::String) ? value : nil
end
coerce_result(value, ctx) click to toggle source
# File lib/graphql/types/string.rb, line 8
def self.coerce_result(value, ctx)
  str = value.to_s
  str.encoding == Encoding::UTF_8 ? str : str.encode(Encoding::UTF_8)
rescue EncodingError
  err = GraphQL::StringEncodingError.new(str)
  ctx.schema.type_error(err, ctx)
end