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.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/elasticgraph-schema_definition.gemspec +1 -1
  3. data/lib/elastic_graph/schema_definition/api.rb +4 -4
  4. data/lib/elastic_graph/schema_definition/factory.rb +11 -14
  5. data/lib/elastic_graph/schema_definition/indexing/derived_indexed_type.rb +2 -2
  6. data/lib/elastic_graph/schema_definition/indexing/field_type/object.rb +2 -2
  7. data/lib/elastic_graph/schema_definition/indexing/index.rb +5 -5
  8. data/lib/elastic_graph/schema_definition/mixins/has_subtypes.rb +3 -3
  9. data/lib/elastic_graph/schema_definition/mixins/has_type_info.rb +2 -2
  10. data/lib/elastic_graph/schema_definition/mixins/implements_interfaces.rb +2 -2
  11. data/lib/elastic_graph/schema_definition/mixins/verifies_graphql_name.rb +2 -2
  12. data/lib/elastic_graph/schema_definition/results.rb +10 -10
  13. data/lib/elastic_graph/schema_definition/schema_elements/built_in_types.rb +36 -53
  14. data/lib/elastic_graph/schema_definition/schema_elements/enum_type.rb +3 -3
  15. data/lib/elastic_graph/schema_definition/schema_elements/enum_value_namer.rb +2 -2
  16. data/lib/elastic_graph/schema_definition/schema_elements/field.rb +33 -14
  17. data/lib/elastic_graph/schema_definition/schema_elements/object_type.rb +1 -1
  18. data/lib/elastic_graph/schema_definition/schema_elements/relationship.rb +2 -2
  19. data/lib/elastic_graph/schema_definition/schema_elements/scalar_type.rb +9 -9
  20. data/lib/elastic_graph/schema_definition/schema_elements/type_namer.rb +7 -7
  21. data/lib/elastic_graph/schema_definition/schema_elements/type_reference.rb +4 -4
  22. data/lib/elastic_graph/schema_definition/schema_elements/type_with_subfields.rb +3 -4
  23. data/lib/elastic_graph/schema_definition/schema_elements/union_type.rb +3 -3
  24. data/lib/elastic_graph/schema_definition/scripting/file_system_repository.rb +5 -5
  25. data/lib/elastic_graph/schema_definition/state.rb +4 -4
  26. data/lib/elastic_graph/schema_definition/test_support.rb +2 -2
  27. metadata +38 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5627aa4be4d0968f9d34d9374b4423713c2cba88e5bbfbc4a4fedea676a906f7
4
- data.tar.gz: e04375010eb75f80087bb3396da2915de2a6d78f9c17840a9861a33790efb75e
3
+ metadata.gz: 8b41786d54c947a50ab0b4cba23f68d2a70c4a49341b12e0733acc5a79bbe1e8
4
+ data.tar.gz: 1b4315922c6310b88773120c22a94bb2de7ae16087d2f1e6bd14efa3b2da3529
5
5
  SHA512:
