elasticgraph-schema_definition 0.18.0.4 → 0.19.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/elasticgraph-schema_definition.gemspec +1 -1
- data/lib/elastic_graph/schema_definition/api.rb +4 -4
- data/lib/elastic_graph/schema_definition/factory.rb +11 -14
- 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 +36 -53
- 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 +33 -14
- 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 +9 -9
- 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 +38 -31
@@ -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
|
@@ -745,7 +742,7 @@ module ElasticGraph
|
|
745
742
|
schema_def_state.factory.new_field(**params).tap do |f|
|
746
743
|
f.documentation derived_documentation(
|
747
744
|
"Used to filter on the `#{name}` field",
|
748
|
-
"
|
745
|
+
"When `null` or an empty object is passed, matches all documents"
|
749
746
|
)
|
750
747
|
|
751
748
|
filter_customizations.each { |c| c.call(f) }
|
@@ -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
|
@@ -200,33 +200,33 @@ module ElasticGraph
|
|
200
200
|
Matches records where the field value is equal to any of the provided values.
|
201
201
|
This works just like an IN operator in SQL.
|
202
202
|
|
203
|
-
|
204
|
-
part of the filter
|
205
|
-
|
203
|
+
When `null` is passed, matches all documents. When an empty list is passed,
|
204
|
+
this part of the filter matches no documents. When `null` is passed in the
|
205
|
+
list, this part of the filter matches records where the field value is `null`.
|
206
206
|
EOS
|
207
207
|
|
208
208
|
GT_DOC = <<~EOS
|
209
209
|
Matches records where the field value is greater than (>) the provided value.
|
210
210
|
|
211
|
-
|
211
|
+
When `null` is passed, matches all documents.
|
212
212
|
EOS
|
213
213
|
|
214
214
|
GTE_DOC = <<~EOS
|
215
215
|
Matches records where the field value is greater than or equal to (>=) the provided value.
|
216
216
|
|
217
|
-
|
217
|
+
When `null` is passed, matches all documents.
|
218
218
|
EOS
|
219
219
|
|
220
220
|
LT_DOC = <<~EOS
|
221
221
|
Matches records where the field value is less than (<) the provided value.
|
222
222
|
|
223
|
-
|
223
|
+
When `null` is passed, matches all documents.
|
224
224
|
EOS
|
225
225
|
|
226
226
|
LTE_DOC = <<~EOS
|
227
227
|
Matches records where the field value is less than or equal to (<=) the provided value.
|
228
228
|
|
229
|
-
|
229
|
+
When `null` is passed, matches all documents.
|
230
230
|
EOS
|
231
231
|
|
232
232
|
def to_input_filters
|
@@ -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
|