class ElasticGraph::GraphQL::Resolvers::RelayConnection::ArrayAdapter
here we just adapt it to the ElasticGraph internal resolver interface.
Relay connection adapter for an array. Implemented primarily by ‘GraphQL::Relay::ArrayConnection`;
def self.build(nodes, args, schema_element_names, context)
def self.build(nodes, args, schema_element_names, context) # ElasticGraph supports any schema elements (like a `first` argument) being renamed, # but `GraphQL::Relay::ArrayConnection` would not understand a renamed argument. # Here we map the args back to the canonical relay args so `ArrayConnection` can # understand them. relay_args = [:first, :after, :last, :before].to_h do |arg_name| [arg_name, args[schema_element_names.public_send(arg_name)]] end.compact graphql_impl = ::GraphQL::Pagination::ArrayConnection.new(nodes || [], context: context, **relay_args) new(schema_element_names, graphql_impl) end
def edges
def edges @edges ||= graphql_impl.nodes.map do |node| Edge.new(schema_element_names, graphql_impl, node) end end
def nodes
def nodes @nodes ||= graphql_impl.nodes end
def page_info
def page_info self end
def total_edge_count
def total_edge_count graphql_impl.nodes.size end