6
- metadata.gz: 4e0cfe74e08755d2886f7fd0aedc037b6999d170e1b377a51a29b4774a39b31e51693af4700e0ea8d37133c14fb57739a5ba4b51155b22aeb69148248a07ddbb
7
- data.tar.gz: f35700ff04061b51e997137cee5628bc258fdaa12aa8871ea5ad6dca1de4858ba979b6d78868fe6194d8e3e44623816e2aea10893a195ae8be766b3ee6222da6
6
+ metadata.gz: 00d281410236882efb20f17a8293b372b682803da9603693b4eb6a8a6c11f0b6790d887f65ae977c7355ee26dfbc32769ae7151c01ad0a66dd879aa8f5fea5de
7
+ data.tar.gz: d00c0bbc950752e1b05cc122febd33db82368795b4af81c22ee71efcb5e5deaf4f3c9105dad5bfd469df051d074a22c0815c898ff9e3a267345889dc97552f2a
@@ -16,7 +16,7 @@ ElasticGraphGemspecHelper.define_elasticgraph_gem(gemspec_file: __FILE__, catego
16
16
  spec.add_dependency "elasticgraph-json_schema", eg_version
17
17
  spec.add_dependency "elasticgraph-schema_artifacts", eg_version
18
18
  spec.add_dependency "elasticgraph-support", eg_version
19
- spec.add_dependency "graphql", "~> 2.3.14"
19
+ spec.add_dependency "graphql", "~> 2.4.5"
20
20
  spec.add_dependency "rake", "~> 13.2"
21
21
 
22
22
  spec.add_development_dependency "elasticgraph-admin", eg_version
@@ -6,7 +6,7 @@
6
6
  #
7
7
  # frozen_string_literal: true
8
8
 
9
- require "elastic_graph/error"
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
@@ -141,7 +141,7 @@ module ElasticGraph
141
141
  t.documentation <<~EOS
142
142
  Input type used to specify filters on `#{source_type}` fields.
143
143
 
144
- Will be ignored if passed as an empty object (or as `null`).
144
+ Will match all documents if passed as an empty object (or as `null`).
145
145
  EOS
146
146
 
147
147
  t.field @state.schema_elements.any_of, "[#{t.name}!]" do |f|
@@ -149,17 +149,17 @@ module ElasticGraph
149
149
  Matches records where any of the provided sub-filters evaluate to true.
150
150
  This works just like an OR operator in SQL.
151
151
 
152
- Will be ignored when `null` is passed. When an empty list is passed, will cause this
153
- part of the filter to match no documents.
152
+ When `null` is passed, matches all documents.
153
+ When an empty list is passed, this part of the filter matches no documents.
154
154
  EOS
155
155
  end
156
156
 
157
157
  t.field @state.schema_elements.not, t.name do |f|
158
158
  f.documentation <<~EOS
159
- Matches records where the provided sub-filter does not evaluate to true.
159
+ Matches records where the provided sub-filter evaluates to false.
160
160
  This works just like a NOT operator in SQL.
161
161
 
162
- Will be ignored when `null` or an empty object is passed.
162
+ When `null` or an empty object is passed, matches no documents.
163
163
  EOS
164
164
  end
165
165
 
@@ -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.runtime_metadata_graphql_field = f.runtime_metadata_graphql_field.with_computation_detail(
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
@@ -306,7 +303,7 @@ module ElasticGraph
306
303
  f.documentation <<~EOS
307
304
  Matches records where any of the list elements match the provided sub-filter.
308
305
 
309
- Will be ignored when `null` or an empty object is passed.
306
+ When `null` or an empty object is passed, matches all documents.
310
307
  EOS
311
308
  end
312
309
 
@@ -318,7 +315,7 @@ module ElasticGraph
318
315
  be provided on a single `#{t.name}` input because of collisions between key names. For example, if you want to provide
319
316
  multiple `#{any_satisfy}: ...` filters, you could do `#{all_of}: [{#{any_satisfy}: ...}, {#{any_satisfy}: ...}]`.
320
317
 
321
- Will be ignored when `null` is passed or an empty list is passed.
318
+ When `null` or an empty list is passed, matches all documents.
322
319
  EOS
323
320
  end
324
321
 
@@ -333,7 +330,7 @@ module ElasticGraph
333
330
  t.documentation <<~EOS
334
331
  Input type used to specify filters on elements of a `[#{source_type}]` field.
335
332
 
336
- Will be ignored if passed as an empty object (or as `null`).
333
+ Will match all documents if passed as an empty object (or as `null`).
337
334
  EOS
338
335
 
339
336
  # While we support `not: {any_satisfy: ...}` we do not support `any_satisfy: {not ...}` at this time.
@@ -377,7 +374,7 @@ module ElasticGraph
377
374
  or transitively from a list field that has been configured to index each leaf field as
378
375
  its own flattened list of values.
379
376
 
380
- Will be ignored if passed as an empty object (or as `null`).
377
+ Will match all documents if passed as an empty object (or as `null`).
381
378
  EOS
382
379
 
383
380
  source_type.graphql_fields_by_name.each do |field_name, field|
@@ -427,7 +424,7 @@ module ElasticGraph
427
424
  f.documentation <<~EOS
428
425
  Used to filter on the number of non-null elements in this list field.
429
426
 
430
- Will be ignored when `null` or an empty object is passed.
427
+ When `null` or an empty object is passed, matches all documents.
431
428
  EOS
432
429
  end
433
430
  end
@@ -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/error"
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/error"
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/error"
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/error"
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
@@ -216,7 +216,7 @@ module ElasticGraph
216
216
  f.documentation <<~EOS
217
217
  Matches records where the field value matches the provided value using full text search.
218
218
 
219
- Will be ignored when `null` is passed.
219
+ When `null` is passed, matches all documents.
220
220
  EOS
221
221
 
222
222
  f.directive "deprecated", reason: "Use `#{names.matches_query}` instead."
@@ -228,7 +228,7 @@ module ElasticGraph
228
228
  This is more lenient than `#{names.matches_phrase}`: the order of terms is ignored, and,
229
229
  by default, only one search term is required to be in the field value.
230
230
 
231
- Will be ignored when `null` is passed.
231
+ When `null` is passed, matches all documents.
232
232
  EOS
233
233
  end
234
234
 
@@ -238,7 +238,7 @@ module ElasticGraph
238
238
  full text search. This is stricter than `#{names.matches_query}`: all terms must match
239
239
  and be in the same order as the provided phrase.
240
240
 
241
- Will be ignored when `null` is passed.
241
+ When `null` is passed, matches all documents.
242
242
  EOS
243
243
  end
244
244
  end.each do |input_type|
@@ -246,7 +246,7 @@ module ElasticGraph
246
246
  input_type.documentation <<~EOS
247
247
  Input type used to specify filters on `#{field_type}` fields that have been indexed for full text search.
248
248
 
249
- Will be ignored if passed as an empty object (or as `null`).
249
+ Will match all documents if passed as an empty object (or as `null`).
250
250
  EOS
251
251
 
252
252
  register_input_type(input_type)
@@ -256,7 +256,7 @@ module ElasticGraph
256
256
  t.documentation <<~EOS
257
257
  Input type used to specify parameters for the `#{names.matches_query}` filtering operator.
258
258
 
259
- Will be ignored if passed as `null`.
259
+ When `null` is passed, matches all documents.
260
260
  EOS
261
261
 
262
262
  t.field names.query, "String!" do |f|
@@ -280,18 +280,30 @@ module ElasticGraph
280
280
 
281
281
  f.default false
282
282
  end
283
+
284
+ # any_of/not don't really make sense on this filter because it doesn't make sense to
285
+ # apply an OR operator or negation to the fields of this type since they are all an
286
+ # indivisible part of a single filter operation on a specific field. So we remove them
287
+ # here.
288
+ remove_any_of_and_not_filter_operators_on(t)
283
289
  end
284
290
 
285
291
  register_filter "MatchesPhrase" do |t|
286
292
  t.documentation <<~EOS
287
293
  Input type used to specify parameters for the `#{names.matches_phrase}` filtering operator.
288
294
 
289
- Will be ignored if passed as `null`.
295
+ When `null` is passed, matches all documents.
290
296
  EOS
291
297
 
292
298
  t.field names.phrase, "String!" do |f|
293
299
  f.documentation "The input phrase to search for."
294
300
  end
301
+
302
+ # any_of/not don't really make sense on this filter because it doesn't make sense to
303
+ # apply an OR operator or negation to the fields of this type since they are all an
304
+ # indivisible part of a single filter operation on a specific field. So we remove them
305
+ # here.
306
+ remove_any_of_and_not_filter_operators_on(t)
295
307
  end
296
308
 
297
309
  # This is defined as a built-in ElasticGraph type so that we can leverage Elasticsearch/OpenSearch GeoLocation features
@@ -329,7 +341,7 @@ module ElasticGraph
329
341
  Matches records where the field's geographic location is within a specified distance from the
330
342
  location identified by `#{names.latitude}` and `#{names.longitude}`.
331
343
 
332
- Will be ignored when `null` or an empty object is passed.
344
+ When `null` or an empty object is passed, matches all documents.
333
345
  EOS
334
346
  end
335
347
  end.each { |input_filter| register_input_type(input_filter) }
@@ -551,10 +563,7 @@ module ElasticGraph
551
563
  t.customize_aggregated_values_type do |avt|
552
564
  # not nullable, since sum(empty_set) == 0
553
565
  avt.field names.approximate_sum, "Float!", graphql_only: true do |f|
554
- f.runtime_metadata_graphql_field = f.runtime_metadata_graphql_field.with_computation_detail(
555
- empty_bucket_value: 0,
556
- function: :sum
557
- )
566
+ f.runtime_metadata_computation_detail empty_bucket_value: 0, function: :sum
558
567
 
559
568
  f.documentation <<~EOS
560
569
  The sum of the field values within this grouping.
@@ -574,10 +583,7 @@ module ElasticGraph
574
583
  end
575
584
 
576
585
  avt.field names.approximate_avg, "Float", graphql_only: true do |f|
577
- f.runtime_metadata_graphql_field = f.runtime_metadata_graphql_field.with_computation_detail(
578
- empty_bucket_value: nil,
579
- function: :avg
580
- )
586
+ f.runtime_metadata_computation_detail empty_bucket_value: nil, function: :avg
581
587
 
582
588
  f.documentation <<~EOS
583
589
  The average (mean) of the field values within this grouping.
@@ -666,7 +672,11 @@ module ElasticGraph
666
672
  t.type_ref.as_list_element_filter_input.to_final_form(as_input: true).name
667
673
  ) do |ft|
668
674
  ft.field names.time_of_day, date_time_time_of_day_ref.as_filter_input.name do |f|
669
- f.documentation "Matches records based on the time-of-day of the `DateTime` values."
675
+ f.documentation <<~EOS
676
+ Matches records based on the time-of-day of the `DateTime` values.
677
+
678
+ When `null` is passed, matches all documents.
679
+ EOS
670
680
  end
671
681
  end
672
682
 
@@ -683,7 +693,7 @@ module ElasticGraph
683
693
  t.documentation <<~EOS
684
694
  Input type used to specify filters on the time-of-day of `DateTime` fields.
685
695
 
686
- Will be ignored if passed as an empty object (or as `null`).
696
+ Will match all documents if passed as an empty object (or as `null`).
687
697
  EOS
688
698
 
689
699
  fixup_doc = ->(doc_string) do
@@ -855,10 +865,7 @@ module ElasticGraph
855
865
  t.customize_aggregated_values_type do |avt|
856
866
  # not nullable, since sum(empty_set) == 0
857
867
  avt.field names.approximate_sum, "Float!", graphql_only: true do |f|
858
- f.runtime_metadata_graphql_field = f.runtime_metadata_graphql_field.with_computation_detail(
859
- empty_bucket_value: 0,
860
- function: :sum
861
- )
868
+ f.runtime_metadata_computation_detail empty_bucket_value: 0, function: :sum
862
869
 
863
870
  f.documentation <<~EOS
864
871
  The (approximate) sum of the field values within this grouping.
@@ -870,10 +877,7 @@ module ElasticGraph
870
877
  end
871
878
 
872
879
  avt.field names.exact_sum, "JsonSafeLong", graphql_only: true do |f|
873
- f.runtime_metadata_graphql_field = f.runtime_metadata_graphql_field.with_computation_detail(
874
- empty_bucket_value: 0,
875
- function: :sum
876
- )
880
+ f.runtime_metadata_computation_detail empty_bucket_value: 0, function: :sum
877
881
 
878
882
  f.documentation <<~EOS
879
883
  The exact sum of the field values within this grouping, if it fits in a `JsonSafeLong`.
@@ -902,10 +906,7 @@ module ElasticGraph
902
906
  names.exact_max => [:max, "maximum", names.approximate_max, "largest"]
903
907
  }.each do |exact_name, (func, full_name, approx_name, adjective)|
