elasticgraph-schema_definition 0.18.0.3 → 0.18.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/elastic_graph/schema_definition/api.rb +4 -4
- data/lib/elastic_graph/schema_definition/factory.rb +1 -4
- data/lib/elastic_graph/schema_definition/indexing/derived_indexed_type.rb +2 -2
- data/lib/elastic_graph/schema_definition/indexing/field_type/object.rb +2 -2
- data/lib/elastic_graph/schema_definition/indexing/index.rb +5 -5
- data/lib/elastic_graph/schema_definition/mixins/has_subtypes.rb +3 -3
- data/lib/elastic_graph/schema_definition/mixins/has_type_info.rb +2 -2
- data/lib/elastic_graph/schema_definition/mixins/implements_interfaces.rb +2 -2
- data/lib/elastic_graph/schema_definition/mixins/verifies_graphql_name.rb +2 -2
- data/lib/elastic_graph/schema_definition/results.rb +10 -10
- data/lib/elastic_graph/schema_definition/schema_elements/built_in_types.rb +11 -44
- data/lib/elastic_graph/schema_definition/schema_elements/enum_type.rb +3 -3
- data/lib/elastic_graph/schema_definition/schema_elements/enum_value_namer.rb +2 -2
- data/lib/elastic_graph/schema_definition/schema_elements/field.rb +32 -13
- data/lib/elastic_graph/schema_definition/schema_elements/object_type.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/relationship.rb +2 -2
- data/lib/elastic_graph/schema_definition/schema_elements/scalar_type.rb +2 -2
- data/lib/elastic_graph/schema_definition/schema_elements/type_namer.rb +7 -7
- data/lib/elastic_graph/schema_definition/schema_elements/type_reference.rb +4 -4
- data/lib/elastic_graph/schema_definition/schema_elements/type_with_subfields.rb +3 -4
- data/lib/elastic_graph/schema_definition/schema_elements/union_type.rb +3 -3
- data/lib/elastic_graph/schema_definition/scripting/file_system_repository.rb +5 -5
- data/lib/elastic_graph/schema_definition/state.rb +4 -4
- data/lib/elastic_graph/schema_definition/test_support.rb +2 -2
- metadata +22 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bb25d1889af5a97e059d9e3f676b0b3afa2bb42d3669f26a3185edf9a931744
|
4
|
+
data.tar.gz: b7a7a8f7dbb7992925aedb81aa75e12581966f0b2012e831162719fbd4e985f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98d5092178638c639a5e17207d74533db9de54bc423ae7e5889dd0ae8b1db9e41446d9f516dcdcad9306cf48310a51f14f19edbd0aac55670ad393f8bee51579
|
7
|
+
data.tar.gz: d55858c4a7bba00679c6bbc07ee2f1a8d3820858eb2d5b3e5d1855d4acba9829b3cefa540bdfce3143d341949bb24677cb00c87d5c236963e4c0f219e2102434
|
@@ -6,7 +6,7 @@
|
|
6
6
|
#
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
|
-
require "elastic_graph/
|
9
|
+
require "elastic_graph/errors"
|
10
10
|
require "elastic_graph/schema_artifacts/runtime_metadata/extension"
|
11
11
|
require "elastic_graph/schema_definition/mixins/has_readable_to_s_and_inspect"
|
12
12
|
require "elastic_graph/schema_definition/results"
|
@@ -26,7 +26,7 @@ module ElasticGraph
|
|
26
26
|
if (api_instance = ::Thread.current[:ElasticGraph_SchemaDefinition_API_instance])
|
27
27
|
yield api_instance
|
28
28
|
else
|
29
|
-
raise SchemaError, "No active `SchemaDefinition::API` instance is available. " \
|
29
|
+
raise Errors::SchemaError, "No active `SchemaDefinition::API` instance is available. " \
|
30
30
|
"Let ElasticGraph load the schema definition files."
|
31
31
|
end
|
32
32
|
end
|
@@ -314,11 +314,11 @@ module ElasticGraph
|
|
314
314
|
# end
|
315
315
|
def json_schema_version(version)
|
316
316
|
if !version.is_a?(Integer) || version < 1
|
317
|
-
raise SchemaError, "`json_schema_version` must be a positive integer. Specified version: #{version}"
|
317
|
+
raise Errors::SchemaError, "`json_schema_version` must be a positive integer. Specified version: #{version}"
|
318
318
|
end
|
319
319
|
|
320
320
|
if @state.json_schema_version
|
321
|
-
raise SchemaError, "`json_schema_version` can only be set once on a schema. Previously-set version: #{@state.json_schema_version}"
|
321
|
+
raise Errors::SchemaError, "`json_schema_version` can only be set once on a schema. Previously-set version: #{@state.json_schema_version}"
|
322
322
|
end
|
323
323
|
|
324
324
|
@state.json_schema_version = version
|
@@ -285,10 +285,7 @@ module ElasticGraph
|
|
285
285
|
it usually differs from the true distinct value count by less than 7%.
|
286
286
|
EOS
|
287
287
|
|
288
|
-
f.
|
289
|
-
empty_bucket_value: 0,
|
290
|
-
function: :cardinality
|
291
|
-
)
|
288
|
+
f.runtime_metadata_computation_detail empty_bucket_value: 0, function: :cardinality
|
292
289
|
end
|
293
290
|
|
294
291
|
yield type
|
@@ -173,7 +173,7 @@ module ElasticGraph
|
|
173
173
|
# end
|
174
174
|
def immutable_value(field_name, from:, nullable: true, can_change_from_null: false)
|
175
175
|
if !nullable && can_change_from_null
|
176
|
-
raise SchemaError, "`can_change_from_null: true` is not allowed with `nullable: false` (as there would be no `null` values to change from)."
|
176
|
+
raise Errors::SchemaError, "`can_change_from_null: true` is not allowed with `nullable: false` (as there would be no `null` values to change from)."
|
177
177
|
end
|
178
178
|
|
179
179
|
fields << DerivedFields::ImmutableValue.new(
|
@@ -280,7 +280,7 @@ module ElasticGraph
|
|
280
280
|
|
281
281
|
def generate_script
|
282
282
|
if fields.empty?
|
283
|
-
raise SchemaError, "`derive_indexed_type_fields` definition for #{destination_type_ref} (from #{source_type.name}) " \
|
283
|
+
raise Errors::SchemaError, "`derive_indexed_type_fields` definition for #{destination_type_ref} (from #{source_type.name}) " \
|
284
284
|
"has no derived field definitions."
|
285
285
|
end
|
286
286
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
#
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
|
-
require "elastic_graph/
|
9
|
+
require "elastic_graph/errors"
|
10
10
|
require "elastic_graph/support/hash_util"
|
11
11
|
require "elastic_graph/support/memoizable_data"
|
12
12
|
|
@@ -101,7 +101,7 @@ module ElasticGraph
|
|
101
101
|
return if problem_fields.empty?
|
102
102
|
|
103
103
|
field_descriptions = problem_fields.map(&:name).sort.map { |f| "`#{f}`" }.join(", ")
|
104
|
-
raise SchemaError,
|
104
|
+
raise Errors::SchemaError,
|
105
105
|
"`#{type_name}` has #{problem_fields.size} field(s) (#{field_descriptions}) that are `sourced_from` " \
|
106
106
|
"another type and also have JSON schema customizations. Instead, put the JSON schema " \
|
107
107
|
"customizations on the source type's field definitions."
|
@@ -47,7 +47,7 @@ module ElasticGraph
|
|
47
47
|
# @api private
|
48
48
|
def initialize(name, settings, schema_def_state, indexed_type)
|
49
49
|
if name.include?(ROLLOVER_INDEX_INFIX_MARKER)
|
50
|
-
raise SchemaError, "`#{name}` is an invalid index definition name since it contains " \
|
50
|
+
raise Errors::SchemaError, "`#{name}` is an invalid index definition name since it contains " \
|
51
51
|
"`#{ROLLOVER_INDEX_INFIX_MARKER}` which ElasticGraph treats as special."
|
52
52
|
end
|
53
53
|
|
@@ -124,11 +124,11 @@ module ElasticGraph
|
|
124
124
|
|
125
125
|
unless date_and_datetime_types.include?(timestamp_field_path.type.fully_unwrapped.name)
|
126
126
|
date_or_datetime_description = date_and_datetime_types.map { |t| "`#{t}`" }.join(" or ")
|
127
|
-
raise SchemaError, "rollover field `#{timestamp_field_path.full_description}` cannot be used for rollover since it is not a #{date_or_datetime_description} field."
|
127
|
+
raise Errors::SchemaError, "rollover field `#{timestamp_field_path.full_description}` cannot be used for rollover since it is not a #{date_or_datetime_description} field."
|
128
128
|
end
|
129
129
|
|
130
130
|
if timestamp_field_path.type.list?
|
131
|
-
raise SchemaError, "rollover field `#{timestamp_field_path.full_description}` cannot be used for rollover since it is a list field."
|
131
|
+
raise Errors::SchemaError, "rollover field `#{timestamp_field_path.full_description}` cannot be used for rollover since it is a list field."
|
132
132
|
end
|
133
133
|
|
134
134
|
timestamp_field_path.path_parts.each { |f| f.json_schema nullable: false }
|
@@ -172,7 +172,7 @@ module ElasticGraph
|
|
172
172
|
routing_field_path = public_field_path(routing_field_path_name, explanation: "it is referenced as an index `route_with` field")
|
173
173
|
|
174
174
|
unless routing_field_path.type.leaf?
|
175
|
-
raise SchemaError, "shard routing field `#{routing_field_path.full_description}` cannot be used for routing since it is not a leaf field."
|
175
|
+
raise Errors::SchemaError, "shard routing field `#{routing_field_path.full_description}` cannot be used for routing since it is not a leaf field."
|
176
176
|
end
|
177
177
|
|
178
178
|
self.routing_field_path = routing_field_path
|
@@ -304,7 +304,7 @@ module ElasticGraph
|
|
304
304
|
error_msg += " Note: the `#{indexed_type.name}.#{path_parts.first}` definition must come before the `index` call."
|
305
305
|
end
|
306
306
|
|
307
|
-
raise SchemaError, error_msg
|
307
|
+
raise Errors::SchemaError, error_msg
|
308
308
|
end
|
309
309
|
|
310
310
|
def date_and_datetime_types
|
@@ -6,7 +6,7 @@
|
|
6
6
|
#
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
|
-
require "elastic_graph/
|
9
|
+
require "elastic_graph/errors"
|
10
10
|
require "elastic_graph/schema_definition/indexing/field_type/union"
|
11
11
|
require "elastic_graph/schema_definition/schema_elements/list_counts_state"
|
12
12
|
|
@@ -79,7 +79,7 @@ module ElasticGraph
|
|
79
79
|
defs << "on #{st.name}:\n#{field.to_sdl.strip} mapping: #{field.resolve_mapping.inspect}" if st.graphql_fields_by_name.key?(field_name)
|
80
80
|
end
|
81
81
|
|
82
|
-
raise SchemaError,
|
82
|
+
raise Errors::SchemaError,
|
83
83
|
"Conflicting definitions for field `#{field_name}` on the subtypes of `#{name}`. " \
|
84
84
|
"Their definitions must agree. Defs:\n\n#{def_strings.join("\n\n")}"
|
85
85
|
end
|
@@ -102,7 +102,7 @@ module ElasticGraph
|
|
102
102
|
"#{name}: indexed? = #{value}"
|
103
103
|
end
|
104
104
|
|
105
|
-
raise SchemaError,
|
105
|
+
raise Errors::SchemaError,
|
106
106
|
"The #{self.class.name} #{name} has some indexed subtypes, and some non-indexed subtypes. " \
|
107
107
|
"All subtypes must be indexed or all must NOT be indexed. Subtypes:\n" \
|
108
108
|
"#{descriptions.join("\n")}"
|
@@ -103,7 +103,7 @@ module ElasticGraph
|
|
103
103
|
param_diff = (options.keys.to_set - CUSTOMIZABLE_DATASTORE_PARAMS).to_a
|
104
104
|
|
105
105
|
unless param_diff.empty?
|
106
|
-
raise SchemaError, "Some configured mapping overrides are unsupported: #{param_diff.inspect}"
|
106
|
+
raise Errors::SchemaError, "Some configured mapping overrides are unsupported: #{param_diff.inspect}"
|
107
107
|
end
|
108
108
|
|
109
109
|
mapping_options.update(options)
|
@@ -170,7 +170,7 @@ module ElasticGraph
|
|
170
170
|
validatable_json_schema = Support::HashUtil.stringify_keys(options)
|
171
171
|
|
172
172
|
if (error_msg = JSONSchema.strict_meta_schema_validator.validate_with_error_message(validatable_json_schema))
|
173
|
-
raise SchemaError, "Invalid JSON schema options set on #{self}:\n\n#{error_msg}"
|
173
|
+
raise Errors::SchemaError, "Invalid JSON schema options set on #{self}:\n\n#{error_msg}"
|
174
174
|
end
|
175
175
|
|
176
176
|
json_schema_options.update(options)
|
@@ -6,7 +6,7 @@
|
|
6
6
|
#
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
|
-
require "elastic_graph/
|
9
|
+
require "elastic_graph/errors"
|
10
10
|
|
11
11
|
module ElasticGraph
|
12
12
|
module SchemaDefinition
|
@@ -99,7 +99,7 @@ module ElasticGraph
|
|
99
99
|
end
|
100
100
|
|
101
101
|
unless schema_error_messages.empty?
|
102
|
-
raise SchemaError, schema_error_messages.join("\n\n")
|
102
|
+
raise Errors::SchemaError, schema_error_messages.join("\n\n")
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -27,10 +27,10 @@ module ElasticGraph
|
|
27
27
|
#
|
28
28
|
# @param name [String] name of GraphQL schema element
|
29
29
|
# @return [void]
|
30
|
-
# @raise [InvalidGraphQLNameError] if the name is invalid
|
30
|
+
# @raise [Errors::InvalidGraphQLNameError] if the name is invalid
|
31
31
|
def self.verify_name!(name)
|
32
32
|
return if GRAPHQL_NAME_PATTERN.match?(name)
|
33
|
-
raise InvalidGraphQLNameError, "Not a valid GraphQL name: `#{name}`. #{GRAPHQL_NAME_VALIDITY_DESCRIPTION}"
|
33
|
+
raise Errors::InvalidGraphQLNameError, "Not a valid GraphQL name: `#{name}`. #{GRAPHQL_NAME_VALIDITY_DESCRIPTION}"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
9
|
require "elastic_graph/constants"
|
10
|
-
require "elastic_graph/
|
10
|
+
require "elastic_graph/errors"
|
11
11
|
require "elastic_graph/schema_artifacts/runtime_metadata/schema"
|
12
12
|
require "elastic_graph/schema_artifacts/artifacts_helper_methods"
|
13
13
|
require "elastic_graph/schema_definition/indexing/event_envelope"
|
@@ -47,10 +47,10 @@ module ElasticGraph
|
|
47
47
|
|
48
48
|
# @param version [Integer] desired JSON schema version
|
49
49
|
# @return [Hash<String, Object>] the JSON schema for the requested version, if available
|
50
|
-
# @raise [NotFoundError] if the requested JSON schema version is not available
|
50
|
+
# @raise [Errors::NotFoundError] if the requested JSON schema version is not available
|
51
51
|
def json_schemas_for(version)
|
52
52
|
unless available_json_schema_versions.include?(version)
|
53
|
-
raise NotFoundError, "The requested json schema version (#{version}) is not available. Available versions: #{available_json_schema_versions.to_a.join(", ")}."
|
53
|
+
raise Errors::NotFoundError, "The requested json schema version (#{version}) is not available. Available versions: #{available_json_schema_versions.to_a.join(", ")}."
|
54
54
|
end
|
55
55
|
|
56
56
|
@latest_versioned_json_schema ||= merge_field_metadata_into_json_schema(current_public_json_schema).json_schema
|
@@ -241,7 +241,7 @@ module ElasticGraph
|
|
241
241
|
end
|
242
242
|
|
243
243
|
unless full_errors.empty?
|
244
|
-
raise SchemaError, full_errors.join("\n\n")
|
244
|
+
raise Errors::SchemaError, full_errors.join("\n\n")
|
245
245
|
end
|
246
246
|
end
|
247
247
|
end
|
@@ -263,7 +263,7 @@ module ElasticGraph
|
|
263
263
|
def build_public_json_schema
|
264
264
|
json_schema_version = state.json_schema_version
|
265
265
|
if json_schema_version.nil?
|
266
|
-
raise SchemaError, "`json_schema_version` must be specified in the schema. To resolve, add `schema.json_schema_version 1` in a schema definition block."
|
266
|
+
raise Errors::SchemaError, "`json_schema_version` must be specified in the schema. To resolve, add `schema.json_schema_version 1` in a schema definition block."
|
267
267
|
end
|
268
268
|
|
269
269
|
indexed_type_names = state.object_types_by_name.values
|
@@ -319,7 +319,7 @@ module ElasticGraph
|
|
319
319
|
"- The set of #{set.to_a} forms a circular reference chain."
|
320
320
|
end
|
321
321
|
|
322
|
-
raise SchemaError, "Your schema has self-referential types, which are not allowed, since " \
|
322
|
+
raise Errors::SchemaError, "Your schema has self-referential types, which are not allowed, since " \
|
323
323
|
"it prevents the datastore mapping and GraphQL schema generation from terminating:\n" \
|
324
324
|
"#{descriptions.join("\n")}"
|
325
325
|
end
|
@@ -362,13 +362,13 @@ module ElasticGraph
|
|
362
362
|
end
|
363
363
|
|
364
364
|
unless (unknown_type_names = registered_type.derived_type_customizations_by_name.keys - types.map(&:name)).empty?
|
365
|
-
raise SchemaError,
|
365
|
+
raise Errors::SchemaError,
|
366
366
|
"`customize_derived_types` was called on `#{registered_type.name}` with some unrecognized type names " \
|
367
367
|
"(#{unknown_type_names.join(", ")}). Maybe some of the derived GraphQL types are misspelled?"
|
368
368
|
end
|
369
369
|
|
370
370
|
unless (unknown_type_names = registered_type.derived_field_customizations_by_type_and_field_name.keys - types.map(&:name)).empty?
|
371
|
-
raise SchemaError,
|
371
|
+
raise Errors::SchemaError,
|
372
372
|
"`customize_derived_type_fields` was called on `#{registered_type.name}` with some unrecognized type names " \
|
373
373
|
"(#{unknown_type_names.join(", ")}). Maybe some of the derived GraphQL types are misspelled?"
|
374
374
|
end
|
@@ -378,7 +378,7 @@ module ElasticGraph
|
|
378
378
|
field_customizations_by_name = registered_type.derived_field_customizations_by_name_for_type(type)
|
379
379
|
|
380
380
|
if field_customizations_by_name.any? && !type.respond_to?(:graphql_fields_by_name)
|
381
|
-
raise SchemaError,
|
381
|
+
raise Errors::SchemaError,
|
382
382
|
"`customize_derived_type_fields` was called on `#{registered_type.name}` with a type that can " \
|
383
383
|
"never have fields: `#{type.name}`."
|
384
384
|
end
|
@@ -394,7 +394,7 @@ module ElasticGraph
|
|
394
394
|
end
|
395
395
|
|
396
396
|
unless unknown_field_names.empty?
|
397
|
-
raise SchemaError,
|
397
|
+
raise Errors::SchemaError,
|
398
398
|
"`customize_derived_type_fields` was called on `#{registered_type.name}` with some unrecognized field names " \
|
399
399
|
"(#{unknown_field_names.join(", ")}). Maybe one of the field names was misspelled?"
|
400
400
|
end
|
@@ -551,10 +551,7 @@ module ElasticGraph
|
|
551
551
|
t.customize_aggregated_values_type do |avt|
|
552
552
|
# not nullable, since sum(empty_set) == 0
|
553
553
|
avt.field names.approximate_sum, "Float!", graphql_only: true do |f|
|
554
|
-
f.
|
555
|
-
empty_bucket_value: 0,
|
556
|
-
function: :sum
|
557
|
-
)
|
554
|
+
f.runtime_metadata_computation_detail empty_bucket_value: 0, function: :sum
|
558
555
|
|
559
556
|
f.documentation <<~EOS
|
560
557
|
The sum of the field values within this grouping.
|
@@ -574,10 +571,7 @@ module ElasticGraph
|
|
574
571
|
end
|
575
572
|
|
576
573
|
avt.field names.approximate_avg, "Float", graphql_only: true do |f|
|
577
|
-
f.
|
578
|
-
empty_bucket_value: nil,
|
579
|
-
function: :avg
|
580
|
-
)
|
574
|
+
f.runtime_metadata_computation_detail empty_bucket_value: nil, function: :avg
|
581
575
|
|
582
576
|
f.documentation <<~EOS
|
583
577
|
The average (mean) of the field values within this grouping.
|
@@ -855,10 +849,7 @@ module ElasticGraph
|
|
855
849
|
t.customize_aggregated_values_type do |avt|
|
856
850
|
# not nullable, since sum(empty_set) == 0
|
857
851
|
avt.field names.approximate_sum, "Float!", graphql_only: true do |f|
|
858
|
-
f.
|
859
|
-
empty_bucket_value: 0,
|
860
|
-
function: :sum
|
861
|
-
)
|
852
|
+
f.runtime_metadata_computation_detail empty_bucket_value: 0, function: :sum
|
862
853
|
|
863
854
|
f.documentation <<~EOS
|
864
855
|
The (approximate) sum of the field values within this grouping.
|
@@ -870,10 +861,7 @@ module ElasticGraph
|
|
870
861
|
end
|
871
862
|
|
872
863
|
avt.field names.exact_sum, "JsonSafeLong", graphql_only: true do |f|
|
873
|
-
f.
|
874
|
-
empty_bucket_value: 0,
|
875
|
-
function: :sum
|
876
|
-
)
|
864
|
+
f.runtime_metadata_computation_detail empty_bucket_value: 0, function: :sum
|
877
865
|
|
878
866
|
f.documentation <<~EOS
|
879
867
|
The exact sum of the field values within this grouping, if it fits in a `JsonSafeLong`.
|
@@ -902,10 +890,7 @@ module ElasticGraph
|
|
902
890
|
names.exact_max => [:max, "maximum", names.approximate_max, "largest"]
|
903
891
|
}.each do |exact_name, (func, full_name, approx_name, adjective)|
|
904
892
|
avt.field approx_name, "LongString", graphql_only: true do |f|
|
905
|
-
f.
|
906
|
-
empty_bucket_value: nil,
|
907
|
-
function: func
|
908
|
-
)
|
893
|
+
f.runtime_metadata_computation_detail empty_bucket_value: nil, function: func
|
909
894
|
|
910
895
|
f.documentation <<~EOS
|
911
896
|
The #{full_name} of the field values within this grouping.
|
@@ -920,10 +905,7 @@ module ElasticGraph
|
|
920
905
|
end
|
921
906
|
|
922
907
|
avt.field names.approximate_avg, "Float", graphql_only: true do |f|
|
923
|
-
f.
|
924
|
-
empty_bucket_value: nil,
|
925
|
-
function: :avg
|
926
|
-
)
|
908
|
+
f.runtime_metadata_computation_detail empty_bucket_value: nil, function: :avg
|
927
909
|
|
928
910
|
f.documentation <<~EOS
|
929
911
|
The average (mean) of the field values within this grouping.
|
@@ -1424,10 +1406,7 @@ module ElasticGraph
|
|
1424
1406
|
scalar_type.customize_aggregated_values_type do |t|
|
1425
1407
|
# not nullable, since sum(empty_set) == 0
|
1426
1408
|
t.field names.approximate_sum, "Float!", graphql_only: true do |f|
|
1427
|
-
f.
|
1428
|
-
empty_bucket_value: 0,
|
1429
|
-
function: :sum
|
1430
|
-
)
|
1409
|
+
f.runtime_metadata_computation_detail empty_bucket_value: 0, function: :sum
|
1431
1410
|
|
1432
1411
|
f.documentation <<~EOS
|
1433
1412
|
The (approximate) sum of the field values within this grouping.
|
@@ -1439,10 +1418,7 @@ module ElasticGraph
|
|
1439
1418
|
end
|
1440
1419
|
|
1441
1420
|
t.field names.exact_sum, long_type, graphql_only: true do |f|
|
1442
|
-
f.
|
1443
|
-
empty_bucket_value: 0,
|
1444
|
-
function: :sum
|
1445
|
-
)
|
1421
|
+
f.runtime_metadata_computation_detail empty_bucket_value: 0, function: :sum
|
1446
1422
|
|
1447
1423
|
f.documentation <<~EOS
|
1448
1424
|
The exact sum of the field values within this grouping, if it fits in a `#{long_type}`.
|
@@ -1461,10 +1437,7 @@ module ElasticGraph
|
|
1461
1437
|
end
|
1462
1438
|
|
1463
1439
|
t.field names.approximate_avg, "Float", graphql_only: true do |f|
|
1464
|
-
f.
|
1465
|
-
empty_bucket_value: nil,
|
1466
|
-
function: :avg
|
1467
|
-
)
|
1440
|
+
f.runtime_metadata_computation_detail empty_bucket_value: nil, function: :avg
|
1468
1441
|
|
1469
1442
|
f.documentation <<~EOS
|
1470
1443
|
The average (mean) of the field values within this grouping.
|
@@ -1481,10 +1454,7 @@ module ElasticGraph
|
|
1481
1454
|
define_exact_min_and_max_on_aggregated_values(aggregated_values_type, scalar_type, &block)
|
1482
1455
|
|
1483
1456
|
aggregated_values_type.field names.approximate_avg, scalar_type, graphql_only: true do |f|
|
1484
|
-
f.
|
1485
|
-
empty_bucket_value: nil,
|
1486
|
-
function: :avg
|
1487
|
-
)
|
1457
|
+
f.runtime_metadata_computation_detail empty_bucket_value: nil, function: :avg
|
1488
1458
|
|
1489
1459
|
f.documentation <<~EOS
|
1490
1460
|
The average (mean) of the field values within this grouping.
|
@@ -1501,10 +1471,7 @@ module ElasticGraph
|
|
1501
1471
|
discussion = yield(adjective: adjective, full_name: full_name)
|
1502
1472
|
|
1503
1473
|
aggregated_values_type.field name, scalar_type, graphql_only: true do |f|
|
1504
|
-
f.
|
1505
|
-
empty_bucket_value: nil,
|
1506
|
-
function: func
|
1507
|
-
)
|
1474
|
+
f.runtime_metadata_computation_detail empty_bucket_value: nil, function: func
|
1508
1475
|
|
1509
1476
|
f.documentation ["The #{full_name} of the field values within this grouping.", discussion].compact.join("\n\n")
|
1510
1477
|
end
|
@@ -89,11 +89,11 @@ module ElasticGraph
|
|
89
89
|
value_name = schema_def_state.enum_value_namer.name_for(name, value_name.to_s)
|
90
90
|
|
91
91
|
if values_by_name.key?(value_name)
|
92
|
-
raise SchemaError, "Duplicate value on Enum::Type #{name}: #{value_name}"
|
92
|
+
raise Errors::SchemaError, "Duplicate value on Enum::Type #{name}: #{value_name}"
|
93
93
|
end
|
94
94
|
|
95
95
|
if value_name.length > DEFAULT_MAX_KEYWORD_LENGTH
|
96
|
-
raise SchemaError, "Enum value `#{name}.#{value_name}` is too long: it is #{value_name.length} characters but cannot exceed #{DEFAULT_MAX_KEYWORD_LENGTH} characters."
|
96
|
+
raise Errors::SchemaError, "Enum value `#{name}.#{value_name}` is too long: it is #{value_name.length} characters but cannot exceed #{DEFAULT_MAX_KEYWORD_LENGTH} characters."
|
97
97
|
end
|
98
98
|
|
99
99
|
values_by_name[value_name] = schema_def_state.factory.new_enum_value(value_name, alternate_original_name, &block)
|
@@ -127,7 +127,7 @@ module ElasticGraph
|
|
127
127
|
# @return [String] GraphQL SDL form of the enum type
|
128
128
|
def to_sdl
|
129
129
|
if values_by_name.empty?
|
130
|
-
raise SchemaError, "Enum type #{name} has no values, but enums must have at least one value."
|
130
|
+
raise Errors::SchemaError, "Enum type #{name} has no values, but enums must have at least one value."
|
131
131
|
end
|
132
132
|
|
133
133
|
<<~EOS
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
9
|
require "elastic_graph/constants"
|
10
|
-
require "elastic_graph/
|
10
|
+
require "elastic_graph/errors"
|
11
11
|
require "elastic_graph/support/hash_util"
|
12
12
|
|
13
13
|
module ElasticGraph
|
@@ -80,7 +80,7 @@ module ElasticGraph
|
|
80
80
|
def notify_problems(problems)
|
81
81
|
return if problems.empty?
|
82
82
|
|
83
|
-
raise ConfigError, "Provided `enum_value_overrides_by_type_name` have #{problems.size} problem(s):\n\n" \
|
83
|
+
raise Errors::ConfigError, "Provided `enum_value_overrides_by_type_name` have #{problems.size} problem(s):\n\n" \
|
84
84
|
"#{problems.map.with_index(1) { |problem, i| "#{i}. #{problem}" }.join("\n\n")}"
|
85
85
|
end
|
86
86
|
end
|
@@ -37,6 +37,8 @@ module ElasticGraph
|
|
37
37
|
# @return [State] schema definition state
|
38
38
|
# @!attribute [r] graphql_only
|
39
39
|
# @return [Boolean] true if this field exists only in the GraphQL schema and is not indexed
|
40
|
+
# @!attribute [r] name_in_index
|
41
|
+
# @return [String] the name of this field in the datastore index
|
40
42
|
#
|
41
43
|
# @!attribute [rw] original_type
|
42
44
|
# @private
|
@@ -74,7 +76,7 @@ module ElasticGraph
|
|
74
76
|
# @private
|
75
77
|
# @!attribute [rw] singular_name
|
76
78
|
# @private
|
77
|
-
# @!attribute [rw]
|
79
|
+
# @!attribute [rw] computation_detail
|
78
80
|
# @private
|
79
81
|
# @!attribute [rw] non_nullable_in_json_schema
|
80
82
|
# @private
|
@@ -89,8 +91,8 @@ module ElasticGraph
|
|
89
91
|
:filter_customizations, :grouped_by_customizations, :sub_aggregations_customizations,
|
90
92
|
:aggregated_values_customizations, :sort_order_enum_value_customizations,
|
91
93
|
:args, :sortable, :filterable, :aggregatable, :groupable, :graphql_only, :source, :runtime_field_script, :relationship, :singular_name,
|
92
|
-
:
|
93
|
-
:legacy_grouping_schema
|
94
|
+
:computation_detail, :non_nullable_in_json_schema, :backing_indexing_field, :as_input,
|
95
|
+
:legacy_grouping_schema, :name_in_index
|
94
96
|
)
|
95
97
|
include Mixins::HasDocumentation
|
96
98
|
include Mixins::HasDirectives
|
@@ -131,7 +133,7 @@ module ElasticGraph
|
|
131
133
|
# other schema definition APIs, which also use `singular:` instead of `singular_name:`. We include
|
132
134
|
# the `_name` suffix on the attribute for clarity.
|
133
135
|
singular_name: singular,
|
134
|
-
|
136
|
+
name_in_index: name_in_index,
|
135
137
|
non_nullable_in_json_schema: false,
|
136
138
|
backing_indexing_field: backing_indexing_field,
|
137
139
|
as_input: as_input,
|
@@ -139,7 +141,7 @@ module ElasticGraph
|
|
139
141
|
)
|
140
142
|
|
141
143
|
if name != name_in_index && name_in_index&.include?(".") && !graphql_only
|
142
|
-
raise SchemaError, "#{self} has an invalid `name_in_index`: #{name_in_index.inspect}. Only `graphql_only: true` fields can have a `name_in_index` that references a child field."
|
144
|
+
raise Errors::SchemaError, "#{self} has an invalid `name_in_index`: #{name_in_index.inspect}. Only `graphql_only: true` fields can have a `name_in_index` that references a child field."
|
143
145
|
end
|
144
146
|
|
145
147
|
schema_def_state.register_user_defined_field(self)
|
@@ -395,12 +397,12 @@ module ElasticGraph
|
|
395
397
|
# (see Mixins::HasTypeInfo#json_schema)
|
396
398
|
def json_schema(nullable: nil, **options)
|
397
399
|
if options.key?(:type)
|
398
|
-
raise SchemaError, "Cannot override JSON schema type of field `#{name}` with `#{options.fetch(:type)}`"
|
400
|
+
raise Errors::SchemaError, "Cannot override JSON schema type of field `#{name}` with `#{options.fetch(:type)}`"
|
399
401
|
end
|
400
402
|
|
401
403
|
case nullable
|
402
404
|
when true
|
403
|
-
raise SchemaError, "`nullable: true` is not allowed on a field--just declare the GraphQL field as being nullable (no `!` suffix) instead."
|
405
|
+
raise Errors::SchemaError, "`nullable: true` is not allowed on a field--just declare the GraphQL field as being nullable (no `!` suffix) instead."
|
404
406
|
when false
|
405
407
|
self.non_nullable_in_json_schema = true
|
406
408
|
end
|
@@ -478,11 +480,6 @@ module ElasticGraph
|
|
478
480
|
)
|
479
481
|
end
|
480
482
|
|
481
|
-
# @return [String] the name of this field in the datastore index
|
482
|
-
def name_in_index
|
483
|
-
runtime_metadata_graphql_field.name_in_index
|
484
|
-
end
|
485
|
-
|
486
483
|
# @private
|
487
484
|
def to_sdl(type_structure_only: false, default_value_sdl: nil, &arg_selector)
|
488
485
|
if type_structure_only
|
@@ -910,6 +907,28 @@ module ElasticGraph
|
|
910
907
|
mapping_type == "nested"
|
911
908
|
end
|
912
909
|
|
910
|
+
# Records the `ComputationDetail` that should be on the `runtime_metadata_graphql_field`.
|
911
|
+
#
|
912
|
+
# @private
|
913
|
+
def runtime_metadata_computation_detail(empty_bucket_value:, function:)
|
914
|
+
self.computation_detail = SchemaArtifacts::RuntimeMetadata::ComputationDetail.new(
|
915
|
+
empty_bucket_value: empty_bucket_value,
|
916
|
+
function: function
|
917
|
+
)
|
918
|
+
end
|
919
|
+
|
920
|
+
# Lazily creates and returns a GraphQLField using the field's {#name_in_index}, {#computation_detail},
|
921
|
+
# and {#relationship}.
|
922
|
+
#
|
923
|
+
# @private
|
924
|
+
def runtime_metadata_graphql_field
|
925
|
+
SchemaArtifacts::RuntimeMetadata::GraphQLField.new(
|
926
|
+
name_in_index: name_in_index,
|
927
|
+
computation_detail: computation_detail,
|
928
|
+
relation: relationship&.runtime_metadata
|
929
|
+
)
|
930
|
+
end
|
931
|
+
|
913
932
|
private
|
914
933
|
|
915
934
|
def args_sdl(joiner:, after_opening_paren: "", &arg_selector)
|
@@ -988,7 +1007,7 @@ module ElasticGraph
|
|
988
1007
|
when "nested" then :list_filter_input
|
989
1008
|
when "object" then :fields_list_filter_input
|
990
1009
|
else
|
991
|
-
raise SchemaError, <<~EOS
|
1010
|
+
raise Errors::SchemaError, <<~EOS
|
992
1011
|
`#{parent_type.name}.#{name}` is a list-of-objects field, but the mapping type has not been explicitly specified. Elasticsearch and OpenSearch
|
993
1012
|
offer two ways to index list-of-objects fields. It cannot be changed on an existing field without dropping the index and recreating it (losing
|
994
1013
|
any existing indexed data!), and there are nuanced tradeoffs involved here, so ElasticGraph provides no default mapping in this situation.
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
9
|
require "delegate"
|
10
|
-
require "elastic_graph/
|
10
|
+
require "elastic_graph/errors"
|
11
11
|
require "elastic_graph/schema_definition/mixins/has_indices"
|
12
12
|
require "elastic_graph/schema_definition/mixins/has_readable_to_s_and_inspect"
|
13
13
|
require "elastic_graph/schema_definition/mixins/implements_interfaces"
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
9
|
require "delegate"
|
10
|
-
require "elastic_graph/
|
10
|
+
require "elastic_graph/errors"
|
11
11
|
require "elastic_graph/schema_definition/schema_elements/field"
|
12
12
|
require "elastic_graph/support/hash_util"
|
13
13
|
|
@@ -124,7 +124,7 @@ module ElasticGraph
|
|
124
124
|
# end
|
125
125
|
def equivalent_field(path, locally_named: path)
|
126
126
|
if @equivalent_field_paths_by_local_path.key?(locally_named)
|
127
|
-
raise SchemaError, "`equivalent_field` has been called multiple times on `#{parent_type.name}.#{name}` with the same " \
|
127
|
+
raise Errors::SchemaError, "`equivalent_field` has been called multiple times on `#{parent_type.name}.#{name}` with the same " \
|
128
128
|
"`locally_named` value (#{locally_named.inspect}), but each local field can have only one `equivalent_field`."
|
129
129
|
else
|
130
130
|
@equivalent_field_paths_by_local_path[locally_named] = path
|
@@ -73,7 +73,7 @@ module ElasticGraph
|
|
73
73
|
].compact
|
74
74
|
|
75
75
|
if missing.any?
|
76
|
-
raise SchemaError, "Scalar types require `mapping` and `json_schema` to be configured, but `#{name}` lacks #{missing.join(" and ")}."
|
76
|
+
raise Errors::SchemaError, "Scalar types require `mapping` and `json_schema` to be configured, but `#{name}` lacks #{missing.join(" and ")}."
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -85,7 +85,7 @@ module ElasticGraph
|
|
85
85
|
# (see Mixins::HasTypeInfo#mapping)
|
86
86
|
def mapping(**options)
|
87
87
|
self.mapping_type = options.fetch(:type) do
|
88
|
-
raise SchemaError, "Must specify a mapping `type:` on custom scalars but was missing on the `#{name}` type."
|
88
|
+
raise Errors::SchemaError, "Must specify a mapping `type:` on custom scalars but was missing on the `#{name}` type."
|
89
89
|
end
|
90
90
|
|
91
91
|
super
|
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
require "did_you_mean"
|
10
10
|
require "elastic_graph/constants"
|
11
|
-
require "elastic_graph/
|
11
|
+
require "elastic_graph/errors"
|
12
12
|
|
13
13
|
module ElasticGraph
|
14
14
|
module SchemaDefinition
|
@@ -59,7 +59,7 @@ module ElasticGraph
|
|
59
59
|
end
|
60
60
|
|
61
61
|
# Generates a derived type name based on the provided format name and arguments. The given arguments must match
|
62
|
-
# the placeholders in the format. If the format name is unknown or the arguments are invalid, a `ConfigError` is raised.
|
62
|
+
# the placeholders in the format. If the format name is unknown or the arguments are invalid, a `Errors::ConfigError` is raised.
|
63
63
|
#
|
64
64
|
# Note: this does not apply any configured `name_overrides`. It's up to the caller to apply that when desired.
|
65
65
|
#
|
@@ -67,16 +67,16 @@ module ElasticGraph
|
|
67
67
|
def generate_name_for(format_name, **args)
|
68
68
|
format = formats.fetch(format_name) do
|
69
69
|
suggestions = FORMAT_SUGGESTER.correct(format_name).map(&:inspect)
|
70
|
-
raise ConfigError, "Unknown format name: #{format_name.inspect}. Possible alternatives: #{suggestions.join(", ")}."
|
70
|
+
raise Errors::ConfigError, "Unknown format name: #{format_name.inspect}. Possible alternatives: #{suggestions.join(", ")}."
|
71
71
|
end
|
72
72
|
|
73
73
|
expected_placeholders = REQUIRED_PLACEHOLDERS.fetch(format_name)
|
74
74
|
if (missing_placeholders = expected_placeholders - args.keys).any?
|
75
|
-
raise ConfigError, "The arguments (#{args.inspect}) provided for `#{format_name}` format (#{format.inspect}) omits required key(s): #{missing_placeholders.join(", ")}."
|
75
|
+
raise Errors::ConfigError, "The arguments (#{args.inspect}) provided for `#{format_name}` format (#{format.inspect}) omits required key(s): #{missing_placeholders.join(", ")}."
|
76
76
|
end
|
77
77
|
|
78
78
|
if (extra_placeholders = args.keys - expected_placeholders).any?
|
79
|
-
raise ConfigError, "The arguments (#{args.inspect}) provided for `#{format_name}` format (#{format.inspect}) contains extra key(s): #{extra_placeholders.join(", ")}."
|
79
|
+
raise Errors::ConfigError, "The arguments (#{args.inspect}) provided for `#{format_name}` format (#{format.inspect}) contains extra key(s): #{extra_placeholders.join(", ")}."
|
80
80
|
end
|
81
81
|
|
82
82
|
format % args
|
@@ -93,7 +93,7 @@ module ElasticGraph
|
|
93
93
|
# @private
|
94
94
|
def extract_base_from(name, format:)
|
95
95
|
unless REQUIRED_PLACEHOLDERS.fetch(format) == [:base]
|
96
|
-
raise InvalidArgumentValueError, "The `#{format}` format does not support base extraction."
|
96
|
+
raise Errors::InvalidArgumentValueError, "The `#{format}` format does not support base extraction."
|
97
97
|
end
|
98
98
|
|
99
99
|
regexes.fetch(format).match(name)&.captures&.first
|
@@ -228,7 +228,7 @@ module ElasticGraph
|
|
228
228
|
def notify_problems(problems, source_description)
|
229
229
|
return if problems.empty?
|
230
230
|
|
231
|
-
raise ConfigError, "#{source_description} have #{problems.size} problem(s):\n\n" \
|
231
|
+
raise Errors::ConfigError, "#{source_description} have #{problems.size} problem(s):\n\n" \
|
232
232
|
"#{problems.map.with_index(1) { |problem, i| "#{i}. #{problem}" }.join("\n\n")}"
|
233
233
|
end
|
234
234
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
#
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
|
-
require "elastic_graph/
|
9
|
+
require "elastic_graph/errors"
|
10
10
|
require "elastic_graph/schema_artifacts/runtime_metadata/schema_element_names"
|
11
11
|
require "elastic_graph/schema_definition/mixins/verifies_graphql_name"
|
12
12
|
require "elastic_graph/schema_definition/schema_elements/type_namer"
|
@@ -88,7 +88,7 @@ module ElasticGraph
|
|
88
88
|
false
|
89
89
|
else
|
90
90
|
# If we can't determine the type from the name, just raise an error.
|
91
|
-
raise SchemaError, "Type `#{name}` cannot be resolved. Is it misspelled?"
|
91
|
+
raise Errors::SchemaError, "Type `#{name}` cannot be resolved. Is it misspelled?"
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -109,7 +109,7 @@ module ElasticGraph
|
|
109
109
|
true
|
110
110
|
else
|
111
111
|
# If we can't determine the type from the name, just raise an error.
|
112
|
-
raise SchemaError, "Type `#{name}` cannot be resolved. Is it misspelled?"
|
112
|
+
raise Errors::SchemaError, "Type `#{name}` cannot be resolved. Is it misspelled?"
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
@@ -320,7 +320,7 @@ module ElasticGraph
|
|
320
320
|
in [*parent_types, last_parent_type]
|
321
321
|
type_namer.generate_name_for(:SubAggregation, parent_types: parent_types.join, base: last_parent_type)
|
322
322
|
else
|
323
|
-
raise SchemaError, "Unexpected `parent_doc_types`: #{parent_doc_types.inspect}. `parent_doc_types` must not be empty."
|
323
|
+
raise Errors::SchemaError, "Unexpected `parent_doc_types`: #{parent_doc_types.inspect}. `parent_doc_types` must not be empty."
|
324
324
|
end
|
325
325
|
end
|
326
326
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
#
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
|
-
require "elastic_graph/
|
9
|
+
require "elastic_graph/errors"
|
10
10
|
require "elastic_graph/schema_artifacts/runtime_metadata/relation"
|
11
11
|
require "elastic_graph/schema_definition/indexing/field"
|
12
12
|
require "elastic_graph/schema_definition/indexing/field_type/object"
|
@@ -191,7 +191,7 @@ module ElasticGraph
|
|
191
191
|
# end
|
192
192
|
def field(name, type, graphql_only: false, indexing_only: false, **options)
|
193
193
|
if reserved_field_names.include?(name)
|
194
|
-
raise SchemaError, "Invalid field name: `#{self.name}.#{name}`. `#{name}` is reserved for use by " \
|
194
|
+
raise Errors::SchemaError, "Invalid field name: `#{self.name}.#{name}`. `#{name}` is reserved for use by " \
|
195
195
|
"ElasticGraph as a filtering operator. To use it for a field name, add " \
|
196
196
|
"the `schema_element_name_overrides` option (on `ElasticGraph::SchemaDefinition::RakeTasks.new`) to " \
|
197
197
|
"configure an alternate name for the `#{name}` operator."
|
@@ -519,7 +519,7 @@ module ElasticGraph
|
|
519
519
|
def register_field(name, field, registry, registry_type, only_option_to_fix, &to_comparable)
|
520
520
|
if (existing_field = registry[name])
|
521
521
|
field = Field.pick_most_accurate_from(field, existing_field, to_comparable: to_comparable || ->(f) { f }) do
|
522
|
-
raise SchemaError, "Duplicate #{registry_type} field on Type #{self.name}: #{name}. " \
|
522
|
+
raise Errors::SchemaError, "Duplicate #{registry_type} field on Type #{self.name}: #{name}. " \
|
523
523
|
"To resolve this, set `#{only_option_to_fix}: true` on one of the fields."
|
524
524
|
end
|
525
525
|
end
|
@@ -540,7 +540,6 @@ module ElasticGraph
|
|
540
540
|
yield relationship if block_given?
|
541
541
|
|
542
542
|
field.relationship = relationship
|
543
|
-
field.runtime_metadata_graphql_field = field.runtime_metadata_graphql_field.with(relation: relationship.runtime_metadata)
|
544
543
|
|
545
544
|
if dir == :out
|
546
545
|
register_inferred_foreign_key_fields(from_type: [via, foreign_key_type], to_other: ["id", "ID!"], related_type: relationship.related_type)
|
@@ -90,7 +90,7 @@ module ElasticGraph
|
|
90
90
|
type_ref = schema_def_state.type_ref(name.to_s).to_final_form
|
91
91
|
|
92
92
|
if subtype_refs.include?(type_ref)
|
93
|
-
raise SchemaError, "Duplicate subtype on UnionType #{self.name}: #{name}"
|
93
|
+
raise Errors::SchemaError, "Duplicate subtype on UnionType #{self.name}: #{name}"
|
94
94
|
end
|
95
95
|
|
96
96
|
subtype_refs << type_ref
|
@@ -122,7 +122,7 @@ module ElasticGraph
|
|
122
122
|
# @return [String] the formatted GraphQL SDL of the union type
|
123
123
|
def to_sdl
|
124
124
|
if subtype_refs.empty?
|
125
|
-
raise SchemaError, "UnionType type #{name} has no subtypes, but must have at least one."
|
125
|
+
raise Errors::SchemaError, "UnionType type #{name} has no subtypes, but must have at least one."
|
126
126
|
end
|
127
127
|
|
128
128
|
"#{formatted_documentation}union #{name} #{directives_sdl(suffix_with: " ")}= #{subtype_refs.map(&:name).to_a.join(" | ")}"
|
@@ -147,7 +147,7 @@ module ElasticGraph
|
|
147
147
|
def resolve_subtypes
|
148
148
|
subtype_refs.map do |ref|
|
149
149
|
ref.as_object_type || raise(
|
150
|
-
SchemaError, "The subtype `#{ref}` of the UnionType `#{name}` is not a defined object type."
|
150
|
+
Errors::SchemaError, "The subtype `#{ref}` of the UnionType `#{name}` is not a defined object type."
|
151
151
|
)
|
152
152
|
end
|
153
153
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
#
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
|
-
require "elastic_graph/
|
9
|
+
require "elastic_graph/errors"
|
10
10
|
require "elastic_graph/schema_definition/scripting/script"
|
11
11
|
require "elastic_graph/support/memoizable_data"
|
12
12
|
require "pathname"
|
@@ -33,16 +33,16 @@ module ElasticGraph
|
|
33
33
|
def scripts
|
34
34
|
@scripts ||= ::Pathname.new(dir).children.sort.flat_map do |context_dir|
|
35
35
|
unless context_dir.directory?
|
36
|
-
raise InvalidScriptDirectoryError, "`#{dir}` has a file (#{context_dir}) that is not a context directory as expected."
|
36
|
+
raise Errors::InvalidScriptDirectoryError, "`#{dir}` has a file (#{context_dir}) that is not a context directory as expected."
|
37
37
|
end
|
38
38
|
|
39
39
|
context_dir.children.sort.map do |script_file|
|
40
40
|
unless script_file.file?
|
41
|
-
raise InvalidScriptDirectoryError, "`#{dir}` has extra directory nesting (#{script_file}) that is unexpected."
|
41
|
+
raise Errors::InvalidScriptDirectoryError, "`#{dir}` has extra directory nesting (#{script_file}) that is unexpected."
|
42
42
|
end
|
43
43
|
|
44
44
|
language = SUPPORTED_LANGUAGES_BY_EXTENSION[script_file.extname] || raise(
|
45
|
-
InvalidScriptDirectoryError, "`#{dir}` has a file (`#{script_file}`) that has an unrecognized file extension: #{script_file.extname}."
|
45
|
+
Errors::InvalidScriptDirectoryError, "`#{dir}` has a file (`#{script_file}`) that has an unrecognized file extension: #{script_file.extname}."
|
46
46
|
)
|
47
47
|
|
48
48
|
Script.new(
|
@@ -68,7 +68,7 @@ module ElasticGraph
|
|
68
68
|
end.keys
|
69
69
|
|
70
70
|
if duplicate_scoped_names.any?
|
71
|
-
raise InvalidScriptDirectoryError, "`#{dir}` has multiple scripts with the same scoped name, which is not allowed: #{duplicate_scoped_names.join(", ")}."
|
71
|
+
raise Errors::InvalidScriptDirectoryError, "`#{dir}` has multiple scripts with the same scoped name, which is not allowed: #{duplicate_scoped_names.join(", ")}."
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
9
|
require "elastic_graph/constants"
|
10
|
-
require "elastic_graph/
|
10
|
+
require "elastic_graph/errors"
|
11
11
|
require "elastic_graph/schema_definition/factory"
|
12
12
|
require "elastic_graph/schema_definition/mixins/has_readable_to_s_and_inspect"
|
13
13
|
require "elastic_graph/schema_definition/schema_elements/enum_value_namer"
|
@@ -162,7 +162,7 @@ module ElasticGraph
|
|
162
162
|
def user_defined_field_references_by_type_name
|
163
163
|
@user_defined_field_references_by_type_name ||= begin
|
164
164
|
unless user_definition_complete
|
165
|
-
raise SchemaError, "Cannot access `user_defined_field_references_by_type_name` until the schema definition is complete."
|
165
|
+
raise Errors::SchemaError, "Cannot access `user_defined_field_references_by_type_name` until the schema definition is complete."
|
166
166
|
end
|
167
167
|
|
168
168
|
@user_defined_field_references_by_type_name ||= user_defined_fields
|
@@ -197,11 +197,11 @@ module ElasticGraph
|
|
197
197
|
name = (_ = type).name
|
198
198
|
|
199
199
|
if RESERVED_TYPE_NAMES.include?(name)
|
200
|
-
raise SchemaError, "`#{name}` cannot be used as a schema type because it is a reserved name."
|
200
|
+
raise Errors::SchemaError, "`#{name}` cannot be used as a schema type because it is a reserved name."
|
201
201
|
end
|
202
202
|
|
203
203
|
if types_by_name.key?(name)
|
204
|
-
raise SchemaError, "Duplicate definition for type #{name} detected. Each type can only be defined once."
|
204
|
+
raise Errors::SchemaError, "Duplicate definition for type #{name} detected. Each type can only be defined once."
|
205
205
|
end
|
206
206
|
|
207
207
|
additional_type_index[name] = type if additional_type_index
|
@@ -6,7 +6,7 @@
|
|
6
6
|
#
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
|
-
require "elastic_graph/
|
9
|
+
require "elastic_graph/errors"
|
10
10
|
require "elastic_graph/schema_definition/api"
|
11
11
|
require "elastic_graph/schema_artifacts/runtime_metadata/schema_element_names"
|
12
12
|
|
@@ -93,7 +93,7 @@ module ElasticGraph
|
|
93
93
|
|
94
94
|
if type_defs.size >= 2
|
95
95
|
# :nocov: -- only executed when a mistake has been made; causes a failing test.
|
96
|
-
raise SchemaError,
|
96
|
+
raise Errors::SchemaError,
|
97
97
|
"Expected to find 0 or 1 type definition for #{type}, but found #{type_defs.size}. Type defs:\n\n#{type_defs.join("\n\n")}"
|
98
98
|
# :nocov:
|
99
99
|
end
|
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticgraph-schema_definition
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.0.
|
4
|
+
version: 0.18.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myron Marston
|
8
|
+
- Ben VandenBos
|
9
|
+
- Square Engineering
|
8
10
|
autorequire:
|
9
11
|
bindir: exe
|
10
12
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
13
|
+
date: 2024-09-20 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: rubocop-factory_bot
|
@@ -238,70 +240,70 @@ dependencies:
|
|
238
240
|
requirements:
|
239
241
|
- - '='
|
240
242
|
- !ruby/object:Gem::Version
|
241
|
-
version: 0.18.0.
|
243
|
+
version: 0.18.0.5
|
242
244
|
type: :runtime
|
243
245
|
prerelease: false
|
244
246
|
version_requirements: !ruby/object:Gem::Requirement
|
245
247
|
requirements:
|
246
248
|
- - '='
|
247
249
|
- !ruby/object:Gem::Version
|
248
|
-
version: 0.18.0.
|
250
|
+
version: 0.18.0.5
|
249
251
|
- !ruby/object:Gem::Dependency
|
250
252
|
name: elasticgraph-indexer
|
251
253
|
requirement: !ruby/object:Gem::Requirement
|
252
254
|
requirements:
|
253
255
|
- - '='
|
254
256
|
- !ruby/object:Gem::Version
|
255
|
-
version: 0.18.0.
|
257
|
+
version: 0.18.0.5
|
256
258
|
type: :runtime
|
257
259
|
prerelease: false
|
258
260
|
version_requirements: !ruby/object:Gem::Requirement
|
259
261
|
requirements:
|
260
262
|
- - '='
|
261
263
|
- !ruby/object:Gem::Version
|
262
|
-
version: 0.18.0.
|
264
|
+
version: 0.18.0.5
|
263
265
|
- !ruby/object:Gem::Dependency
|
264
266
|
name: elasticgraph-json_schema
|
265
267
|
requirement: !ruby/object:Gem::Requirement
|
266
268
|
requirements:
|
267
269
|
- - '='
|
268
270
|
- !ruby/object:Gem::Version
|
269
|
-
version: 0.18.0.
|
271
|
+
version: 0.18.0.5
|
270
272
|
type: :runtime
|
271
273
|
prerelease: false
|
272
274
|
version_requirements: !ruby/object:Gem::Requirement
|
273
275
|
requirements:
|
274
276
|
- - '='
|
275
277
|
- !ruby/object:Gem::Version
|
276
|
-
version: 0.18.0.
|
278
|
+
version: 0.18.0.5
|
277
279
|
- !ruby/object:Gem::Dependency
|
278
280
|
name: elasticgraph-schema_artifacts
|
279
281
|
requirement: !ruby/object:Gem::Requirement
|
280
282
|
requirements:
|
281
283
|
- - '='
|
282
284
|
- !ruby/object:Gem::Version
|
283
|
-
version: 0.18.0.
|
285
|
+
version: 0.18.0.5
|
284
286
|
type: :runtime
|
285
287
|
prerelease: false
|
286
288
|
version_requirements: !ruby/object:Gem::Requirement
|
287
289
|
requirements:
|
288
290
|
- - '='
|
289
291
|
- !ruby/object:Gem::Version
|
290
|
-
version: 0.18.0.
|
292
|
+
version: 0.18.0.5
|
291
293
|
- !ruby/object:Gem::Dependency
|
292
294
|
name: elasticgraph-support
|
293
295
|
requirement: !ruby/object:Gem::Requirement
|
294
296
|
requirements:
|
295
297
|
- - '='
|
296
298
|
- !ruby/object:Gem::Version
|
297
|
-
version: 0.18.0.
|
299
|
+
version: 0.18.0.5
|
298
300
|
type: :runtime
|
299
301
|
prerelease: false
|
300
302
|
version_requirements: !ruby/object:Gem::Requirement
|
301
303
|
requirements:
|
302
304
|
- - '='
|
303
305
|
- !ruby/object:Gem::Version
|
304
|
-
version: 0.18.0.
|
306
|
+
version: 0.18.0.5
|
305
307
|
- !ruby/object:Gem::Dependency
|
306
308
|
name: graphql
|
307
309
|
requirement: !ruby/object:Gem::Requirement
|
@@ -336,56 +338,56 @@ dependencies:
|
|
336
338
|
requirements:
|
337
339
|
- - '='
|
338
340
|
- !ruby/object:Gem::Version
|
339
|
-
version: 0.18.0.
|
341
|
+
version: 0.18.0.5
|
340
342
|
type: :development
|
341
343
|
prerelease: false
|
342
344
|
version_requirements: !ruby/object:Gem::Requirement
|
343
345
|
requirements:
|
344
346
|
- - '='
|
345
347
|
- !ruby/object:Gem::Version
|
346
|
-
version: 0.18.0.
|
348
|
+
version: 0.18.0.5
|
347
349
|
- !ruby/object:Gem::Dependency
|
348
350
|
name: elasticgraph-datastore_core
|
349
351
|
requirement: !ruby/object:Gem::Requirement
|
350
352
|
requirements:
|
351
353
|
- - '='
|
352
354
|
- !ruby/object:Gem::Version
|
353
|
-
version: 0.18.0.
|
355
|
+
version: 0.18.0.5
|
354
356
|
type: :development
|
355
357
|
prerelease: false
|
356
358
|
version_requirements: !ruby/object:Gem::Requirement
|
357
359
|
requirements:
|
358
360
|
- - '='
|
359
361
|
- !ruby/object:Gem::Version
|
360
|
-
version: 0.18.0.
|
362
|
+
version: 0.18.0.5
|
361
363
|
- !ruby/object:Gem::Dependency
|
362
364
|
name: elasticgraph-elasticsearch
|
363
365
|
requirement: !ruby/object:Gem::Requirement
|
364
366
|
requirements:
|
365
367
|
- - '='
|
366
368
|
- !ruby/object:Gem::Version
|
367
|
-
version: 0.18.0.
|
369
|
+
version: 0.18.0.5
|
368
370
|
type: :development
|
369
371
|
prerelease: false
|
370
372
|
version_requirements: !ruby/object:Gem::Requirement
|
371
373
|
requirements:
|
372
374
|
- - '='
|
373
375
|
- !ruby/object:Gem::Version
|
374
|
-
version: 0.18.0.
|
376
|
+
version: 0.18.0.5
|
375
377
|
- !ruby/object:Gem::Dependency
|
376
378
|
name: elasticgraph-opensearch
|
377
379
|
requirement: !ruby/object:Gem::Requirement
|
378
380
|
requirements:
|
379
381
|
- - '='
|
380
382
|
- !ruby/object:Gem::Version
|
381
|
-
version: 0.18.0.
|
383
|
+
version: 0.18.0.5
|
382
384
|
type: :development
|
383
385
|
prerelease: false
|
384
386
|
version_requirements: !ruby/object:Gem::Requirement
|
385
387
|
requirements:
|
386
388
|
- - '='
|
387
389
|
- !ruby/object:Gem::Version
|
388
|
-
version: 0.18.0.
|
390
|
+
version: 0.18.0.5
|
389
391
|
description:
|
390
392
|
email:
|
391
393
|
- myron@squareup.com
|