Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions CODEBASE_OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ graph LR;
rackup["rackup"];
rake["rake"];
webrick["webrick"];
elasticgraph-json_ingestion["eg-json_ingestion"];
elasticgraph-schema_artifacts["eg-schema_artifacts"];
graphql["graphql"];
elasticgraph --> elasticgraph-support;
Expand All @@ -126,7 +125,6 @@ graph LR;
elasticgraph-local --> webrick;
elasticgraph-schema_definition --> elasticgraph-graphql;
elasticgraph-schema_definition --> elasticgraph-indexer;
elasticgraph-schema_definition --> elasticgraph-json_ingestion;
elasticgraph-schema_definition --> elasticgraph-schema_artifacts;
elasticgraph-schema_definition --> elasticgraph-support;
elasticgraph-schema_definition --> graphql;
Expand All @@ -143,7 +141,6 @@ graph LR;
class rackup externalGemCatStyle;
class rake externalGemCatStyle;
class webrick externalGemCatStyle;
class elasticgraph-json_ingestion otherEgGemStyle;
class elasticgraph-schema_artifacts otherEgGemStyle;
class graphql externalGemCatStyle;
click thor href "https://rubygems.org/gems/thor" "Open on RubyGems.org" _blank;
Expand Down
1 change: 0 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ PATH
elasticgraph-schema_definition (1.2.1.pre)
elasticgraph-graphql (= 1.2.1.pre)
elasticgraph-indexer (= 1.2.1.pre)
elasticgraph-json_ingestion (= 1.2.1.pre)
elasticgraph-schema_artifacts (= 1.2.1.pre)
elasticgraph-support (= 1.2.1.pre)
graphql (~> 2.6.2)
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

require "delegate"
require "elastic_graph/apollo/schema_definition/api_extension"
require "elastic_graph/warehouse/schema_definition/api_extension"
require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/local/rake_tasks"
require "elastic_graph/schema_definition/rake_tasks"
require "elastic_graph/warehouse/schema_definition/api_extension"
require "yaml"

project_root = File.expand_path(__dir__)
Expand Down Expand Up @@ -49,6 +50,7 @@ configure_local_rake_tasks = ->(tasks) do
tasks.index_document_sizes = true
tasks.env_port_mapping = {test: test_port}
tasks.output = schema_def_output
tasks.schema_definition_extension_modules << ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension

tasks.define_fake_data_batch_for(:widgets) do
require "rspec/core" # the factories file expects RSpec to be loaded, so load it.
Expand Down
2 changes: 2 additions & 0 deletions config/site/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ module ElasticGraph

# When we are releasing gems, these dependencies aren't available.
unless ENV["BUNDLE_GEMFILE"].to_s.end_with?("config/release/Gemfile")
require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/local/rake_tasks"
require "elastic_graph/query_registry/rake_tasks"

Expand Down Expand Up @@ -460,6 +461,7 @@ module ElasticGraph
# Here we provide a "default Rakefile" for examples that don't have any specialized needs and that aren't trying
# to demonstrate any `Rakefile` APIs.
::ElasticGraph::Local::RakeTasks.new(local_config_yaml: settings_file, path_to_schema: schema_file) do |tasks|
tasks.schema_definition_extension_modules << ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension
tasks.opensearch_versions = []
end
end
Expand Down
20 changes: 19 additions & 1 deletion config/site/support/doctest_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# frozen_string_literal: true

require "elastic_graph/apollo/schema_definition/api_extension"
require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/schema_artifacts/runtime_metadata/schema_element_names"
require "elastic_graph/schema_definition/api"
require "elastic_graph/schema_definition/schema_artifact_manager"
Expand Down Expand Up @@ -51,6 +52,7 @@ module ElasticGraph
descriptions_needing_schema_def_api_and_extension_modules = {
"ElasticGraph.define_schema" => [],
"ElasticGraph::Apollo::SchemaDefinition" => [ElasticGraph::Apollo::SchemaDefinition::APIExtension],
"ElasticGraph::JSONIngestion::SchemaDefinition" => [],
"ElasticGraph::SchemaDefinition" => [],
"ElasticGraph::Warehouse::SchemaDefinition" => [ElasticGraph::Warehouse::SchemaDefinition::APIExtension]
}
Expand All @@ -60,7 +62,7 @@ module ElasticGraph
@api = SchemaDefinition::API.new(
SchemaArtifacts::RuntimeMetadata::SchemaElementNames.new(form: :camelCase, overrides: {}),
true,
extension_modules: extension_modules
extension_modules: [JSONIngestion::SchemaDefinition::APIExtension] + extension_modules
)