904
908
  avt.field approx_name, "LongString", graphql_only: true do |f|
905
- f.runtime_metadata_graphql_field = f.runtime_metadata_graphql_field.with_computation_detail(
906
- empty_bucket_value: nil,
907
- function: func
908
- )
909
+ f.runtime_metadata_computation_detail empty_bucket_value: nil, function: func
909
910
 
910
911
  f.documentation <<~EOS
911
912
  The #{full_name} of the field values within this grouping.
@@ -920,10 +921,7 @@ module ElasticGraph
920
921
  end
921
922
 
922
923
  avt.field names.approximate_avg, "Float", graphql_only: true do |f|
923
- f.runtime_metadata_graphql_field = f.runtime_metadata_graphql_field.with_computation_detail(
924
- empty_bucket_value: nil,
925
- function: :avg
926
- )
924
+ f.runtime_metadata_computation_detail empty_bucket_value: nil, function: :avg
927
925
 
928
926
  f.documentation <<~EOS
929
927
  The average (mean) of the field values within this grouping.
@@ -1424,10 +1422,7 @@ module ElasticGraph
1424
1422
  scalar_type.customize_aggregated_values_type do |t|
1425
1423
  # not nullable, since sum(empty_set) == 0
1426
1424
  t.field names.approximate_sum, "Float!", graphql_only: true do |f|
