Class: ElasticGraph::SchemaDefinition::Results
- Inherits:
-
Object
- Object
- ElasticGraph::SchemaDefinition::Results
- Includes:
- SchemaArtifacts::ArtifactsHelperMethods
- Defined in:
- lib/elastic_graph/schema_definition/results.rb
Overview
This class is designed to implement the same interface as ElasticGraph::SchemaArtifacts::FromDisk, so that it can be used
Provides the results of defining a schema.
interchangeably with schema artifacts loaded from disk. This allows the artifacts to be used in tests without having to dump them or reload them.
Constant Summary collapse
- STATIC_SCRIPT_REPO =
Scripting::FileSystemRepository.new(::File.join(__dir__.to_s, "scripting", "scripts"))
Instance Method Summary collapse
-
#available_json_schema_versions ⇒ Set<Integer>
Set of available JSON schema versions.
- #current_public_json_schema ⇒ Object
-
#datastore_config ⇒ Hash<String, Object>
The Elasticsearch/OpenSearch configuration dumped as
datastore_config.yaml. - #derived_indexing_type_names ⇒ Object
-
#graphql_schema_string ⇒ String
The generated GraphQL SDL schema string dumped as
schema.graphql. - #json_schema_field_metadata_by_type_and_field_name ⇒ Object
- #json_schema_version_setter_location ⇒ Object
-
#json_schemas_for(version) ⇒ Hash<String, Object>
The JSON schema for the requested version, if available.
-
#latest_json_schema_version ⇒ Hash<String, Object>
The newly generated JSON schema.
- #merge_field_metadata_into_json_schema(json_schema) ⇒ Object
-
#runtime_metadata ⇒ Hash<String, Object>
Runtime metadata used by other parts of ElasticGraph and dumped as
runtime_metadata.yaml. - #unused_deprecated_elements ⇒ Object
Instance Method Details
#available_json_schema_versions ⇒ Set<Integer>
Returns set of available JSON schema versions.
61 62 63 |
# File 'lib/elastic_graph/schema_definition/results.rb', line 61 def available_json_schema_versions @available_json_schema_versions ||= Set[latest_json_schema_version] end |
#current_public_json_schema ⇒ Object
82 83 84 |
# File 'lib/elastic_graph/schema_definition/results.rb', line 82 def current_public_json_schema @current_public_json_schema ||= build_public_json_schema end |
#datastore_config ⇒ Hash<String, Object>
Returns the Elasticsearch/OpenSearch configuration dumped as datastore_config.yaml.
40 41 42 |
# File 'lib/elastic_graph/schema_definition/results.rb', line 40 def datastore_config @datastore_config ||= generate_datastore_config end |
#derived_indexing_type_names ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/elastic_graph/schema_definition/results.rb', line 100 def derived_indexing_type_names @derived_indexing_type_names ||= state .object_types_by_name .values .flat_map { |type| type.derived_indexed_types.map { |dit| dit.destination_type_ref.name } } .to_set end |
#graphql_schema_string ⇒ String
Returns the generated GraphQL SDL schema string dumped as schema.graphql.
35 36 37 |
# File 'lib/elastic_graph/schema_definition/results.rb', line 35 def graphql_schema_string @graphql_schema_string ||= generate_sdl end |
#json_schema_field_metadata_by_type_and_field_name ⇒ Object
76 77 78 79 |
# File 'lib/elastic_graph/schema_definition/results.rb', line 76 def @json_schema_field_metadata_by_type_and_field_name ||= json_schema_indexing_field_types_by_name .transform_values(&:json_schema_field_metadata_by_field_name) end |
#json_schema_version_setter_location ⇒ Object
71 72 73 |
# File 'lib/elastic_graph/schema_definition/results.rb', line 71 def json_schema_version_setter_location state.json_schema_version_setter_location end |
#json_schemas_for(version) ⇒ Hash<String, Object>
Returns the JSON schema for the requested version, if available.
52 53 54 55 56 57 58 |
# File 'lib/elastic_graph/schema_definition/results.rb', line 52 def json_schemas_for(version) unless available_json_schema_versions.include?(version) raise Errors::NotFoundError, "The requested json schema version (#{version}) is not available. Available versions: #{available_json_schema_versions.to_a.join(", ")}." end @latest_versioned_json_schema ||= (current_public_json_schema).json_schema end |
#latest_json_schema_version ⇒ Hash<String, Object>
Returns the newly generated JSON schema.
66 67 68 |
# File 'lib/elastic_graph/schema_definition/results.rb', line 66 def latest_json_schema_version current_public_json_schema[JSON_SCHEMA_VERSION_KEY] end |
#merge_field_metadata_into_json_schema(json_schema) ⇒ Object
87 88 89 |
# File 'lib/elastic_graph/schema_definition/results.rb', line 87 def (json_schema) .(json_schema) end |
#runtime_metadata ⇒ Hash<String, Object>
Returns runtime metadata used by other parts of ElasticGraph and dumped as runtime_metadata.yaml.
45 46 47 |
# File 'lib/elastic_graph/schema_definition/results.rb', line 45 def @runtime_metadata ||= end |
#unused_deprecated_elements ⇒ Object
92 93 94 |
# File 'lib/elastic_graph/schema_definition/results.rb', line 92 def unused_deprecated_elements .unused_deprecated_elements end |