Class: GraphQL::Relay::EdgesInstrumentation::EdgesResolve
- Inherits:
-
Object
- Object
- GraphQL::Relay::EdgesInstrumentation::EdgesResolve
- Defined in:
- lib/graphql/relay/edges_instrumentation.rb
Instance Method Summary collapse
-
#call(obj, args, ctx) ⇒ Object
A user's custom Connection may return a lazy object, if so, handle it later.
-
#initialize(edge_class:, resolve:) ⇒ EdgesResolve
constructor
A new instance of EdgesResolve.
Constructor Details
#initialize(edge_class:, resolve:) ⇒ EdgesResolve
Returns a new instance of EdgesResolve.
20 21 22 23 |
# File 'lib/graphql/relay/edges_instrumentation.rb', line 20 def initialize(edge_class:, resolve:) @edge_class = edge_class @resolve_proc = resolve end |
Instance Method Details
#call(obj, args, ctx) ⇒ Object
A user's custom Connection may return a lazy object, if so, handle it later.
27 28 29 30 31 32 33 34 35 |
# File 'lib/graphql/relay/edges_instrumentation.rb', line 27 def call(obj, args, ctx) parent = ctx.object nodes = @resolve_proc.call(obj, args, ctx) if ctx.schema.lazy?(nodes) nodes else nodes.map { |item| item.is_a?(GraphQL::Pagination::Connection::Edge) ? item : @edge_class.new(item, parent) } end end |