Skip to content

Commit 660ff2d

Browse files
committed
Use JSON ingestion as schema definition extension
1 parent 8f06402 commit 660ff2d

71 files changed

Lines changed: 285 additions & 1045 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: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +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" => [ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension],
55+
"ElasticGraph::JSONIngestion::SchemaDefinition" => [JSONIngestion::SchemaDefinition::APIExtension],
5656
"ElasticGraph::SchemaDefinition" => [],
5757
"ElasticGraph::Warehouse::SchemaDefinition" => [ElasticGraph::Warehouse::SchemaDefinition::APIExtension]
5858
}
@@ -92,16 +92,11 @@ module ElasticGraph
9292
end
9393
end
9494

95-
[
96-
"ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension#json_schema_version",
97-
"ElasticGraph::SchemaDefinition::API#json_schema_version"
98-
].each do |description|
99-
doctest.before description do
100-
ElasticGraph.define_schema do |schema|
101-
# `schema.json_schema_version` raises an error when the version is set more than once.
102-
# By default we set it above. Here we clear it to allow our example to set it.
103-
schema.state.json_schema_version = nil
104-
end
95+
doctest.before "ElasticGraph::JSONIngestion::SchemaDefinition::APIExtension#json_schema_version" do
96+
ElasticGraph.define_schema do |schema|
97+
# `schema.json_schema_version` raises an error when the version is set more than once.
98+
# By default we set it above. Here we clear it to allow our example to set it.
99+
schema.state.json_schema_version = nil
105100
end
106101
end
107102

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/apollo_tests_implementation/Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
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/schema_definition/rake_tasks"
1111
require "pathname"
1212

1313
project_root = Pathname.new(__dir__)

elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/api_extension.rb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,23 +224,20 @@ def define_apollo_schema_elements
224224

225225
apollo_scalar_type "link__Import" do |t|
226226
t.documentation "Scalar type used by the `@link` directive required for Apollo Federation V2."
227-
# `scalar_type` requires we set these but this scalar type is only in GraphQL.
227+
# `scalar_type` requires a mapping but this scalar type is only in GraphQL.
228228
t.mapping type: nil
229-
t.json_schema type: "null"
230229
end
231230

232231
apollo_scalar_type "federation__Scope" do |t|
233232
t.documentation "Scalar type used by the `@requiresScopes` directive required for Apollo Federation V2.5+."
234-
# `scalar_type` requires we set these but this scalar type is only in GraphQL.
233+
# `scalar_type` requires a mapping but this scalar type is only in GraphQL.
235234
t.mapping type: nil
236-
t.json_schema type: "null"
237235
end
238236

239237
apollo_scalar_type "federation__Policy" do |t|
240238
t.documentation "Scalar type used by the `@policy` directive required for Apollo Federation V2.6+."
241-
# `scalar_type` requires we set these but this scalar type is only in GraphQL.
239+
# `scalar_type` requires a mapping but this scalar type is only in GraphQL.
242240
t.mapping type: nil
243-
t.json_schema type: "null"
244241
end
245242

246243
# Copied from https://github.com/apollographql/federation/blob/b3a3cb84d8d67d1d6e817dc85b9ae0ecdd9908d1/docs/source/subgraph-spec.mdx#subgraph-schema-additions
@@ -271,9 +268,8 @@ def define_apollo_schema_elements
271268
Not intended for use by clients other than Apollo.
272269
EOS
273270

274-
# `scalar_type` requires we set these but this scalar type is only in GraphQL.
271+
# `scalar_type` requires a mapping but this scalar type is only in GraphQL.
275272
t.mapping type: nil
276-
t.json_schema type: "null"
277273
end
278274

279275
apollo_scalar_type "_Any" do |t|
@@ -297,9 +293,8 @@ def define_apollo_schema_elements
297293
Not intended for use by clients other than Apollo.
298294
EOS
299295

300-
# `scalar_type` requires we set these but this scalar type is only in GraphQL.
296+
# `scalar_type` requires a mapping but this scalar type is only in GraphQL.
301297
t.mapping type: nil
302-
t.json_schema type: "null"
303298
end
304299

305300
apollo_object_type "_Service" do |t|

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def self.with_both_casing_forms(&block)
5656
schema.scalar_type "Url" do |f|
5757
f.apollo_authenticated
5858
f.mapping type: "keyword"
59-
f.json_schema type: "string"
6059
end
6160
end
6261

@@ -166,7 +165,6 @@ def self.with_both_casing_forms(&block)
166165
schema.scalar_type "Url" do |f|
167166
f.apollo_inaccessible
168167
f.mapping type: "keyword"
169-
f.json_schema type: "string"
170168

171169
f.customize_derived_types "UrlFilterInput" do |dt|
172170
dt.apollo_inaccessible
@@ -319,7 +317,6 @@ def self.with_both_casing_forms(&block)
319317
schema.scalar_type "Url" do |f|
320318
f.apollo_policy(policies: [["Policy1", "Policy2"], ["Policy3"]])
321319
f.mapping type: "keyword"
322-
f.json_schema type: "string"
323320
end
324321
end
325322

@@ -407,7 +404,6 @@ def self.with_both_casing_forms(&block)
407404
schema.scalar_type "Url" do |f|
408405
f.apollo_requires_scopes(scopes: [["Scope1", "Scope2"], ["Scope3"]])
409406
f.mapping type: "keyword"
410-
f.json_schema type: "string"
411407
end
412408
end
413409

@@ -493,7 +489,6 @@ def self.with_both_casing_forms(&block)
493489
schema.scalar_type "Url" do |f|
494490
f.apollo_tag name: "test"
495491
f.mapping type: "keyword"
496-
f.json_schema type: "string"
497492

498493
f.customize_derived_types "UrlFilterInput" do |dt|
499494
dt.apollo_tag name: "test"

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ def self.with_both_casing_forms(&block)
460460
without_apollo_results = define_schema(with_apollo: false) { |s| define_some_types_on(s) }
461461

462462
expect(with_apollo_results.datastore_scripts).to eq(without_apollo_results.datastore_scripts)
463-
expect(with_apollo_results.json_schemas_for(1)).to eq(without_apollo_results.json_schemas_for(1))
464463
expect(with_apollo_results.indices).to eq(without_apollo_results.indices)
465464
expect(with_apollo_results.index_templates).to eq(without_apollo_results.index_templates)
466465

0 commit comments

Comments
 (0)