Class: ElasticGraph::GraphQL::ScalarCoercionAdapters::LongString

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_graph/graphql/scalar_coercion_adapters/longs.rb

Class Method Summary collapse

Class Method Details

.coerce_input(value, ctx) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/elastic_graph/graphql/scalar_coercion_adapters/longs.rb', line 33

def self.coerce_input(value, ctx)
  # Do not allow non-string input, to guard against the value potentially having been rounded off by
  # the client before it got serialized into a JSON request.
  return nil unless value.is_a?(::String)

  Longs.to_ruby_int_in_range(value, LONG_STRING_MIN, LONG_STRING_MAX)
end

.coerce_result(value, ctx) ⇒ Object



41
42
43
# File 'lib/elastic_graph/graphql/scalar_coercion_adapters/longs.rb', line 41

def self.coerce_result(value, ctx)
  Longs.to_ruby_int_in_range(value, LONG_STRING_MIN, LONG_STRING_MAX)&.to_s
end