Class: ElasticGraph::GraphQL::Aggregation::PathSegment

Inherits:
Data
  • Object
show all
Defined in:
lib/elastic_graph/graphql/aggregation/path_segment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#name_in_graphql_queryObject (readonly)

Returns the value of attribute name_in_graphql_query

Returns:

  • (Object)

    the current value of name_in_graphql_query



12
13
14
# File 'lib/elastic_graph/graphql/aggregation/path_segment.rb', line 12

def name_in_graphql_query
  @name_in_graphql_query
end

#name_in_indexObject (readonly)

Returns the value of attribute name_in_index

Returns:

  • (Object)

    the current value of name_in_index



12
13
14
# File 'lib/elastic_graph/graphql/aggregation/path_segment.rb', line 12

def name_in_index
  @name_in_index
end

Class Method Details

.for(lookahead:, field: nil) ⇒ Object

Factory method that aids in building a ‘PathSegment` for a given `field` and `lookahead` node.



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

def self.for(lookahead:, field: nil)
  ast_node = lookahead.ast_nodes.first # : ::GraphQL::Language::Nodes::Field

  new(
    name_in_graphql_query: ast_node.alias || ast_node.name,
    name_in_index: field&.name_in_index
  )
end