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.
21 22 23 24 |
# File 'lib/graphql/relay/edges_instrumentation.rb', line 21 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.
28 29 30 31 32 33 34 35 36 |
# File 'lib/graphql/relay/edges_instrumentation.rb', line 28 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| @edge_class.new(item, parent) } end end |