Module: ElasticGraph::GraphQL::Aggregation::Resolvers::RelayConnectionBuilder
- Defined in:
- lib/elastic_graph/graphql/aggregation/resolvers/relay_connection_builder.rb
Class Method Summary collapse
- .build_from_buckets(query:, parent_queries:, schema_element_names:, field_path: [], &build_buckets) ⇒ Object
- .build_from_search_response(query:, search_response:, schema_element_names:) ⇒ Object
Class Method Details
.build_from_buckets(query:, parent_queries:, schema_element_names:, field_path: [], &build_buckets) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/elastic_graph/graphql/aggregation/resolvers/relay_connection_builder.rb', line 24 def self.build_from_buckets(query:, parent_queries:, schema_element_names:, field_path: [], &build_buckets) GraphQL::Resolvers::RelayConnection::GenericAdapter.new( schema_element_names: schema_element_names, raw_nodes: raw_nodes_for(query, parent_queries, schema_element_names, field_path, &build_buckets), paginator: query.paginator, get_total_edge_count: -> {}, to_sort_value: ->(node, decoded_cursor) do query.groupings.map do |grouping| DatastoreQuery::Paginator::SortValue.new( from_item: (_ = node).bucket.fetch("key").fetch(grouping.key), from_cursor: decoded_cursor.sort_values.fetch(grouping.key), sort_direction: :asc # we don't yet support any alternate sorting. ) end end ) end |
.build_from_search_response(query:, search_response:, schema_element_names:) ⇒ Object
18 19 20 21 22 |
# File 'lib/elastic_graph/graphql/aggregation/resolvers/relay_connection_builder.rb', line 18 def self.build_from_search_response(query:, search_response:, schema_element_names:) build_from_buckets(query: query, parent_queries: [], schema_element_names: schema_element_names) do extract_buckets_from(search_response, for_query: query) end end |