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

#can_resolve?(field:, object:) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/elastic_graph/graphql/aggregation/resolvers/grouped_by.rb', line 17

def can_resolve?(field:, object:)
  true
end

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



21
22
23
24
25
26
27
# File 'lib/elastic_graph/graphql/aggregation/resolvers/grouped_by.rb', line 21

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")
  Support::HashUtil.verbose_fetch(bucket_entry, FieldPathEncoder.encode(new_field_path.map(&:name_in_graphql_query)))
end