Class: ElasticGraph::GraphQL::ScalarCoercionAdapters::Cursor

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

Class Method Summary collapse

Class Method Details

.coerce_input(value, ctx) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/elastic_graph/graphql/scalar_coercion_adapters/cursor.rb', line 15

def self.coerce_input(value, ctx)
  case value
  when DecodedCursor
    value
  when ::String
    DecodedCursor.try_decode(value)
  end
end

.coerce_result(value, ctx) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/elastic_graph/graphql/scalar_coercion_adapters/cursor.rb', line 24

def self.coerce_result(value, ctx)
  case value
  when DecodedCursor
    value.encode
  when ::String
    value if DecodedCursor.try_decode(value)
  end
end