23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/elastic_graph/graphql/aggregation/resolvers/sub_aggregations.rb', line 23
def resolve(field:, object:, args:, context:, lookahead:)
path_segment = PathSegment.for(field: field, lookahead: lookahead)
new_field_path = field_path + [path_segment]
return with(field_path: new_field_path) unless field.type.elasticgraph_category == :nested_sub_aggregation_connection
sub_agg_key = FieldPathEncoder.encode(new_field_path.map(&:name_in_graphql_query))
sub_agg_query = Support::HashUtil.verbose_fetch(sub_aggregations, sub_agg_key).query
RelayConnectionBuilder.build_from_buckets(
query: sub_agg_query,
parent_queries: parent_queries,
schema: schema,
field_path: new_field_path
) { (sub_agg_key, args) }
end
|