Skip to content

Commit 6a5b3a8

Browse files
committed
Add schema definition extension plumbing
1 parent a099965 commit 6a5b3a8

31 files changed

Lines changed: 112 additions & 99 deletions

File tree

Rakefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ end
4646

4747
configure_local_rake_tasks = ->(tasks) do
4848
tasks.schema_element_name_form = :snake_case
49-
tasks.enforce_json_schema_version = false
5049
tasks.index_document_sizes = true
5150
tasks.env_port_mapping = {test: test_port}
5251
tasks.output = schema_def_output

config/schema.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
ElasticGraph.define_schema do |schema|
1010
schema.json_schema_version 1
11+
schema.enforce_json_schema_version false
1112
end
1213

1314
# Note: anytime you add a file to load here, you'll also have to update the list here:

config/site/Rakefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ module ElasticGraph
448448
namespace schema_name do
449449
::ElasticGraph::Local::RakeTasks.new(local_config_yaml: settings_file, path_to_schema: schema_file) do |tasks|
450450
tasks.opensearch_versions = []
451-
tasks.enforce_json_schema_version = false
452451
end
453452

454453
task validate: ["schema_artifacts:dump"] do

config/site/support/doctest_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ module ElasticGraph
8282
artifacts_manager = @api.factory.new_schema_artifact_manager(
8383
schema_definition_results: @api.results,
8484
schema_artifacts_directory: "#{@tmp_dir}/schema_artifacts",
85-
enforce_json_schema_version: true,
8685
output: ::StringIO.new
8786
)
8887

elasticgraph-admin/spec/integration/elastic_graph/admin/index_definition_configurator/for_index_template_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ def fetch_artifact_configuration(schema_artifacts, index_def_name)
167167
factory.new_schema_artifact_manager(
168168
schema_definition_results: schema_def_results,
169169
schema_artifacts_directory: Dir.pwd,
170-
enforce_json_schema_version: true,
171170
output: output_io
172171
).dump_artifacts
173172

elasticgraph-apollo/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,14 @@ index 2943335..26633c3 100644
6464
require "elastic_graph/local/rake_tasks"
6565
require "elastic_graph/query_registry/rake_tasks"
6666
require "rspec/core/rake_task"
67-
@@ -12,6 +13,8 @@ ElasticGraph::Local::RakeTasks.new(
67+
@@ -12,5 +13,7 @@ ElasticGraph::Local::RakeTasks.new(
6868
local_config_yaml: settings_file,
6969
path_to_schema: "#{project_root}/config/schema.rb"
7070
) do |tasks|
7171
+ tasks.schema_definition_extension_modules = [ElasticGraph::Apollo::SchemaDefinition::APIExtension]
7272
+
73-
# Set this to true once you're beyond the prototyping stage.
74-
tasks.enforce_json_schema_version = false
75-
73+
# Determines casing of field names. Can be either `:camelCase` or `:snake_case`.
74+
tasks.schema_element_name_form = :camelCase
7675
```
7776

7877
That's it!
@@ -94,11 +93,16 @@ diff --git a/config/schema.rb b/config/schema.rb
9493
index 015c5fa..362cdcb 100644
9594
--- a/config/schema.rb
9695
+++ b/config/schema.rb
97-
@@ -4,6 +4,8 @@ ElasticGraph.define_schema do |schema|
96+
@@ -4,7 +4,9 @@ ElasticGraph.define_schema do |schema|
9897
# ElasticGraph will tell you when you need to bump this.
9998
schema.json_schema_version 1
100-
99+
-
100+
+
101101
+ schema.target_apollo_federation_version "2.3"
102+
+
103+
# Set this to true once you're beyond the prototyping stage.
104+
schema.enforce_json_schema_version false
105+
-
102106
+
103107
# This registers the elasticgraph-query_registry extension, which can be used to reject queries that
104108
# clients have not registered (and to reject queries that differ from what a client has registered).

elasticgraph-apollo/apollo_tests_implementation/Rakefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ ElasticGraph::SchemaDefinition::RakeTasks.new(
1717
index_document_sizes: false,
1818
path_to_schema: project_root / "config/products_schema.rb",
1919
schema_artifacts_directory: project_root / "config/schema/artifacts",
20-
extension_modules: [ElasticGraph::Apollo::SchemaDefinition::APIExtension],
21-
enforce_json_schema_version: false
20+
extension_modules: [ElasticGraph::Apollo::SchemaDefinition::APIExtension]
2221
)

elasticgraph-apollo/apollo_tests_implementation/config/products_schema.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module ApolloTestImpl
1818
# https://github.com/apollographql/apollo-federation-subgraph-compatibility/blob/2.0.0/COMPATIBILITY.md#products-schema-to-be-implemented-by-library-maintainers
1919
ElasticGraph.define_schema do |schema|
2020
schema.json_schema_version 1
21+
schema.enforce_json_schema_version false
2122
schema.target_apollo_federation_version(federation_version) if federation_version
2223

2324
unless federation_version == "2.0"

elasticgraph-graphql/spec/acceptance/schema_evolution_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def dump_schema_artifacts(json_schema_version:, team_extras: "")
6868
index_document_sizes: true,
6969
path_to_schema: path_to_schema,
7070
schema_artifacts_directory: "config/schema/artifacts",
71-
enforce_json_schema_version: true,
7271
output: output
7372
)
7473
end

elasticgraph-indexer/spec/acceptance/schema_evolution_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ def dump_artifacts
404404
index_document_sizes: true,
405405
path_to_schema: path_to_schema,
406406
schema_artifacts_directory: "config/schema/artifacts",
407-
enforce_json_schema_version: true,
408407
output: output
409408
)
410409
end

0 commit comments

Comments
 (0)