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
60 61 62 |
# File 'lib/graphql_includable/relay/edge_with_node_connection.rb', line 60 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 41 42 43 |
# File 'lib/graphql_includable/relay/edge_with_node_connection.rb', line 35 def fetch_edges # This context is used within Resolver for connections ctx.namespace(:gql_includable)[:resolving] = :edges @loaded_edges ||= @edges_and_nodes.edges_resolver.call(@edges_and_nodes.parent, args, ctx) ctx.namespace(:gql_includable)[:resolving] = nil # Set nodes to make underlying BaseConnection work @nodes = @loaded_edges @loaded_edges end |
#fetch_nodes ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/graphql_includable/relay/edge_with_node_connection.rb', line 45 def fetch_nodes # This context is used within Resolver for connections ctx.namespace(:gql_includable)[:resolving] = :nodes @loaded_nodes ||= @edges_and_nodes.nodes_resolver.call(@edges_and_nodes.parent, args, ctx) ctx.namespace(:gql_includable)[:resolving] = nil # Set nodes to make underlying BaseConnection work @nodes = @loaded_nodes @loaded_nodes end |
#page_info ⇒ Object
55 56 57 58 |
# File 'lib/graphql_includable/relay/edge_with_node_connection.rb', line 55 def page_info @nodes = determine_page_info_nodes super end |
#total_count ⇒ Object
64 65 66 67 |
# File 'lib/graphql_includable/relay/edge_with_node_connection.rb', line 64 def total_count @nodes = determine_page_info_nodes @nodes.size end |