Class: ElasticGraph::GraphQL::ScalarCoercionAdapters::Untyped
- Inherits:
-
Object
- Object
- ElasticGraph::GraphQL::ScalarCoercionAdapters::Untyped
- Defined in:
- lib/elastic_graph/graphql/scalar_coercion_adapters/untyped.rb
Class Method Summary collapse
Class Method Details
.coerce_input(value, ctx) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/elastic_graph/graphql/scalar_coercion_adapters/untyped.rb', line 15 def self.coerce_input(value, ctx) Support::UntypedEncoder.encode(value).tap do |encoded| # Check to see if the encoded form, when parsed as JSON, gives us back the original value. If not, # it's not a valid `Untyped` value! if Support::UntypedEncoder.decode(encoded) != value raise ::GraphQL::CoercionError, "Could not coerce value #{value.inspect} to `Untyped`: not representable as JSON." end end end |
.coerce_result(value, ctx) ⇒ Object
26 27 28 |
# File 'lib/elastic_graph/graphql/scalar_coercion_adapters/untyped.rb', line 26 def self.coerce_result(value, ctx) Support::UntypedEncoder.decode(value) if value.is_a?(::String) end |