Module: ElasticGraph::GraphQL::Resolvers::RelayConnection
- Defined in:
- lib/elastic_graph/graphql/resolvers/relay_connection.rb,
lib/elastic_graph/graphql/resolvers/relay_connection/page_info.rb,
lib/elastic_graph/graphql/resolvers/relay_connection/array_adapter.rb,
lib/elastic_graph/graphql/resolvers/relay_connection/generic_adapter.rb,
lib/elastic_graph/graphql/resolvers/relay_connection/search_response_adapter_builder.rb
Overview
Defines resolver logic related to relay connections. The relay connections spec is here: facebook.github.io/relay/graphql/connections.htm
Defined Under Namespace
Classes: ArrayAdapter, GenericAdapter, PageInfo, SearchResponseAdapterBuilder
Class Method Summary collapse
-
.maybe_wrap(search_response, field:, context:, lookahead:, query:) ⇒ Object
Conditionally wraps the given search response in the appropriate relay connection adapter, if needed.
Class Method Details
.maybe_wrap(search_response, field:, context:, lookahead:, query:) ⇒ Object
Conditionally wraps the given search response in the appropriate relay connection adapter, if needed.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/elastic_graph/graphql/resolvers/relay_connection.rb', line 20 def self.maybe_wrap(search_response, field:, context:, lookahead:, query:) return search_response unless field.type.relay_connection? schema_element_names = context.fetch(:schema_element_names) unless field.type.unwrap_fully.indexed_aggregation? return SearchResponseAdapterBuilder.build_from( schema_element_names: schema_element_names, search_response: search_response, query: query ) end agg_name = lookahead.ast_nodes.first&.alias || lookahead.name Aggregation::Resolvers::RelayConnectionBuilder.build_from_search_response( schema_element_names: schema_element_names, search_response: search_response, query: Support::HashUtil.verbose_fetch(query.aggregations, agg_name) ) end |