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, nil)
- NAME_IN_INDEX =
"name_in_index"- RELATION =
"relation"- AGGREGATION_DETAIL =
"computation_detail"- RESOLVER =
"resolver"
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
24 25 26 27 28 29 30 31 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_field.rb', line 24 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) }, resolver: hash[RESOLVER]&.then { |res_hash| ConfiguredGraphQLResolver.from_hash(res_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.
46 47 48 49 50 51 52 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_field.rb', line 46 def needed?(name_in_graphql) !!relation || !!computation_detail || name_in_index&.!=(name_in_graphql) || !resolver.nil? || false end |
#to_dumpable_hash ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_field.rb', line 33 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, RESOLVER => resolver&.to_dumpable_hash } end |
#with_computation_detail(empty_bucket_value:, function:) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/graphql_field.rb', line 54 def with_computation_detail(empty_bucket_value:, function:) with(computation_detail: ComputationDetail.new( empty_bucket_value: empty_bucket_value, function: function )) end |