Module: GraphQL::Relay::EdgesInstrumentation

Defined in:
lib/graphql/relay/edges_instrumentation.rb

Defined Under Namespace

Classes: EdgesResolve

Class Method Summary collapse

Class Method Details

.instrument(type, field) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/graphql/relay/edges_instrumentation.rb', line 5

def self.instrument(type, field)
  if field.edges?
    edges_resolve = EdgesResolve.new(
      edge_class: field.edge_class,
      resolve: field.resolve_proc,
      lazy_resolve: field.lazy_resolve_proc,
    )

    field.redefine(
      resolve: edges_resolve.method(:resolve),
      lazy_resolve: edges_resolve.method(:lazy_resolve),
    )
  else
    field
  end
end