Skip to content

Commit ee6f074

Browse files
committed
Use JSON ingestion as schema definition extension
1 parent 4f85649 commit ee6f074

75 files changed

Lines changed: 315 additions & 1022 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CODEBASE_OVERVIEW.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ graph LR;
111111
rackup["rackup"];
112112
rake["rake"];
113113
webrick["webrick"];
114-
elasticgraph-json_ingestion["eg-json_ingestion"];
115114
elasticgraph-schema_artifacts["eg-schema_artifacts"];
116115
graphql["graphql"];
117116
elasticgraph --> elasticgraph-support;
@@ -126,7 +125,6 @@ graph LR;
126125
elasticgraph-local --> webrick;
127126
elasticgraph-schema_definition --> elasticgraph-graphql;
128127
elasticgraph-schema_definition --> elasticgraph-indexer;
129-
elasticgraph-schema_definition --> elasticgraph-json_ingestion;
130128
elasticgraph-schema_definition --> elasticgraph-schema_artifacts;
131129
elasticgraph-schema_definition --> elasticgraph-support;
132130
elasticgraph-schema_definition --> graphql;
@@ -143,7 +141,6 @@ graph LR;
143141
class rackup externalGemCatStyle;
144142
class rake externalGemCatStyle;
145143
class webrick externalGemCatStyle;
146-
class elasticgraph-json_ingestion otherEgGemStyle;
147144
class elasticgraph-schema_artifacts otherEgGemStyle;
148145
class graphql externalGemCatStyle;
149146
click thor href "https://rubygems.org/gems/thor" "Open on RubyGems.org" _blank;

Gemfile.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ PATH
198198
elasticgraph-schema_definition (1.2.1.pre)
199199
elasticgraph-graphql (= 1.2.1.pre)
200200
elasticgraph-indexer (= 1.2.1.pre)
201-
elasticgraph-json_ingestion (= 1.2.1.pre)
202201
elasticgraph-schema_artifacts (= 1.2.1.pre)
203202
elasticgraph-support (= 1.2.1.pre)
204203
graphql (~> 2.6.2)

Rakefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
require "delegate"
1010
require "elastic_graph/apollo/schema_definition/api_extension"
11-
require "elastic_graph/warehouse/schema_definition/api_extension"
11+
require "elastic_graph/json_ingestion/schema_definition/api_extension"
1212
require "elastic_graph/local/rake_tasks"
1313
require "elastic_graph/schema_definition/rake_tasks"
14+
require "elastic_graph/warehouse/schema_definition/api_extension"
1415
require "yaml"
1516

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

5355
tasks.define_fake_data_batch_for(:widgets) do
5456
require "rspec/core" # the factories file expects RSpec to be loaded, so load it.

config/site/Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ module ElasticGraph
433433

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

@@ -460,6 +461,7 @@ module ElasticGraph
460461
# Here we provide a "default Rakefile" for examples that don't have any specialized needs and that aren't trying
461462
# to demonstrate any `Rakefile` APIs.
462463
::ElasticGraph::Local::RakeTasks.new(local_config_yaml: settings_file, path_to_schema: schema_file) do |tasks|
464+
tasks.schema_definition_extension_modules << ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension
463465
tasks.opensearch_versions = []
464466
end
465467
end

config/site/support/doctest_helper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ module ElasticGraph
5252
descriptions_needing_schema_def_api_and_extension_modules = {
5353
"ElasticGraph.define_schema" => [],
5454
"ElasticGraph::Apollo::SchemaDefinition" => [ElasticGraph::Apollo::SchemaDefinition::APIExtension],
55+
"ElasticGraph::JSONIngestion::SchemaDefinition" => [],
5556
"ElasticGraph::SchemaDefinition" => [],
5657
"ElasticGraph::Warehouse::SchemaDefinition" => [ElasticGraph::Warehouse::SchemaDefinition::APIExtension]
5758
}
@@ -61,7 +62,7 @@ module ElasticGraph
6162
@api = SchemaDefinition::API.new(
6263
SchemaArtifacts::RuntimeMetadata::SchemaElementNames.new(form: :camelCase, overrides: {}),
6364
true,
64-
extension_modules: extension_modules
65+
extension_modules: [JSONIngestion::SchemaDefinition::APIExtension] + extension_modules
6566
)
6667

6768
# This is required in all schemas, but we don't want to have to put in all our examples,
@@ -111,6 +112,7 @@ module ElasticGraph
111112
# `schema.json_schema_version` raises an error when the version is set more than once.
112113
# By default we set it above. Here we clear it to allow our example to set it.
113114
schema.state.json_schema_version = nil
115+
schema.state.json_schema_version_setter_location = nil
114116
end
115117
end
116118