1427
- f.runtime_metadata_graphql_field = f.runtime_metadata_graphql_field.with_computation_detail(
1428
- empty_bucket_value: 0,
1429
- function: :sum
1430
- )
1425
+ f.runtime_metadata_computation_detail empty_bucket_value: 0, function: :sum
1431
1426
 
1432
1427
  f.documentation <<~EOS
1433
1428
  The (approximate) sum of the field values within this grouping.
@@ -1439,10 +1434,7 @@ module ElasticGraph
1439
1434
  end
1440
1435
 
1441
1436
  t.field names.exact_sum, long_type, graphql_only: true do |f|
1442
- f.runtime_metadata_graphql_field = f.runtime_metadata_graphql_field.with_computation_detail(
1443
- empty_bucket_value: 0,
1444
- function: :sum
1445
- )
1437
+ f.runtime_metadata_computation_detail empty_bucket_value: 0, function: :sum
1446
1438
 
1447
1439
  f.documentation <<~EOS
1448
1440
  The exact sum of the field values within this grouping, if it fits in a `#{long_type}`.
@@ -1461,10 +1453,7 @@ module ElasticGraph
1461
1453
  end
1462
1454
 
1463
1455
  t.field names.approximate_avg, "Float", graphql_only: true do |f|
1464
- f.runtime_metadata_graphql_field = f.runtime_metadata_graphql_field.with_computation_detail(
1465
- empty_bucket_value: nil,
1466
- function: :avg
1467
- )
1456
+ f.runtime_metadata_computation_detail empty_bucket_value: nil, function: :avg
1468
1457
 
