Class: ElasticGraph::GraphQL::Aggregation::QueryAdapter
- Inherits:
-
Object
- Object
- ElasticGraph::GraphQL::Aggregation::QueryAdapter
- Defined in:
- lib/elastic_graph/graphql/aggregation/query_adapter.rb
Overview
Responsible for taking in the incoming GraphQL request context, arguments, and the GraphQL schema and directives and populating the ‘aggregations` portion of `query`.
Instance Attribute Summary collapse
-
#element_names ⇒ Object
readonly
Returns the value of attribute element_names.
Instance Method Summary collapse
Instance Attribute Details
#element_names ⇒ Object (readonly)
Returns the value of attribute element_names.
28 29 30 |
# File 'lib/elastic_graph/graphql/aggregation/query_adapter.rb', line 28 def element_names @element_names end |
Instance Method Details
#call(query:, lookahead:, args:, field:, context:) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/elastic_graph/graphql/aggregation/query_adapter.rb', line 30 def call(query:, lookahead:, args:, field:, context:) return query unless field.type.unwrap_fully.indexed_aggregation? aggregations_node = extract_aggregation_node(lookahead, field, context.query) return query unless aggregations_node aggregation_query = build_aggregation_query_for( aggregations_node, field: field, grouping_adapter: CompositeGroupingAdapter, # Filters on root aggregations applied to the search query body itself instead of # using a filter aggregation, like sub-aggregations do, so we don't want a filter # aggregation generated here. unfiltered: true ) query.merge_with(aggregations: {aggregation_query.name => aggregation_query}) end |