class GraphQL::Types::String
Public Class Methods
(untyped value, GraphQL::Query::Context _ctx) → ::String?
Source
# File lib/graphql/types/string.rb, line 26 def self.coerce_input(value, _ctx) value.is_a?(::String) ? value : nil end
(untyped value, GraphQL::Query::Context ctx) → untyped
Source
# File lib/graphql/types/string.rb, line 11 def self.coerce_result(value, ctx) str = value.to_s if str.encoding == Encoding::UTF_8 || str.ascii_only? str elsif str.frozen? str.encode(Encoding::UTF_8) else str.encode!(Encoding::UTF_8) end rescue EncodingError err = GraphQL::StringEncodingError.new(str, context: ctx) ctx.schema.type_error(err, ctx) end