1469
1458
  f.documentation <<~EOS
1470
1459
  The average (mean) of the field values within this grouping.
@@ -1481,10 +1470,7 @@ module ElasticGraph
1481
1470
  define_exact_min_and_max_on_aggregated_values(aggregated_values_type, scalar_type, &block)
1482
1471
 
1483
1472
  aggregated_values_type.field names.approximate_avg, scalar_type, graphql_only: true do |f|
1484
- f.runtime_metadata_graphql_field = f.runtime_metadata_graphql_field.with_computation_detail(
1485
- empty_bucket_value: nil,
1486
- function: :avg
1487
- )
1473
+ f.runtime_metadata_computation_detail empty_bucket_value: nil, function: :avg
1488
1474
 
1489
1475
  f.documentation <<~EOS
1490
1476
  The average (mean) of the field values within this grouping.
@@ -1501,10 +1487,7 @@ module ElasticGraph
1501
1487
  discussion = yield(adjective: adjective, full_name: full_name)
1502
1488
 
1503
1489
  aggregated_values_type.field name, scalar_type, graphql_only: true do |f|
1504
- f.runtime_metadata_graphql_field = f.runtime_metadata_graphql_field.with_computation_detail(
1505
- empty_bucket_value: nil,
1506
- function: func
1507
- )
1490
+ f.runtime_metadata_computation_detail empty_bucket_value: nil, function: func
1508
1491
 
1509
1492
  f.documentation ["The #{full_name} of the field values within this grouping.", discussion].compact.join("\n\n")
1510
1493
  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