Class: GraphQLIncludable::Relay::EdgeWithNodeConnection

Inherits:
GraphQL::Relay::RelationConnection
  • Object
show all
Defined in:
lib/graphql_includable/relay/edge_with_node_connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(nodes, *args, &block) ⇒ EdgeWithNodeConnection

Returns a new instance of EdgeWithNodeConnection.



24
25
26
27
28
29
# File 'lib/graphql_includable/relay/edge_with_node_connection.rb', line 24

def initialize(nodes, *args, &block)
  @edges_and_nodes = nodes
  @loaded_nodes = nil
  @loaded_edges = nil
  super(nil, *args, &block)
end

Instance Method Details

#edge_nodesObject



31
32
33
# File 'lib/graphql_includable/relay/edge_with_node_connection.rb', line 31

def edge_nodes
  raise 'This should not be called from a EdgeWithNodeConnectionType'
end

#edge_to_node(edge) ⇒ Object



54
55
56
# File 'lib/graphql_includable/relay/edge_with_node_connection.rb', line 54

def edge_to_node(edge)
  edge.public_send(@edges_and_nodes.edge_to_node_property)
end

#fetch_edgesObject



35
36
37
38
39
40
# File 'lib/graphql_includable/relay/edge_with_node_connection.rb', line 35

def fetch_edges
  @loaded_edges ||= @edges_and_nodes.edges_resolver.call(@edges_and_nodes.parent, args, ctx)
  # Set nodes to make underlying BaseConnection work
  @nodes = @loaded_edges
  @loaded_edges
end

#fetch_nodesObject



42
43
44
45
46
47
# File 'lib/graphql_includable/relay/edge_with_node_connection.rb', line 42

def fetch_nodes
  @loaded_nodes ||= @edges_and_nodes.nodes_resolver.call(@edges_and_nodes.parent, args, ctx)
  # Set nodes to make underlying BaseConnection work
  @nodes = @loaded_nodes
  @loaded_nodes
end

#page_infoObject



49
50
51
52
# File 'lib/graphql_includable/relay/edge_with_node_connection.rb', line 49

def page_info
  @nodes = determin_page_info_nodes
  super
end

#total_countObject



58
59
60
61
# File 'lib/graphql_includable/relay/edge_with_node_connection.rb', line 58

def total_count
  @nodes = determin_page_info_nodes
  @nodes.size
end