# This is required in all schemas, but we don't want to have to put in all our examples,
Expand Down Expand Up @@ -90,11 +92,27 @@ module ElasticGraph
end
end

doctest.before "ElasticGraph::JSONIngestion::SchemaDefinition" do
@api = SchemaDefinition::API.new(
SchemaArtifacts::RuntimeMetadata::SchemaElementNames.new(form: :camelCase, overrides: {}),
true,
extension_modules: [JSONIngestion::SchemaDefinition::APIExtension]
)

@api.json_schema_version 1
::Thread.current[:ElasticGraph_SchemaDefinition_API_instance] = @api
end

doctest.after "ElasticGraph::JSONIngestion::SchemaDefinition" do
::Thread.current[:ElasticGraph_SchemaDefinition_API_instance] = nil
end

doctest.before "ElasticGraph::SchemaDefinition::API#json_schema_version" do
ElasticGraph.define_schema do |schema|
# `schema.json_schema_version` raises an error when the version is set more than once.
# By default we set it above. Here we clear it to allow our example to set it.
schema.state.json_schema_version = nil
schema.state.json_schema_version_setter_location = nil
end
end

Expand Down
1 change: 1 addition & 0 deletions elasticgraph-admin/elasticgraph-admin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "rake", "~> 13.4", ">= 13.4.2"

spec.add_development_dependency "elasticgraph-elasticsearch", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-json_ingestion", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-opensearch", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-schema_definition", ElasticGraph::VERSION
end
19 changes: 10 additions & 9 deletions elasticgraph-apollo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,30 @@ index 4a5ef1e..5c16c2b 100644

```

Finally, update `Rakefile` so that `ElasticGraph::GraphQL::Apollo::SchemaDefinition::APIExtension` is
used as one of the `extension_modules`:
Finally, update `Rakefile` so that `ElasticGraph::Apollo::SchemaDefinition::APIExtension` is
used as one of the `schema_definition_extension_modules`:

```diff
diff --git a/Rakefile b/Rakefile
index 2943335..26633c3 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,5 +1,6 @@
@@ -1,6 +1,7 @@
project_root = File.expand_path(__dir__)

