Sha256: 54e6bf64155d552e2487934e116a9c639737c03147d084da116521b9534893fa

Contents?: true

Size: 483 Bytes

Versions: 3

Compression:

Stored size: 483 Bytes

Contents

# frozen_string_literal: true
GraphQL::STRING_TYPE = GraphQL::ScalarType.define do
  name "String"
  description "Represents textual data as UTF-8 character sequences. This type is most often used by GraphQL to represent free-form human-readable text."

  coerce_result ->(value) {
    str = value.to_s
    str.encoding == Encoding::US_ASCII || str.encoding == Encoding::UTF_8 ? str : nil
  }

  coerce_input ->(value) { value.is_a?(String) ? value : nil }
  default_scalar true
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
graphql-1.5.5 lib/graphql/string_type.rb
graphql-1.5.4 lib/graphql/string_type.rb
graphql-1.5.3 lib/graphql/string_type.rb