Class: GraphQL::Types::String
- Inherits:
-
Schema::Scalar
- Object
- Schema::Member
- Schema::Scalar
- GraphQL::Types::String
- Defined in:
- lib/graphql/types/string.rb
Constant Summary
Constants included from Schema::Member::HasDirectives
Schema::Member::HasDirectives::NO_DIRECTIVES
Constants included from Schema::Member::GraphQLTypeNames
Schema::Member::GraphQLTypeNames::Boolean, Schema::Member::GraphQLTypeNames::ID, Schema::Member::GraphQLTypeNames::Int
Instance Attribute Summary
Attributes included from Schema::Member::BaseDSLMethods
Class Method Summary collapse
Methods inherited from Schema::Scalar
default_scalar, default_scalar?, kind, specified_by_url, validate_non_null_input
Methods included from Schema::Member::ValidatesInput
#coerce_isolated_input, #coerce_isolated_result, #valid_input?, #valid_isolated_input?, #validate_input
Methods included from Schema::Member::BaseDSLMethods
#authorized?, #description, #graphql_name, #introspection, #introspection?, #mutation, #name, #visible?
Methods included from Schema::Member::BaseDSLMethods::ConfigurationExtension
Methods included from Schema::Member::TypeSystemHelpers
#initialize, #kind, #list?, #non_null?, #to_list_type, #to_non_null_type, #to_type_signature
Methods included from Schema::Member::Scoped
Methods included from Schema::Member::RelayShortcuts
#connection_type, #connection_type_class, #edge_type, #edge_type_class
Methods included from Schema::Member::HasPath
Methods included from Schema::Member::HasAstNode
Methods included from Schema::Member::HasDirectives
add_directive, #directive, #directives, get_directives, #remove_directive, remove_directive
Class Method Details
.coerce_input(value, _ctx) ⇒ Object
22 23 24 |
# File 'lib/graphql/types/string.rb', line 22 def self.coerce_input(value, _ctx) value.is_a?(::String) ? value : nil end |
.coerce_result(value, ctx) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/graphql/types/string.rb', line 8 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 |