+require "elastic_graph/apollo/schema_definition/api_extension"
require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/local/rake_tasks"
require "elastic_graph/query_registry/rake_tasks"
require "rspec/core/rake_task"
@@ -12,5 +13,7 @@ ElasticGraph::Local::RakeTasks.new(
local_config_yaml: settings_file,
path_to_schema: "#{project_root}/config/schema.rb"
) do |tasks|
+ tasks.schema_definition_extension_modules << ElasticGraph::Apollo::SchemaDefinition::APIExtension
+
@@ -16,5 +17,6 @@ ElasticGraph::Local::RakeTasks.new(
# Determines casing of field names. Can be either `:camelCase` or `:snake_case`.
tasks.schema_element_name_form = :camelCase
tasks.schema_definition_extension_modules << ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension
-
+ tasks.schema_definition_extension_modules << ElasticGraph::Apollo::SchemaDefinition::APIExtension
+
# Customizes the names of fields generated by ElasticGraph.
```

That's it!
Expand Down
8 changes: 6 additions & 2 deletions elasticgraph-apollo/apollo_tests_implementation/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#
# frozen_string_literal: true

require "elastic_graph/schema_definition/rake_tasks"
require "elastic_graph/apollo/schema_definition/api_extension"
require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/schema_definition/rake_tasks"
require "pathname"

project_root = Pathname.new(__dir__)
Expand All @@ -17,5 +18,8 @@ ElasticGraph::SchemaDefinition::RakeTasks.new(
index_document_sizes: false,
path_to_schema: project_root / "config/products_schema.rb",
schema_artifacts_directory: project_root / "config/schema/artifacts",
extension_modules: [ElasticGraph::Apollo::SchemaDefinition::APIExtension]
extension_modules: [
ElasticGraph::Apollo::SchemaDefinition::APIExtension,
ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension
]
)
1 change: 1 addition & 0 deletions elasticgraph-apollo/elasticgraph-apollo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "elasticgraph-schema_definition", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-admin", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-elasticsearch", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-json_ingestion", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-opensearch", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-indexer", ElasticGraph::VERSION
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# frozen_string_literal: true

require "elastic_graph/apollo/schema_definition/api_extension"
require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/spec_support/schema_definition_helpers"

module ElasticGraph
Expand Down Expand Up @@ -552,7 +553,7 @@ def self.with_both_casing_forms(&block)
end

def define_schema(&block)
extension_modules = [SchemaDefinition::APIExtension]
extension_modules = [::ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension, SchemaDefinition::APIExtension]
super(schema_element_name_form: schema_element_name_form, extension_modules: extension_modules, &block)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# frozen_string_literal: true

require "elastic_graph/apollo/schema_definition/api_extension"
require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/spec_support/runtime_metadata_support"
require "elastic_graph/spec_support/schema_definition_helpers"
require "graphql"
Expand Down Expand Up @@ -1431,7 +1432,8 @@ def expect_identifiable_type_tagging_of_token(&type_def_for)
end

def define_schema(with_apollo: true, &block)
extension_modules = with_apollo ? [SchemaDefinition::APIExtension] : []
extension_modules = [::ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension]
extension_modules += [SchemaDefinition::APIExtension] if with_apollo
super(schema_element_name_form: schema_element_name_form, extension_modules: extension_modules, &block)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "elasticgraph-admin", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-elasticsearch", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-json_ingestion", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-opensearch", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-schema_definition", ElasticGraph::VERSION
end
1 change: 1 addition & 0 deletions elasticgraph-graphql/elasticgraph-graphql.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "elasticgraph-admin", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-elasticsearch", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-json_ingestion", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-opensearch", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-indexer", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-schema_definition", ElasticGraph::VERSION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

require "elastic_graph/graphql"
require "elastic_graph/indexer"
require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/schema_definition/rake_tasks"
require "support/graphql"

Expand Down Expand Up @@ -65,6 +66,7 @@ def dump_schema_artifacts(json_schema_version:, team_extras: "")
run_rake "schema_artifacts:dump" do |output|
SchemaDefinition::RakeTasks.new(
schema_element_name_form: :snake_case,
extension_modules: [JSONIngestion::SchemaDefinition::APIExtension],
index_document_sizes: true,
path_to_schema: path_to_schema,
schema_artifacts_directory: "config/schema/artifacts",
Expand Down
1 change: 1 addition & 0 deletions elasticgraph-indexer/elasticgraph-indexer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "elasticgraph-admin", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-elasticsearch", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-json_ingestion", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-opensearch", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-schema_definition", ElasticGraph::VERSION
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# frozen_string_literal: true

require "elastic_graph/indexer"
require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/schema_definition/rake_tasks"

module ElasticGraph
Expand Down Expand Up @@ -401,6 +402,7 @@ def dump_artifacts
run_rake "schema_artifacts:dump" do |output|
SchemaDefinition::RakeTasks.new(
schema_element_name_form: :snake_case,
extension_modules: [JSONIngestion::SchemaDefinition::APIExtension],
index_document_sizes: true,
path_to_schema: path_to_schema,
schema_artifacts_directory: "config/schema/artifacts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,11 @@ def build_preparer_for_old_json_schema_version(v1_def:, v2_def:)
end

def define_schema(&schema_definition)
super(schema_element_name_form: "snake_case", &schema_definition)
super(
schema_element_name_form: "snake_case",
extension_modules: [JSONIngestion::SchemaDefinition::APIExtension],
&schema_definition
)
end
end

Expand Down
7 changes: 2 additions & 5 deletions elasticgraph-json_ingestion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

JSON Schema ingestion support for ElasticGraph.

This gem contains the JSON Schema helper code used by schema definition to generate indexing
event schemas and merge ElasticGraph metadata into versioned schema artifacts.
This gem provides the schema-definition extension that generates JSON Schema artifacts for indexing
events and validates JSON-ingestion-specific schema options.

## Dependency Diagram

Expand All @@ -17,7 +17,4 @@ graph LR;
elasticgraph-support["elasticgraph-support"];
elasticgraph-json_ingestion --> elasticgraph-support;
class elasticgraph-support otherEgGemStyle;
elasticgraph-schema_definition["elasticgraph-schema_definition"];
elasticgraph-schema_definition --> elasticgraph-json_ingestion;
class elasticgraph-schema_definition otherEgGemStyle;
```
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Gem::Specification.new do |spec|

spec.add_dependency "elasticgraph-support", ElasticGraph::VERSION

# This gem's schema-definition extension code references `elasticgraph-schema_definition`, but
# applications load it through schema-definition tasks after `elasticgraph-schema_definition` is already
# available. Keeping this as a development dependency avoids a runtime dependency cycle.
# This gem's extension code references `elasticgraph-schema_definition`, but applications load it
# through schema-definition tasks after `elasticgraph-schema_definition` is already available.
# Keeping it as a development dependency avoids pulling schema definition into runtime bundles.
spec.add_development_dependency "elasticgraph-schema_definition", ElasticGraph::VERSION
end
Loading
Loading