elasticgraph-admin/elasticgraph-admin.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Gem::Specification.new do |spec|
4848
spec.add_dependency "rake", "~> 13.4", ">= 13.4.2"
4949

5050
spec.add_development_dependency "elasticgraph-elasticsearch", ElasticGraph::VERSION
51+
spec.add_development_dependency "elasticgraph-json_ingestion", ElasticGraph::VERSION
5152
spec.add_development_dependency "elasticgraph-opensearch", ElasticGraph::VERSION
5253
spec.add_development_dependency "elasticgraph-schema_definition", ElasticGraph::VERSION
5354
end

elasticgraph-apollo/README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,30 @@ index 4a5ef1e..5c16c2b 100644
4949

5050
```
5151

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

5555
```diff
5656
diff --git a/Rakefile b/Rakefile
5757
index 2943335..26633c3 100644
5858
--- a/Rakefile
5959
+++ b/Rakefile
60-
@@ -1,5 +1,6 @@
60+
@@ -1,6 +1,7 @@
6161
project_root = File.expand_path(__dir__)
6262

6363
+require "elastic_graph/apollo/schema_definition/api_extension"
64+
require "elastic_graph/json_ingestion/schema_definition/api_extension"
6465
require "elastic_graph/local/rake_tasks"
6566
require "elastic_graph/query_registry/rake_tasks"
6667
require "rspec/core/rake_task"
67-
@@ -12,5 +13,7 @@ ElasticGraph::Local::RakeTasks.new(
68-
local_config_yaml: settings_file,
69-
path_to_schema: "#{project_root}/config/schema.rb"
70-
) do |tasks|
71-
+ tasks.schema_definition_extension_modules << ElasticGraph::Apollo::SchemaDefinition::APIExtension
72-
+
68+
@@ -16,5 +17,6 @@ ElasticGraph::Local::RakeTasks.new(
7369
# Determines casing of field names. Can be either `:camelCase` or `:snake_case`.
7470
tasks.schema_element_name_form = :camelCase
71+
tasks.schema_definition_extension_modules << ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension
72+
-
73+
+ tasks.schema_definition_extension_modules << ElasticGraph::Apollo::SchemaDefinition::APIExtension
74+
+
75+
# Customizes the names of fields generated by ElasticGraph.
7576
```
7677

7778
That's it!

elasticgraph-apollo/apollo_tests_implementation/Rakefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#
77
# frozen_string_literal: true
88

9-
require "elastic_graph/schema_definition/rake_tasks"
109
require "elastic_graph/apollo/schema_definition/api_extension"
10+
require "elastic_graph/json_ingestion/schema_definition/api_extension"
11+
require "elastic_graph/schema_definition/rake_tasks"
1112
require "pathname"
1213

1314
project_root = Pathname.new(__dir__)
@@ -17,5 +18,8 @@ ElasticGraph::SchemaDefinition::RakeTasks.new(
1718
index_document_sizes: false,
1819
path_to_schema: project_root / "config/products_schema.rb",
1920
schema_artifacts_directory: project_root / "config/schema/artifacts",
20-
extension_modules: [ElasticGraph::Apollo::SchemaDefinition::APIExtension]
21+
extension_modules: [
22+
ElasticGraph::Apollo::SchemaDefinition::APIExtension,
23+
ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension
24+
]
2125
)

elasticgraph-apollo/elasticgraph-apollo.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Gem::Specification.new do |spec|
5252
spec.add_development_dependency "elasticgraph-schema_definition", ElasticGraph::VERSION
5353
spec.add_development_dependency "elasticgraph-admin", ElasticGraph::VERSION
5454
spec.add_development_dependency "elasticgraph-elasticsearch", ElasticGraph::VERSION
55+
spec.add_development_dependency "elasticgraph-json_ingestion", ElasticGraph::VERSION
5556
spec.add_development_dependency "elasticgraph-opensearch", ElasticGraph::VERSION
5657
spec.add_development_dependency "elasticgraph-indexer", ElasticGraph::VERSION
5758
end

elasticgraph-apollo/spec/unit/elastic_graph/apollo/apollo_directives_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# frozen_string_literal: true
88

99
require "elastic_graph/apollo/schema_definition/api_extension"
10+
require "elastic_graph/json_ingestion/schema_definition/api_extension"
1011
require "elastic_graph/spec_support/schema_definition_helpers"
1112

1213
module ElasticGraph
@@ -552,7 +553,7 @@ def self.with_both_casing_forms(&block)
552553
end
553554

554555
def define_schema(&block)
555-
extension_modules = [SchemaDefinition::APIExtension]
556+
extension_modules = [::ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension, SchemaDefinition::APIExtension]
556557
super(schema_element_name_form: schema_element_name_form, extension_modules: extension_modules, &block)
557558
end
558559
end

0 commit comments

Comments
 (0)