Class: ElasticGraph::SchemaArtifacts::RuntimeMetadata::GraphQLField
- Inherits:
-
Object
- Object
- ElasticGraph::SchemaArtifacts::RuntimeMetadata::GraphQLField
- Defined in:
- lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_field.rb
Constant Summary collapse
- EMPTY =
new(nil, nil, nil)
- NAME_IN_INDEX =
"name_in_index"- RELATION =
"relation"- AGGREGATION_DETAIL =
"computation_detail"
Class Method Summary collapse
Instance Method Summary collapse
-
#needed?(name_in_graphql) ⇒ Boolean
Indicates if we need this field in our dumped runtime metadata, when it has the given ‘name_in_graphql`.
- #to_dumpable_hash ⇒ Object
- #with_computation_detail(empty_bucket_value:, function:) ⇒ Object
Class Method Details
.from_hash(hash) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_field.rb', line 21 def self.from_hash(hash) new( name_in_index: hash[NAME_IN_INDEX], relation: hash[RELATION]&.then { |rel_hash| Relation.from_hash(rel_hash) }, computation_detail: hash[AGGREGATION_DETAIL]&.then { |agg_hash| ComputationDetail.from_hash(agg_hash) } ) end |
Instance Method Details
#needed?(name_in_graphql) ⇒ Boolean
Indicates if we need this field in our dumped runtime metadata, when it has the given ‘name_in_graphql`. Fields that have not been customized in some way do not need to be included in the dumped runtime metadata.
41 42 43 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_field.rb', line 41 def needed?(name_in_graphql) !!relation || !!computation_detail || name_in_index&.!=(name_in_graphql) || false end |
#to_dumpable_hash ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_field.rb', line 29 def to_dumpable_hash { # Keys here are ordered alphabetically; please keep them that way. AGGREGATION_DETAIL => computation_detail&.to_dumpable_hash, NAME_IN_INDEX => name_in_index, RELATION => relation&.to_dumpable_hash } end |
#with_computation_detail(empty_bucket_value:, function:) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_field.rb', line 45 def with_computation_detail(empty_bucket_value:, function:) with(computation_detail: ComputationDetail.new( empty_bucket_value: empty_bucket_value, function: function )) end |