elasticgraph-schema_definition 0.19.3.1 → 1.0.0.rc1
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/LICENSE.txt +1 -1
- data/lib/elastic_graph/schema_definition/api.rb +5 -12
- data/lib/elastic_graph/schema_definition/factory.rb +19 -5
- data/lib/elastic_graph/schema_definition/indexing/derived_fields/append_only_set.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/derived_fields/field_initializer_support.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/derived_fields/immutable_value.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/derived_fields/min_or_max_value.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/derived_indexed_type.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/event_envelope.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/field.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/field_reference.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/field_type/enum.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/field_type/object.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/field_type/scalar.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/field_type/union.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/index.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/json_schema_field_metadata.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/json_schema_with_metadata.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/list_counts_mapping.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/relationship_resolver.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/rollover_config.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/update_target_factory.rb +1 -1
- data/lib/elastic_graph/schema_definition/indexing/update_target_resolver.rb +1 -1
- data/lib/elastic_graph/schema_definition/json_schema_pruner.rb +1 -1
- data/lib/elastic_graph/schema_definition/mixins/can_be_graphql_only.rb +1 -1
- data/lib/elastic_graph/schema_definition/mixins/has_derived_graphql_type_customizations.rb +1 -1
- data/lib/elastic_graph/schema_definition/mixins/has_directives.rb +1 -1
- data/lib/elastic_graph/schema_definition/mixins/has_documentation.rb +1 -1
- data/lib/elastic_graph/schema_definition/mixins/has_indices.rb +4 -17
- data/lib/elastic_graph/schema_definition/mixins/has_readable_to_s_and_inspect.rb +1 -1
- data/lib/elastic_graph/schema_definition/mixins/has_subtypes.rb +1 -1
- data/lib/elastic_graph/schema_definition/mixins/has_type_info.rb +2 -2
- data/lib/elastic_graph/schema_definition/mixins/implements_interfaces.rb +2 -13
- data/lib/elastic_graph/schema_definition/mixins/supports_default_value.rb +1 -1
- data/lib/elastic_graph/schema_definition/mixins/supports_filtering_and_aggregation.rb +23 -8
- data/lib/elastic_graph/schema_definition/mixins/verifies_graphql_name.rb +1 -1
- data/lib/elastic_graph/schema_definition/rake_tasks.rb +1 -1
- data/lib/elastic_graph/schema_definition/results.rb +5 -5
- data/lib/elastic_graph/schema_definition/schema_artifact_manager.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/argument.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/built_in_types.rb +108 -216
- data/lib/elastic_graph/schema_definition/schema_elements/deprecated_element.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/directive.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/enum_type.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/enum_value.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/enum_value_namer.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/enums_for_indexed_types.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/field.rb +103 -142
- data/lib/elastic_graph/schema_definition/schema_elements/field_path.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/field_source.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/graphql_sdl_enumerator.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/input_field.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/input_type.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/interface_type.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/list_counts_state.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/object_type.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/relationship.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/scalar_type.rb +20 -2
- data/lib/elastic_graph/schema_definition/schema_elements/sort_order_enum_value.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/sub_aggregation_path.rb +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/type_namer.rb +2 -1
- data/lib/elastic_graph/schema_definition/schema_elements/type_reference.rb +8 -10
- data/lib/elastic_graph/schema_definition/schema_elements/type_with_subfields.rb +7 -27
- data/lib/elastic_graph/schema_definition/schema_elements/union_type.rb +1 -1
- data/lib/elastic_graph/schema_definition/scripting/file_system_repository.rb +1 -1
- data/lib/elastic_graph/schema_definition/scripting/script.rb +1 -1
- data/lib/elastic_graph/schema_definition/scripting/scripts/update/index_data.painless +2 -22
- data/lib/elastic_graph/schema_definition/state.rb +1 -1
- data/lib/elastic_graph/schema_definition/test_support.rb +1 -1
- metadata +28 -28
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2024 -
|
|
1
|
+
# Copyright 2024 - 2025 Block, Inc.
|
|
2
2
|
#
|
|
3
3
|
# Use of this source code is governed by an MIT-style
|
|
4
4
|
# license that can be found in the LICENSE file or at
|
|
@@ -109,15 +109,9 @@ module ElasticGraph
|
|
|
109
109
|
# ElasticGraph defines these enum types. Most of these are intended for usage as an _input_
|
|
110
110
|
# argument, but they could be used as a return type in your schema if they meet your needs.
|
|
111
111
|
#
|
|
112
|
-
# DateGroupingGranularity
|
|
113
|
-
# : Enumerates the supported granularities of a `Date`.
|
|
114
|
-
#
|
|
115
112
|
# DateGroupingTruncationUnit
|
|
116
113
|
# : Enumerates the supported truncation units of a `Date`.
|
|
117
114
|
#
|
|
118
|
-
# DateTimeGroupingGranularity
|
|
119
|
-
# : Enumerates the supported granularities of a `DateTime`.
|
|
120
|
-
#
|
|
121
115
|
# DateTimeGroupingTruncationUnit
|
|
122
116
|
# : Enumerates the supported truncation units of a `DateTime`.
|
|
123
117
|
#
|
|
@@ -152,20 +146,14 @@ module ElasticGraph
|
|
|
152
146
|
# GeoLocation
|
|
153
147
|
# : Geographic coordinates representing a location on the Earth's surface.
|
|
154
148
|
#
|
|
155
|
-
# GeoTile
|
|
156
|
-
# : A tile in the Web Mercator XYZ grid. Its coordinates identify a cell, not a fixed ground distance.
|
|
157
|
-
#
|
|
158
|
-
# GeoTileBounds
|
|
159
|
-
# : The geographic bounds of a Web Mercator XYZ tile. Tiles do not cross the antimeridian.
|
|
160
|
-
#
|
|
161
|
-
# GeoTileCorners
|
|
162
|
-
# : The geographic locations of the four corners of a Web Mercator XYZ tile.
|
|
163
|
-
#
|
|
164
149
|
# PageInfo
|
|
165
150
|
# : Provides information about the specific fetched page. This implements the
|
|
166
151
|
# `PageInfo` specification from the [Relay GraphQL Cursor Connections
|
|
167
152
|
# Specification](https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo).
|
|
168
153
|
#
|
|
154
|
+
# SearchHighlight
|
|
155
|
+
# : Provides information about why a document matched a search via highlighted snippets.
|
|
156
|
+
#
|
|
169
157
|
# @!attribute [rw] schema_def_api
|
|
170
158
|
# @private
|
|
171
159
|
# @!attribute [rw] schema_def_state
|
|
@@ -189,7 +177,6 @@ module ElasticGraph
|
|
|
189
177
|
register_custom_elastic_graph_scalars
|
|
190
178
|
register_enum_types
|
|
191
179
|
register_date_and_time_grouped_by_types
|
|
192
|
-
register_geo_grouped_by_types
|
|
193
180
|
register_standard_elastic_graph_types
|
|
194
181
|
register_standard_graphql_resolvers
|
|
195
182
|
end
|
|
@@ -216,23 +203,6 @@ module ElasticGraph
|
|
|
216
203
|
def register_standard_elastic_graph_types
|
|
217
204
|
# This is a special filter on a `String` type, so we don't have a `Text` scalar to generate it from.
|
|
218
205
|
schema_def_state.factory.build_standard_filter_input_types_for_index_leaf_type("String", name_prefix: "Text") do |t|
|
|
219
|
-
# We can't support filtering on `null` within a list, so make the field non-nullable when it's the
|
|
220
|
-
# `ListElementFilterInput` type. See scalar_type.rb for a larger comment explaining the rationale behind this.
|
|
221
|
-
equal_to_any_of_type = t.type_ref.list_element_filter_input? ? "[String!]" : "[String]"
|
|
222
|
-
t.field names.equal_to_any_of, equal_to_any_of_type do |f|
|
|
223
|
-
f.documentation ScalarType::EQUAL_TO_ANY_OF_DOC
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
t.field names.matches, "String" do |f|
|
|
227
|
-
f.documentation <<~EOS
|
|
228
|
-
Matches records where the field value matches the provided value using full text search.
|
|
229
|
-
|
|
230
|
-
When `null` is passed, matches all documents.
|
|
231
|
-
EOS
|
|
232
|
-
|
|
233
|
-
f.directive "deprecated", reason: "Use `#{names.matches_query}` instead."
|
|
234
|
-
end
|
|
235
|
-
|
|
236
206
|
t.field names.matches_query, schema_def_state.type_ref("MatchesQuery").as_filter_input.name do |f|
|
|
237
207
|
f.documentation <<~EOS
|
|
238
208
|
Matches records where the field value matches the provided query using full text search.
|
|
@@ -310,7 +280,71 @@ module ElasticGraph
|
|
|
310
280
|
f.documentation "The input phrase to search for."
|
|
311
281
|
end
|
|
312
282
|
|
|
313
|
-
# any_of/all_of/not don't really make sense on this filter because it doesn't make
|
|
283
|
+
# any_of/all_of/not don't really make sense on this filter because it doesn't make sense
|
|
284
|
+
# to apply an OR operator or negation to the fields of this type since they are all an
|
|
285
|
+
# indivisible part of a single filter operation on a specific field. So we remove them
|
|
286
|
+
# here.
|
|
287
|
+
remove_any_of_and_all_of_and_not_filter_operators_on(t)
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
register_filter "StringContains" do |t|
|
|
291
|
+
t.documentation <<~EOS
|
|
292
|
+
Input type used to specify parameters for the `#{names.contains}` string filtering operator.
|
|
293
|
+
|
|
294
|
+
When `null` is passed, matches all documents.
|
|
295
|
+
EOS
|
|
296
|
+
|
|
297
|
+
t.field names.any_substring_of, "[String!]" do |f|
|
|
298
|
+
f.documentation <<~EOS
|
|
299
|
+
Matches records where the field value contains one or more of the provided substrings.
|
|
300
|
+
|
|
301
|
+
When `null` is passed, matches all documents. When an empty list is passed,
|
|
302
|
+
this part of the filter matches no documents.
|
|
303
|
+
EOS
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
t.field names.all_substrings_of, "[String!]" do |f|
|
|
307
|
+
f.documentation <<~EOS
|
|
308
|
+
Matches records where the field value contains all of the provided substrings.
|
|
309
|
+
|
|
310
|
+
When `null` is passed or an empty list is passed, matches all documents.
|
|
311
|
+
EOS
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
t.field names.ignore_case, "Boolean!" do |f|
|
|
315
|
+
f.default false
|
|
316
|
+
f.documentation "Determines if the substring matching is case-sensitive (the default) or case-insensitive."
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
# any_of/all_of/not don't really make sense on this filter because it doesn't make sense
|
|
320
|
+
# to apply an OR operator or negation to the fields of this type since they are all an
|
|
321
|
+
# indivisible part of a single filter operation on a specific field. So we remove them
|
|
322
|
+
# here.
|
|
323
|
+
remove_any_of_and_all_of_and_not_filter_operators_on(t)
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
register_filter "StringStartsWith" do |t|
|
|
327
|
+
t.documentation <<~EOS
|
|
328
|
+
Input type used to specify parameters for the `#{names.starts_with}` string filtering operator.
|
|
329
|
+
|
|
330
|
+
When `null` is passed, matches all documents.
|
|
331
|
+
EOS
|
|
332
|
+
|
|
333
|
+
t.field names.any_prefix_of, "[String!]" do |f|
|
|
334
|
+
f.documentation <<~EOS
|
|
335
|
+
Matches records where the field value starts with one or more of the provided prefixes.
|
|
336
|
+
|
|
337
|
+
When `null` is passed, matches all documents. When an empty list is passed,
|
|
338
|
+
this part of the filter matches no documents.
|
|
339
|
+
EOS
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
t.field names.ignore_case, "Boolean!" do |f|
|
|
343
|
+
f.default false
|
|
344
|
+
f.documentation "Determines if the prefix matching is case-sensitive (the default) or case-insensitive."
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
# any_of/all_of/not don't really make sense on this filter because it doesn't make sense
|
|
314
348
|
# to apply an OR operator or negation to the fields of this type since they are all an
|
|
315
349
|
# indivisible part of a single filter operation on a specific field. So we remove them
|
|
316
350
|
# here.
|
|
@@ -404,7 +438,7 @@ module ElasticGraph
|
|
|
404
438
|
# to go from non-null to null, but is not a breaking change to make it non-null
|
|
405
439
|
# in the future.
|
|
406
440
|
register_framework_object_type "PageInfo" do |t|
|
|
407
|
-
t.
|
|
441
|
+
t.default_graphql_resolver = :object_without_lookahead
|
|
408
442
|
|
|
409
443
|
t.documentation <<~EOS
|
|
410
444
|
Provides information about the specific fetched page. This implements the `PageInfo`
|
|
@@ -435,6 +469,23 @@ module ElasticGraph
|
|
|
435
469
|
end
|
|
436
470
|
end
|
|
437
471
|
|
|
472
|
+
register_framework_object_type "SearchHighlight" do |t|
|
|
473
|
+
t.default_graphql_resolver = :object_without_lookahead
|
|
474
|
+
|
|
475
|
+
t.documentation "Provides information about why a document matched a search via highlighted snippets."
|
|
476
|
+
|
|
477
|
+
t.field names.path, "[String!]!" do |f|
|
|
478
|
+
f.documentation <<~EOS
|
|
479
|
+
Path to a leaf field containing one or more search highlight snippets. The returned list will contain a path segment for
|
|
480
|
+
each object layer of the schema, from the document root.
|
|
481
|
+
EOS
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
t.field names.snippets, "[String!]!" do |f|
|
|
485
|
+
f.documentation "List of snippets containing search highlights from field values at this `path`."
|
|
486
|
+
end
|
|
487
|
+
end
|
|
488
|
+
|
|
438
489
|
schema_def_api.factory.new_input_type("DateTimeGroupingOffsetInput") do |t|
|
|
439
490
|
t.documentation <<~EOS
|
|
440
491
|
Input type offered when grouping on `DateTime` fields, representing the amount of offset
|
|
@@ -522,7 +573,7 @@ module ElasticGraph
|
|
|
522
573
|
|
|
523
574
|
register_framework_object_type "AggregationCountDetail" do |t|
|
|
524
575
|
t.documentation "Provides detail about an aggregation `#{names.count}`."
|
|
525
|
-
t.
|
|
576
|
+
t.default_graphql_resolver = :object_without_lookahead
|
|
526
577
|
|
|
527
578
|
t.field names.approximate_value, "JsonSafeLong!", graphql_only: true do |f|
|
|
528
579
|
f.documentation <<~EOS
|
|
@@ -629,6 +680,24 @@ module ElasticGraph
|
|
|
629
680
|
schema_def_api.scalar_type "String" do |t|
|
|
630
681
|
t.mapping type: "keyword"
|
|
631
682
|
t.json_schema type: "string"
|
|
683
|
+
|
|
684
|
+
t.customize_filter_input_type do |fit|
|
|
685
|
+
fit.field names.contains, schema_def_state.type_ref("StringContains").as_filter_input.name do |f|
|
|
686
|
+
f.documentation <<~EOS
|
|
687
|
+
Matches documents using substring filtering.
|
|
688
|
+
|
|
689
|
+
When `null` is passed, matches all documents.
|
|
690
|
+
EOS
|
|
691
|
+
end
|
|
692
|
+
|
|
693
|
+
fit.field names.starts_with, schema_def_state.type_ref("StringStartsWith").as_filter_input.name do |f|
|
|
694
|
+
f.documentation <<~EOS
|
|
695
|
+
Matches documents using prefix filtering.
|
|
696
|
+
|
|
697
|
+
When `null` is passed, matches all documents.
|
|
698
|
+
EOS
|
|
699
|
+
end
|
|
700
|
+
end
|
|
632
701
|
end
|
|
633
702
|
end
|
|
634
703
|
|
|
@@ -963,38 +1032,6 @@ module ElasticGraph
|
|
|
963
1032
|
# elasticgraph-graphql/spec/acceptance/elasticgraph_graphql_spec.rb
|
|
964
1033
|
es_first_day_of_week = "Monday"
|
|
965
1034
|
|
|
966
|
-
# TODO: Drop support for legacy grouping schema
|
|
967
|
-
schema_def_api.enum_type "DateGroupingGranularity" do |t|
|
|
968
|
-
t.documentation <<~EOS
|
|
969
|
-
Enumerates the supported granularities of a `Date`.
|
|
970
|
-
EOS
|
|
971
|
-
|
|
972
|
-
t.value "YEAR" do |v|
|
|
973
|
-
v.documentation "The year a `Date` falls in."
|
|
974
|
-
v.update_runtime_metadata datastore_value: "year"
|
|
975
|
-
end
|
|
976
|
-
|
|
977
|
-
t.value "QUARTER" do |v|
|
|
978
|
-
v.documentation "The quarter a `Date` falls in."
|
|
979
|
-
v.update_runtime_metadata datastore_value: "quarter"
|
|
980
|
-
end
|
|
981
|
-
|
|
982
|
-
t.value "MONTH" do |v|
|
|
983
|
-
v.documentation "The month a `Date` falls in."
|
|
984
|
-
v.update_runtime_metadata datastore_value: "month"
|
|
985
|
-
end
|
|
986
|
-
|
|
987
|
-
t.value "WEEK" do |v|
|
|
988
|
-
v.documentation "The week, beginning on #{es_first_day_of_week}, a `Date` falls in."
|
|
989
|
-
v.update_runtime_metadata datastore_value: "week"
|
|
990
|
-
end
|
|
991
|
-
|
|
992
|
-
t.value "DAY" do |v|
|
|
993
|
-
v.documentation "The exact day of a `Date`."
|
|
994
|
-
v.update_runtime_metadata datastore_value: "day"
|
|
995
|
-
end
|
|
996
|
-
end
|
|
997
|
-
|
|
998
1035
|
schema_def_api.enum_type "DateGroupingTruncationUnit" do |t|
|
|
999
1036
|
t.documentation <<~EOS
|
|
1000
1037
|
Enumerates the supported truncation units of a `Date`.
|
|
@@ -1026,53 +1063,6 @@ module ElasticGraph
|
|
|
1026
1063
|
end
|
|
1027
1064
|
end
|
|
1028
1065
|
|
|
1029
|
-
# TODO: Drop support for legacy grouping schema
|
|
1030
|
-
schema_def_api.enum_type "DateTimeGroupingGranularity" do |t|
|
|
1031
|
-
t.documentation <<~EOS
|
|
1032
|
-
Enumerates the supported granularities of a `DateTime`.
|
|
1033
|
-
EOS
|
|
1034
|
-
|
|
1035
|
-
t.value "YEAR" do |v|
|
|
1036
|
-
v.documentation "The year a `DateTime` falls in."
|
|
1037
|
-
v.update_runtime_metadata datastore_value: "year"
|
|
1038
|
-
end
|
|
1039
|
-
|
|
1040
|
-
t.value "QUARTER" do |v|
|
|
1041
|
-
v.documentation "The quarter a `DateTime` falls in."
|
|
1042
|
-
v.update_runtime_metadata datastore_value: "quarter"
|
|
1043
|
-
end
|
|
1044
|
-
|
|
1045
|
-
t.value "MONTH" do |v|
|
|
1046
|
-
v.documentation "The month a `DateTime` falls in."
|
|
1047
|
-
v.update_runtime_metadata datastore_value: "month"
|
|
1048
|
-
end
|
|
1049
|
-
|
|
1050
|
-
t.value "WEEK" do |v|
|
|
1051
|
-
v.documentation "The week, beginning on #{es_first_day_of_week}, a `DateTime` falls in."
|
|
1052
|
-
v.update_runtime_metadata datastore_value: "week"
|
|
1053
|
-
end
|
|
1054
|
-
|
|
1055
|
-
t.value "DAY" do |v|
|
|
1056
|
-
v.documentation "The day a `DateTime` falls in."
|
|
1057
|
-
v.update_runtime_metadata datastore_value: "day"
|
|
1058
|
-
end
|
|
1059
|
-
|
|
1060
|
-
t.value "HOUR" do |v|
|
|
1061
|
-
v.documentation "The hour a `DateTime` falls in."
|
|
1062
|
-
v.update_runtime_metadata datastore_value: "hour"
|
|
1063
|
-
end
|
|
1064
|
-
|
|
1065
|
-
t.value "MINUTE" do |v|
|
|
1066
|
-
v.documentation "The minute a `DateTime` falls in."
|
|
1067
|
-
v.update_runtime_metadata datastore_value: "minute"
|
|
1068
|
-
end
|
|
1069
|
-
|
|
1070
|
-
t.value "SECOND" do |v|
|
|
1071
|
-
v.documentation "The second a `DateTime` falls in."
|
|
1072
|
-
v.update_runtime_metadata datastore_value: "second"
|
|
1073
|
-
end
|
|
1074
|
-
end
|
|
1075
|
-
|
|
1076
1066
|
schema_def_api.enum_type "DateTimeGroupingTruncationUnit" do |t|
|
|
1077
1067
|
t.documentation <<~EOS
|
|
1078
1068
|
Enumerates the supported truncation units of a `DateTime`.
|
|
@@ -1304,7 +1294,7 @@ module ElasticGraph
|
|
|
1304
1294
|
date = schema_def_state.type_ref("Date")
|
|
1305
1295
|
register_framework_object_type date.as_grouped_by.name do |t|
|
|
1306
1296
|
t.documentation "Allows for grouping `Date` values based on the desired return type."
|
|
1307
|
-
t.
|
|
1297
|
+
t.default_graphql_resolver = :object_with_lookahead
|
|
1308
1298
|
t.override_runtime_metadata(elasticgraph_category: :date_grouped_by_object)
|
|
1309
1299
|
|
|
1310
1300
|
t.field names.as_date, "Date", graphql_only: true do |f|
|
|
@@ -1322,7 +1312,7 @@ module ElasticGraph
|
|
|
1322
1312
|
date_time = schema_def_state.type_ref("DateTime")
|
|
1323
1313
|
register_framework_object_type date_time.as_grouped_by.name do |t|
|
|
1324
1314
|
t.documentation "Allows for grouping `DateTime` values based on the desired return type."
|
|
1325
|
-
t.
|
|
1315
|
+
t.default_graphql_resolver = :object_with_lookahead
|
|
1326
1316
|
t.override_runtime_metadata(elasticgraph_category: :date_grouped_by_object)
|
|
1327
1317
|
|
|
1328
1318
|
t.field names.as_date_time, "DateTime", graphql_only: true do |f|
|
|
@@ -1379,105 +1369,7 @@ module ElasticGraph
|
|
|
1379
1369
|
end
|
|
1380
1370
|
end
|
|
1381
1371
|
|
|
1382
|
-
# Registers the geographic grouping operation and its tile, bounds, and corner output types.
|
|
1383
|
-
def register_geo_grouped_by_types
|
|
1384
|
-
register_framework_object_type schema_def_state.type_ref("GeoLocation").as_grouped_by.name do |t|
|
|
1385
|
-
t.documentation "Offers geographic grouping representations for a location."
|
|
1386
|
-
t.resolve_fields_with :object_with_lookahead
|
|
1387
|
-
t.override_runtime_metadata(elasticgraph_category: :geo_location_grouped_by_object)
|
|
1388
|
-
|
|
1389
|
-
t.field names.as_geo_tile, "GeoTile", graphql_only: true do |f|
|
|
1390
|
-
f.resolve_with :as_geo_tile
|
|
1391
|
-
|
|
1392
|
-
f.documentation <<~EOS
|
|
1393
|
-
Groups locations into Web Mercator [XYZ tiles](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames). Missing locations produce a `null` tile.
|
|
1394
|
-
Points beyond ±85.0511° latitude are grouped into the northernmost or southernmost row,
|
|
1395
|
-
so a point can be outside the bounds of the tile it is grouped into.
|
|
1396
|
-
Boundary points are assigned to the tile to the east or south, subject to datastore coordinate encoding.
|
|
1397
|
-
EOS
|
|
1398
|
-
|
|
1399
|
-
f.argument names.zoom_level, "Int!" do |a|
|
|
1400
|
-
a.documentation <<~EOS
|
|
1401
|
-
The Web Mercator zoom level, from #{GEO_TILE_ZOOM_LEVELS.min} through #{GEO_TILE_ZOOM_LEVELS.max}.
|
|
1402
|
-
At zoom level z, the map has 2^z rows and 2^z columns. Increasing the zoom level by 1
|
|
1403
|
-
doubles both, producing four times as many tiles.
|
|
1404
|
-
EOS
|
|
1405
|
-
a.default 7
|
|
1406
|
-
end
|
|
1407
|
-
end
|
|
1408
|
-
end
|
|
1409
|
-
|
|
1410
|
-
register_framework_object_type "GeoTile" do |t|
|
|
1411
|
-
t.documentation "A tile in the Web Mercator XYZ grid. Its coordinates identify a cell, not a fixed ground distance."
|
|
1412
|
-
t.resolve_fields_with :object_without_lookahead
|
|
1413
|
-
|
|
1414
|
-
t.field names.zoom_level, "Int!", graphql_only: true do |f|
|
|
1415
|
-
f.documentation "The zoom level of the tile, from #{GEO_TILE_ZOOM_LEVELS.min} through #{GEO_TILE_ZOOM_LEVELS.max}."
|
|
1416
|
-
end
|
|
1417
|
-
|
|
1418
|
-
{names.x => "west to east", names.y => "north to south"}.each do |name, direction|
|
|
1419
|
-
t.field name, "Int!", graphql_only: true do |f|
|
|
1420
|
-
f.documentation "The zero-based tile coordinate, counted #{direction}, from 0 through 2^zoomLevel - 1."
|
|
1421
|
-
end
|
|
1422
|
-
end
|
|
1423
|
-
|
|
1424
|
-
t.field names.map_center_point, "GeoLocation!", graphql_only: true do |f|
|
|
1425
|
-
f.documentation <<~EOS
|
|
1426
|
-
The center of the tile as drawn on a Web Mercator map, not the average record location or the midpoint
|
|
1427
|
-
of the tile's latitude bounds. These differ noticeably only at low zoom levels: for tile 1/0/0,
|
|
1428
|
-
the map center point is at about 66.51° latitude, but the bounds midpoint is at about 42.53°.
|
|
1429
|
-
EOS
|
|
1430
|
-
end
|
|
1431
|
-
|
|
1432
|
-
t.field names.bounds, "GeoTileBounds!", graphql_only: true do |f|
|
|
1433
|
-
f.documentation "The geographic bounds of the tile. Web Mercator excludes the poles and stops at approximately ±85.0511°."
|
|
1434
|
-
end
|
|
1435
|
-
|
|
1436
|
-
t.field names.corners, "GeoTileCorners!", graphql_only: true do |f|
|
|
1437
|
-
f.documentation "The four corners of the tile, calculated from its geographic bounds."
|
|
1438
|
-
end
|
|
1439
|
-
end
|
|
1440
|
-
|
|
1441
|
-
register_framework_object_type "GeoTileBounds" do |t|
|
|
1442
|
-
t.resolve_fields_with :object_without_lookahead
|
|
1443
|
-
t.documentation "The geographic bounds of a Web Mercator XYZ tile. Tiles do not cross the antimeridian."
|
|
1444
|
-
|
|
1445
|
-
{
|
|
1446
|
-
names.north => "latitude of the northern",
|
|
1447
|
-
names.south => "latitude of the southern",
|
|
1448
|
-
names.east => "longitude of the eastern",
|
|
1449
|
-
names.west => "longitude of the western"
|
|
1450
|
-
}.each do |name, description|
|
|
1451
|
-
t.field name, "Float!", graphql_only: true do |f|
|
|
1452
|
-
f.documentation "The #{description} boundary of the tile."
|
|
1453
|
-
end
|
|
1454
|
-
end
|
|
1455
|
-
end
|
|
1456
|
-
|
|
1457
|
-
register_framework_object_type "GeoTileCorners" do |t|
|
|
1458
|
-
t.resolve_fields_with :object_without_lookahead
|
|
1459
|
-
t.documentation "The geographic locations of the four corners of a Web Mercator XYZ tile."
|
|
1460
|
-
|
|
1461
|
-
{
|
|
1462
|
-
names.northwest => "northwest",
|
|
1463
|
-
names.northeast => "northeast",
|
|
1464
|
-
names.southwest => "southwest",
|
|
1465
|
-
names.southeast => "southeast"
|
|
1466
|
-
}.each do |name, description|
|
|
1467
|
-
t.field name, "GeoLocation!", graphql_only: true do |f|
|
|
1468
|
-
f.documentation "The #{description} corner of the tile."
|
|
1469
|
-
end
|
|
1470
|
-
end
|
|
1471
|
-
end
|
|
1472
|
-
end
|
|
1473
|
-
|
|
1474
1372
|
def register_standard_graphql_resolvers
|
|
1475
|
-
require(require_path = "elastic_graph/graphql/aggregation/resolvers/as_geo_tile")
|
|
1476
|
-
schema_def_api.register_graphql_resolver :as_geo_tile,
|
|
1477
|
-
GraphQL::Aggregation::Resolvers::AsGeoTile,
|
|
1478
|
-
defined_at: require_path,
|
|
1479
|
-
built_in: true
|
|
1480
|
-
|
|
1481
1373
|
require(require_path = "elastic_graph/graphql/resolvers/get_record_field_value")
|
|
1482
1374
|
schema_def_api.register_graphql_resolver :get_record_field_value,
|
|
1483
1375
|
GraphQL::Resolvers::GetRecordFieldValue,
|