Class: GraphQLIncludable::Relay::EdgeWithNodeConnection
- Inherits:
-
GraphQL::Relay::RelationConnection
- Object
- GraphQL::Relay::RelationConnection
- GraphQLIncludable::Relay::EdgeWithNodeConnection
- Defined in:
- lib/graphql_includable/relay/edge_with_node_connection.rb
Instance Method Summary collapse
- #edge_nodes ⇒ Object
- #edge_to_node(edge) ⇒ Object
- #fetch_edges ⇒ Object
- #fetch_nodes ⇒ Object
-
#initialize(nodes, *args, &block) ⇒ EdgeWithNodeConnection
constructor
A new instance of EdgeWithNodeConnection.
- #page_info ⇒ Object
- #total_count ⇒ Object
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_nodes ⇒ Object
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_edges ⇒ Object
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_nodes ⇒ Object
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_info ⇒ Object
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_count ⇒ Object
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 |