class GraphQLIncludable::Relay::EdgeWithNodeConnection
Public Class Methods
new(nodes, *args, &block)
click to toggle source
Calls superclass method
# 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
Public Instance Methods
edge_nodes()
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
Calls superclass method
# File lib/graphql_includable/relay/edge_with_node_connection.rb, line 55 def page_info @nodes = determine_page_info_nodes super end
total_count()
click to toggle source
# File lib/graphql_includable/relay/edge_with_node_connection.rb, line 64 def total_count @nodes = determine_page_info_nodes @nodes.size end
Private Instance Methods
args()
click to toggle source
# File lib/graphql_includable/relay/edge_with_node_connection.rb, line 71 def args @edges_and_nodes.args end
ctx()
click to toggle source
# File lib/graphql_includable/relay/edge_with_node_connection.rb, line 75 def ctx @edges_and_nodes.ctx end
determine_page_info_nodes()
click to toggle source
# File lib/graphql_includable/relay/edge_with_node_connection.rb, line 79 def determine_page_info_nodes # If the query asks for `pageInfo` before `edges` or `nodes`, we dont directly know which to use most # efficently. We can have a guess by checking if either of the associations are preloaded return @loaded_nodes if @loaded_nodes.present? return @loaded_edges if @loaded_edges.present? if @edges_and_nodes.nodes_property.present? nodes_preloaded = @edges_and_nodes.parent.association(@edges_and_nodes.nodes_property).loaded? return fetch_nodes if nodes_preloaded end if @edges_and_nodes.edges_property.present? edges_preloaded = @edges_and_nodes.parent.association(@edges_and_nodes.edges_property).loaded? return fetch_edges if edges_preloaded end fetch_nodes end