Class: ElasticGraph::GraphQL::Aggregation::Resolvers::GroupedBy

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_graph/graphql/aggregation/resolvers/grouped_by.rb

Instance Method Summary collapse

Instance Method Details

#resolve(field:, object:, args:, context:, lookahead:) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/elastic_graph/graphql/aggregation/resolvers/grouped_by.rb', line 17

def resolve(field:, object:, args:, context:, lookahead:)
  new_field_path = field_path + [PathSegment.for(field: field, lookahead: lookahead)]
  return with(field_path: new_field_path) if field.type.object?

  bucket_entry = Support::HashUtil.verbose_fetch(bucket, "key")
  value = Support::HashUtil.verbose_fetch(bucket_entry, FieldPathEncoder.encode(new_field_path.map(&:name_in_graphql_query)))

  if field.type.unwrap_fully.name == "Boolean"
    work_around_terms_aggregation_boolean_value(value)
  else
    value
  end
end