Class: ElasticGraph::SchemaArtifacts::RuntimeMetadata::ObjectType
- Inherits:
-
Object
- Object
- ElasticGraph::SchemaArtifacts::RuntimeMetadata::ObjectType
- Defined in:
- lib/elastic_graph/schema_artifacts/runtime_metadata/object_type.rb
Overview
Provides runtime metadata related to object types.
Constant Summary collapse
- UPDATE_TARGETS =
"update_targets"- INDEX_DEFINITION_NAMES =
"index_definition_names"- GRAPHQL_FIELDS_BY_NAME =
"graphql_fields_by_name"- ELASTICGRAPH_CATEGORY =
"elasticgraph_category"- SOURCE_TYPE =
"source_type"- GRAPHQL_ONLY_RETURN_TYPE =
"graphql_only_return_type"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(update_targets:, index_definition_names:, graphql_fields_by_name:, elasticgraph_category:, source_type:, graphql_only_return_type:) ⇒ ObjectType
constructor
A new instance of ObjectType.
- #to_dumpable_hash ⇒ Object
Constructor Details
#initialize(update_targets:, index_definition_names:, graphql_fields_by_name:, elasticgraph_category:, source_type:, graphql_only_return_type:) ⇒ ObjectType
Returns a new instance of ObjectType.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/object_type.rb', line 35 def initialize(update_targets:, index_definition_names:, graphql_fields_by_name:, elasticgraph_category:, source_type:, graphql_only_return_type:) graphql_fields_by_name = graphql_fields_by_name.select { |name, field| field.needed?(name) } super( update_targets: update_targets, index_definition_names: index_definition_names, graphql_fields_by_name: graphql_fields_by_name, elasticgraph_category: elasticgraph_category, source_type: source_type, graphql_only_return_type: graphql_only_return_type ) end |
Class Method Details
.from_hash(hash) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/object_type.rb', line 48 def self.from_hash(hash) update_targets = hash[UPDATE_TARGETS]&.map do |update_target_hash| UpdateTarget.from_hash(update_target_hash) end || [] graphql_fields_by_name = hash[GRAPHQL_FIELDS_BY_NAME]&.transform_values do |field_hash| GraphQLField.from_hash(field_hash) end || {} new( update_targets: update_targets, index_definition_names: hash[INDEX_DEFINITION_NAMES] || [], graphql_fields_by_name: graphql_fields_by_name, elasticgraph_category: hash[ELASTICGRAPH_CATEGORY]&.to_sym || nil, source_type: hash[SOURCE_TYPE] || nil, graphql_only_return_type: !!hash[GRAPHQL_ONLY_RETURN_TYPE] ) end |
Instance Method Details
#to_dumpable_hash ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/elastic_graph/schema_artifacts/runtime_metadata/object_type.rb', line 67 def to_dumpable_hash { # Keys here are ordered alphabetically; please keep them that way. ELASTICGRAPH_CATEGORY => elasticgraph_category&.to_s, GRAPHQL_FIELDS_BY_NAME => HashDumper.dump_hash(graphql_fields_by_name, &:to_dumpable_hash), GRAPHQL_ONLY_RETURN_TYPE => graphql_only_return_type ? true : nil, INDEX_DEFINITION_NAMES => index_definition_names, SOURCE_TYPE => source_type, UPDATE_TARGETS => update_targets.map(&:to_dumpable_hash) } end |