elasticgraph-schema_definition 0.19.3.0 → 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/lib/elastic_graph/schema_definition/api.rb +4 -11
- data/lib/elastic_graph/schema_definition/factory.rb +18 -4
- data/lib/elastic_graph/schema_definition/mixins/has_indices.rb +3 -16
- data/lib/elastic_graph/schema_definition/mixins/has_type_info.rb +1 -1
- data/lib/elastic_graph/schema_definition/mixins/supports_filtering_and_aggregation.rb +22 -7
- data/lib/elastic_graph/schema_definition/results.rb +4 -4
- data/lib/elastic_graph/schema_definition/schema_elements/built_in_types.rb +107 -107
- data/lib/elastic_graph/schema_definition/schema_elements/field.rb +99 -130
- data/lib/elastic_graph/schema_definition/schema_elements/scalar_type.rb +19 -1
- data/lib/elastic_graph/schema_definition/schema_elements/type_namer.rb +1 -0
- data/lib/elastic_graph/schema_definition/schema_elements/type_reference.rb +1 -0
- data/lib/elastic_graph/schema_definition/schema_elements/type_with_subfields.rb +6 -26
- data/lib/elastic_graph/schema_definition/scripting/scripts/update/index_data.painless +2 -22
- metadata +29 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54e9fd94b73a36f09e090c68605743766da45b9f1777e5622a8b1b0e6985a5a5
|
4
|
+
data.tar.gz: c656f8bf79e9dcfa7bf88d9f4e2944a606d436b440e337fd3db9d064ad59aad5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d348ef2187ff3dbd29c7c3c198a61153fdf86219bca6b37c35f92bafa0bbc17a26ac46d655f5a871c5d33f14568d27ff91a413ed1431a714491119b94d2ac67b
|
7
|
+
data.tar.gz: 7db25426957cd9ddfd2a0af5ee78c7248040a270438d95016b73edf9e2c74a08f830866f17a381488bf11706624ef0c58cfe41405b2eaaa485b5277fd2f75914
|
@@ -300,35 +300,28 @@ module ElasticGraph
|
|
300
300
|
# @param defined_at [String] the `require` path of the resolver
|
301
301
|
# @param resolver_config [Hash<Symbol, Object>] configuration options for the resolver, to support parameterized resolvers
|
302
302
|
# @return [void]
|
303
|
-
# @see Mixins::HasIndices#resolve_fields_with
|
304
|
-
# @see SchemaElements::Field#resolve_with
|
305
303
|
#
|
306
304
|
# @example Register a custom resolver for use by a custom `Query` field
|
307
305
|
# # In `add_resolver.rb`:
|
308
306
|
# class AddResolver
|
309
307
|
# def initialize(elasticgraph_graphql:, config:)
|
310
|
-
# @multiplier = config.fetch(:multiplier, 1)
|
311
308
|
# end
|
312
309
|
#
|
313
310
|
# def resolve(field:, object:, args:, context:)
|
314
|
-
#
|
315
|
-
# sum * @multiplier
|
311
|
+
# args.fetch("x") + args.fetch("y")
|
316
312
|
# end
|
317
313
|
# end
|
318
314
|
#
|
319
315
|
# # In `config/schema.rb`:
|
320
316
|
# ElasticGraph.define_schema do |schema|
|
321
317
|
# require(resolver_path = "add_resolver")
|
322
|
-
# schema.register_graphql_resolver :add,
|
323
|
-
# AddResolver,
|
324
|
-
# defined_at: resolver_path,
|
325
|
-
# multiplier: 2 # extra args are passed to the resolver within `config`.
|
318
|
+
# schema.register_graphql_resolver :add, AddResolver, defined_at: resolver_path
|
326
319
|
#
|
327
320
|
# schema.on_root_query_type do |t|
|
328
321
|
# t.field "add", "Int" do |f|
|
329
322
|
# f.argument "x", "Int!"
|
330
323
|
# f.argument "y", "Int!"
|
331
|
-
# f.
|
324
|
+
# f.resolver = :add
|
332
325
|
# end
|
333
326
|
# end
|
334
327
|
# end
|
@@ -361,7 +354,7 @@ module ElasticGraph
|
|
361
354
|
#
|
362
355
|
# schema.on_root_query_type do |t|
|
363
356
|
# t.field "artist", "Artist" do |f|
|
364
|
-
# f.
|
357
|
+
# f.resolver = :artist
|
365
358
|
# end
|
366
359
|
# end
|
367
360
|
# end
|
@@ -286,7 +286,7 @@ module ElasticGraph
|
|
286
286
|
new_object_type @state.type_ref(index_leaf_type).as_aggregated_values.name do |type|
|
287
287
|
type.graphql_only true
|
288
288
|
type.documentation "A return type used from aggregations to provided aggregated values over `#{index_leaf_type}` fields."
|
289
|
-
type.
|
289
|
+
type.default_graphql_resolver = :object_with_lookahead
|
290
290
|
type.override_runtime_metadata(elasticgraph_category: :scalar_aggregated_values)
|
291
291
|
|
292
292
|
type.field @state.schema_elements.approximate_distinct_value_count, "JsonSafeLong", graphql_only: true do |f|
|
@@ -433,14 +433,16 @@ module ElasticGraph
|
|
433
433
|
|
434
434
|
def edge_type_for(type_name)
|
435
435
|
type_ref = @state.type_ref(type_name)
|
436
|
+
object_type = type_ref.as_object_type # : SchemaElements::ObjectType
|
437
|
+
|
436
438
|
new_object_type type_ref.as_edge.name do |t|
|
437
439
|
t.relay_pagination_type = true
|
438
|
-
t.
|
440
|
+
t.default_graphql_resolver = :object_without_lookahead
|
439
441
|
t.override_runtime_metadata(elasticgraph_category: :relay_edge)
|
440
442
|
|
441
443
|
t.documentation <<~EOS
|
442
444
|
Represents a specific `#{type_name}` in the context of a `#{type_ref.as_connection.name}`,
|
443
|
-
providing access to both the `#{type_name}` and
|
445
|
+
providing access to both the `#{type_name}` and query-specific information such as the pagination `Cursor`.
|
444
446
|
|
445
447
|
See the [Relay GraphQL Cursor Connections
|
446
448
|
Specification](https://relay.dev/graphql/connections.htm#sec-Edge-Types) for more info.
|
@@ -456,6 +458,18 @@ module ElasticGraph
|
|
456
458
|
a `before` or `after` argument to continue paginating from this `#{type_name}`.
|
457
459
|
EOS
|
458
460
|
end
|
461
|
+
|
462
|
+
if object_type&.indexed?
|
463
|
+
t.field @state.schema_elements.all_highlights, "[SearchHighlight!]!" do |f|
|
464
|
+
f.documentation "All search highlights for this `#{type_name}`, indicating where in the indexed document the query matched."
|
465
|
+
end
|
466
|
+
|
467
|
+
if object_type.supports?(&:highlightable?)
|
468
|
+
t.field @state.schema_elements.highlights, type_ref.as_highlights.name do |f|
|
469
|
+
f.documentation "Specific search highlights for this `#{type_name}`, providing matching snippets for the requested fields."
|
470
|
+
end
|
471
|
+
end
|
472
|
+
end
|
459
473
|
end
|
460
474
|
end
|
461
475
|
|
@@ -463,7 +477,7 @@ module ElasticGraph
|
|
463
477
|
type_ref = @state.type_ref(type_name)
|
464
478
|
new_object_type type_ref.as_connection.name do |t|
|
465
479
|
t.relay_pagination_type = true
|
466
|
-
t.
|
480
|
+
t.default_graphql_resolver = :object_without_lookahead
|
467
481
|
t.override_runtime_metadata(elasticgraph_category: :relay_connection)
|
468
482
|
|
469
483
|
if support_pagination
|
@@ -20,14 +20,14 @@ module ElasticGraph
|
|
20
20
|
attr_reader :runtime_metadata_overrides
|
21
21
|
|
22
22
|
# @return [::Symbol, nil] the default GraphQL resolver to use for fields on this type
|
23
|
-
|
24
|
-
# @dynamic default_graphql_resolver
|
23
|
+
attr_accessor :default_graphql_resolver
|
24
|
+
# @dynamic default_graphql_resolver, default_graphql_resolver=
|
25
25
|
|
26
26
|
# @private
|
27
27
|
def initialize(*args, **options)
|
28
28
|
super(*args, **options)
|
29
29
|
@runtime_metadata_overrides = {}
|
30
|
-
|
30
|
+
self.default_graphql_resolver = :get_record_field_value
|
31
31
|
yield self
|
32
32
|
|
33
33
|
# Freeze `indices` so that the indexable status of a type does not change after instantiation.
|
@@ -72,19 +72,6 @@ module ElasticGraph
|
|
72
72
|
indices.replace([Indexing::Index.new(name, settings, schema_def_state, self, &block)])
|
73
73
|
end
|
74
74
|
|
75
|
-
# Configures the default GraphQL resolver that will be used to resolve the fields of this type. Individual fields
|
76
|
-
# can override this using {SchemaElements::Field#resolve_with}.
|
77
|
-
#
|
78
|
-
# @param default_resolver_name [Symbol] name of the GraphQL resolver to use as the default for fields of this type
|
79
|
-
# @param config [Hash<Symbol, Object>] configuration parameters for the resolver
|
80
|
-
# @return [void]
|
81
|
-
# @see API#register_graphql_resolver
|
82
|
-
def resolve_fields_with(default_resolver_name, **config)
|
83
|
-
@default_graphql_resolver = default_resolver_name&.then do |name|
|
84
|
-
SchemaArtifacts::RuntimeMetadata::ConfiguredGraphQLResolver.new(name, config)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
75
|
# List of indices. (Currently we only store one but we may support multiple in the future).
|
89
76
|
#
|
90
77
|
# @private
|
@@ -46,7 +46,7 @@ module ElasticGraph
|
|
46
46
|
# Record metadata that is necessary for elasticgraph-graphql to correctly recognize and handle
|
47
47
|
# this sub-aggregation correctly.
|
48
48
|
t.override_runtime_metadata(elasticgraph_category: :nested_sub_aggregation_connection)
|
49
|
-
t.
|
49
|
+
t.default_graphql_resolver = :object_without_lookahead
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -70,7 +70,8 @@ module ElasticGraph
|
|
70
70
|
build_aggregation_sub_aggregations_types + [
|
71
71
|
indexed_agg_type,
|
72
72
|
to_grouped_by_type,
|
73
|
-
to_aggregated_values_type
|
73
|
+
to_aggregated_values_type,
|
74
|
+
to_highlights_type
|
74
75
|
].compact
|
75
76
|
end
|
76
77
|
|
@@ -117,7 +118,7 @@ module ElasticGraph
|
|
117
118
|
schema_def_state.sub_aggregation_paths_for(nested_field_ref.parent_type).map do |path|
|
118
119
|
schema_def_state.factory.new_object_type type_ref.as_sub_aggregation(parent_doc_types: path.parent_doc_types).name do |t|
|
119
120
|
t.documentation "Return type representing a bucket of `#{name}` objects for a sub-aggregation within each `#{type_ref.as_parent_aggregation(parent_doc_types: path.parent_doc_types).name}`."
|
120
|
-
t.
|
121
|
+
t.default_graphql_resolver = :object_without_lookahead
|
121
122
|
|
122
123
|
t.field schema_def_state.schema_elements.count_detail, "AggregationCountDetail", graphql_only: true do |f|
|
123
124
|
f.documentation "Details of the count of `#{name}` documents in a sub-aggregation bucket."
|
@@ -165,7 +166,7 @@ module ElasticGraph
|
|
165
166
|
schema_def_state.factory.new_object_type agg_sub_aggs_type_ref.name do |t|
|
166
167
|
under_field_description = "under `#{path.field_path_string}` " unless path.field_path.empty?
|
167
168
|
t.documentation "Provides access to the `#{schema_def_state.schema_elements.sub_aggregations}` #{under_field_description}within each `#{type_ref.as_parent_aggregation(parent_doc_types: path.parent_doc_types).name}`."
|
168
|
-
t.
|
169
|
+
t.default_graphql_resolver = :object_with_lookahead
|
169
170
|
|
170
171
|
sub_aggregatable_fields.each do |field|
|
171
172
|
if field.nested?
|
@@ -228,7 +229,7 @@ module ElasticGraph
|
|
228
229
|
|
229
230
|
# Record metadata that is necessary for elasticgraph-graphql to correctly recognize and handle
|
230
231
|
# this indexed aggregation type correctly.
|
231
|
-
t.
|
232
|
+
t.default_graphql_resolver = :object_without_lookahead
|
232
233
|
t.override_runtime_metadata(source_type: name, elasticgraph_category: :indexed_aggregation)
|
233
234
|
end
|
234
235
|
end
|
@@ -240,7 +241,7 @@ module ElasticGraph
|
|
240
241
|
|
241
242
|
new_non_empty_object_type type_ref.as_grouped_by.name do |t|
|
242
243
|
t.documentation "Type used to specify the `#{name}` fields to group by for aggregations."
|
243
|
-
t.
|
244
|
+
t.default_graphql_resolver = :object_with_lookahead
|
244
245
|
|
245
246
|
graphql_fields_by_name.values.each do |field|
|
246
247
|
field.define_grouped_by_field(t)
|
@@ -255,7 +256,7 @@ module ElasticGraph
|
|
255
256
|
|
256
257
|
new_non_empty_object_type type_ref.as_aggregated_values.name do |t|
|
257
258
|
t.documentation "Type used to perform aggregation computations on `#{name}` fields."
|
258
|
-
t.
|
259
|
+
t.default_graphql_resolver = :object_with_lookahead
|
259
260
|
|
260
261
|
graphql_fields_by_name.values.each do |field|
|
261
262
|
field.define_aggregated_values_field(t)
|
@@ -263,6 +264,20 @@ module ElasticGraph
|
|
263
264
|
end
|
264
265
|
end
|
265
266
|
|
267
|
+
def to_highlights_type
|
268
|
+
# If the type uses a custom mapping type we don't know how it can be highlighted, so we assume it needs no highlights type.
|
269
|
+
return nil if does_not_support?(&:highlightable?)
|
270
|
+
|
271
|
+
new_non_empty_object_type type_ref.as_highlights.name do |t|
|
272
|
+
t.documentation "Type used to request desired `#{name}` search highlight fields."
|
273
|
+
t.default_graphql_resolver = :get_record_field_value
|
274
|
+
|
275
|
+
graphql_fields_by_name.values.each do |field|
|
276
|
+
field.define_highlights_field(t)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
266
281
|
def new_non_empty_object_type(name, &block)
|
267
282
|
type = schema_def_state.factory.new_object_type(name, &block)
|
268
283
|
type unless type.graphql_fields_by_name.empty?
|
@@ -116,7 +116,7 @@ module ElasticGraph
|
|
116
116
|
def define_root_graphql_type
|
117
117
|
state.api.object_type "Query" do |query_type|
|
118
118
|
query_type.documentation "The query entry point for the entire schema."
|
119
|
-
query_type.
|
119
|
+
query_type.default_graphql_resolver = nil
|
120
120
|
|
121
121
|
state.types_by_name.values.select(&:indexed?).sort_by(&:name).each do |type|
|
122
122
|
# @type var indexed_type: Mixins::HasIndices & _Type
|
@@ -130,7 +130,7 @@ module ElasticGraph
|
|
130
130
|
singular: indexed_type.singular_root_query_field_name
|
131
131
|
) do |f|
|
132
132
|
f.documentation "Fetches `#{indexed_type.name}`s based on the provided arguments."
|
133
|
-
f.
|
133
|
+
f.resolver = :list_records
|
134
134
|
f.hide_relationship_runtime_metadata = true
|
135
135
|
indexed_type.root_query_fields_customizations&.call(f)
|
136
136
|
end
|
@@ -364,8 +364,8 @@ module ElasticGraph
|
|
364
364
|
.object_types_by_name
|
365
365
|
.each do |type_name, type|
|
366
366
|
type.graphql_fields_by_name.each do |field_name, field|
|
367
|
-
if (
|
368
|
-
fields_by_resolvers[
|
367
|
+
if (resolver = field.resolver)
|
368
|
+
fields_by_resolvers[resolver] << "#{type_name}.#{field_name}"
|
369
369
|
end
|
370
370
|
end
|
371
371
|
end
|
@@ -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
|
#
|
@@ -157,6 +151,9 @@ module ElasticGraph
|
|
157
151
|
# `PageInfo` specification from the [Relay GraphQL Cursor Connections
|
158
152
|
# Specification](https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo).
|
159
153
|
#
|
154
|
+
# SearchHighlight
|
155
|
+
# : Provides information about why a document matched a search via highlighted snippets.
|
156
|
+
#
|
160
157
|
# @!attribute [rw] schema_def_api
|
161
158
|
# @private
|
162
159
|
# @!attribute [rw] schema_def_state
|
@@ -206,23 +203,6 @@ module ElasticGraph
|
|
206
203
|
def register_standard_elastic_graph_types
|
207
204
|
# This is a special filter on a `String` type, so we don't have a `Text` scalar to generate it from.
|
208
205
|
schema_def_state.factory.build_standard_filter_input_types_for_index_leaf_type("String", name_prefix: "Text") do |t|
|
209
|
-
# We can't support filtering on `null` within a list, so make the field non-nullable when it's the
|
210
|
-
# `ListElementFilterInput` type. See scalar_type.rb for a larger comment explaining the rationale behind this.
|
211
|
-
equal_to_any_of_type = t.type_ref.list_element_filter_input? ? "[String!]" : "[String]"
|
212
|
-
t.field names.equal_to_any_of, equal_to_any_of_type do |f|
|
213
|
-
f.documentation ScalarType::EQUAL_TO_ANY_OF_DOC
|
214
|
-
end
|
215
|
-
|
216
|
-
t.field names.matches, "String" do |f|
|
217
|
-
f.documentation <<~EOS
|
218
|
-
Matches records where the field value matches the provided value using full text search.
|
219
|
-
|
220
|
-
When `null` is passed, matches all documents.
|
221
|
-
EOS
|
222
|
-
|
223
|
-
f.directive "deprecated", reason: "Use `#{names.matches_query}` instead."
|
224
|
-
end
|
225
|
-
|
226
206
|
t.field names.matches_query, schema_def_state.type_ref("MatchesQuery").as_filter_input.name do |f|
|
227
207
|
f.documentation <<~EOS
|
228
208
|
Matches records where the field value matches the provided query using full text search.
|
@@ -300,7 +280,71 @@ module ElasticGraph
|
|
300
280
|
f.documentation "The input phrase to search for."
|
301
281
|
end
|
302
282
|
|
303
|
-
# 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
|
304
348
|
# to apply an OR operator or negation to the fields of this type since they are all an
|
305
349
|
# indivisible part of a single filter operation on a specific field. So we remove them
|
306
350
|
# here.
|
@@ -394,7 +438,7 @@ module ElasticGraph
|
|
394
438
|
# to go from non-null to null, but is not a breaking change to make it non-null
|
395
439
|
# in the future.
|
396
440
|
register_framework_object_type "PageInfo" do |t|
|
397
|
-
t.
|
441
|
+
t.default_graphql_resolver = :object_without_lookahead
|
398
442
|
|
399
443
|
t.documentation <<~EOS
|
400
444
|
Provides information about the specific fetched page. This implements the `PageInfo`
|
@@ -425,6 +469,23 @@ module ElasticGraph
|
|
425
469
|
end
|
426
470
|
end
|
427
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
|
+
|
428
489
|
schema_def_api.factory.new_input_type("DateTimeGroupingOffsetInput") do |t|
|
429
490
|
t.documentation <<~EOS
|
430
491
|
Input type offered when grouping on `DateTime` fields, representing the amount of offset
|
@@ -512,7 +573,7 @@ module ElasticGraph
|
|
512
573
|
|
513
574
|
register_framework_object_type "AggregationCountDetail" do |t|
|
514
575
|
t.documentation "Provides detail about an aggregation `#{names.count}`."
|
515
|
-
t.
|
576
|
+
t.default_graphql_resolver = :object_without_lookahead
|
516
577
|
|
517
578
|
t.field names.approximate_value, "JsonSafeLong!", graphql_only: true do |f|
|
518
579
|
f.documentation <<~EOS
|
@@ -619,6 +680,24 @@ module ElasticGraph
|
|
619
680
|
schema_def_api.scalar_type "String" do |t|
|
620
681
|
t.mapping type: "keyword"
|
621
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
|
622
701
|
end
|
623
702
|
end
|
624
703
|
|
@@ -953,38 +1032,6 @@ module ElasticGraph
|
|
953
1032
|
# elasticgraph-graphql/spec/acceptance/elasticgraph_graphql_spec.rb
|
954
1033
|
es_first_day_of_week = "Monday"
|
955
1034
|
|
956
|
-
# TODO: Drop support for legacy grouping schema
|
957
|
-
schema_def_api.enum_type "DateGroupingGranularity" do |t|
|
958
|
-
t.documentation <<~EOS
|
959
|
-
Enumerates the supported granularities of a `Date`.
|
960
|
-
EOS
|
961
|
-
|
962
|
-
t.value "YEAR" do |v|
|
963
|
-
v.documentation "The year a `Date` falls in."
|
964
|
-
v.update_runtime_metadata datastore_value: "year"
|
965
|
-
end
|
966
|
-
|
967
|
-
t.value "QUARTER" do |v|
|
968
|
-
v.documentation "The quarter a `Date` falls in."
|
969
|
-
v.update_runtime_metadata datastore_value: "quarter"
|
970
|
-
end
|
971
|
-
|
972
|
-
t.value "MONTH" do |v|
|
973
|
-
v.documentation "The month a `Date` falls in."
|
974
|
-
v.update_runtime_metadata datastore_value: "month"
|
975
|
-
end
|
976
|
-
|
977
|
-
t.value "WEEK" do |v|
|
978
|
-
v.documentation "The week, beginning on #{es_first_day_of_week}, a `Date` falls in."
|
979
|
-
v.update_runtime_metadata datastore_value: "week"
|
980
|
-
end
|
981
|
-
|
982
|
-
t.value "DAY" do |v|
|
983
|
-
v.documentation "The exact day of a `Date`."
|
984
|
-
v.update_runtime_metadata datastore_value: "day"
|
985
|
-
end
|
986
|
-
end
|
987
|
-
|
988
1035
|
schema_def_api.enum_type "DateGroupingTruncationUnit" do |t|
|
989
1036
|
t.documentation <<~EOS
|
990
1037
|
Enumerates the supported truncation units of a `Date`.
|
@@ -1016,53 +1063,6 @@ module ElasticGraph
|
|
1016
1063
|
end
|
1017
1064
|
end
|
1018
1065
|
|
1019
|
-
# TODO: Drop support for legacy grouping schema
|
1020
|
-
schema_def_api.enum_type "DateTimeGroupingGranularity" do |t|
|
1021
|
-
t.documentation <<~EOS
|
1022
|
-
Enumerates the supported granularities of a `DateTime`.
|
1023
|
-
EOS
|
1024
|
-
|
1025
|
-
t.value "YEAR" do |v|
|
1026
|
-
v.documentation "The year a `DateTime` falls in."
|
1027
|
-
v.update_runtime_metadata datastore_value: "year"
|
1028
|
-
end
|
1029
|
-
|
1030
|
-
t.value "QUARTER" do |v|
|
1031
|
-
v.documentation "The quarter a `DateTime` falls in."
|
1032
|
-
v.update_runtime_metadata datastore_value: "quarter"
|
1033
|
-
end
|
1034
|
-
|
1035
|
-
t.value "MONTH" do |v|
|
1036
|
-
v.documentation "The month a `DateTime` falls in."
|
1037
|
-
v.update_runtime_metadata datastore_value: "month"
|
1038
|
-
end
|
1039
|
-
|
1040
|
-
t.value "WEEK" do |v|
|
1041
|
-
v.documentation "The week, beginning on #{es_first_day_of_week}, a `DateTime` falls in."
|
1042
|
-
v.update_runtime_metadata datastore_value: "week"
|
1043
|
-
end
|
1044
|
-
|
1045
|
-
t.value "DAY" do |v|
|
1046
|
-
v.documentation "The day a `DateTime` falls in."
|
1047
|
-
v.update_runtime_metadata datastore_value: "day"
|
1048
|
-
end
|
1049
|
-
|
1050
|
-
t.value "HOUR" do |v|
|
1051
|
-
v.documentation "The hour a `DateTime` falls in."
|
1052
|
-
v.update_runtime_metadata datastore_value: "hour"
|
1053
|
-
end
|
1054
|
-
|
1055
|
-
t.value "MINUTE" do |v|
|
1056
|
-
v.documentation "The minute a `DateTime` falls in."
|
1057
|
-
v.update_runtime_metadata datastore_value: "minute"
|
1058
|
-
end
|
1059
|
-
|
1060
|
-
t.value "SECOND" do |v|
|
1061
|
-
v.documentation "The second a `DateTime` falls in."
|
1062
|
-
v.update_runtime_metadata datastore_value: "second"
|
1063
|
-
end
|
1064
|
-
end
|
1065
|
-
|
1066
1066
|
schema_def_api.enum_type "DateTimeGroupingTruncationUnit" do |t|
|
1067
1067
|
t.documentation <<~EOS
|
1068
1068
|
Enumerates the supported truncation units of a `DateTime`.
|
@@ -1294,7 +1294,7 @@ module ElasticGraph
|
|
1294
1294
|
date = schema_def_state.type_ref("Date")
|
1295
1295
|
register_framework_object_type date.as_grouped_by.name do |t|
|
1296
1296
|
t.documentation "Allows for grouping `Date` values based on the desired return type."
|
1297
|
-
t.
|
1297
|
+
t.default_graphql_resolver = :object_with_lookahead
|
1298
1298
|
t.override_runtime_metadata(elasticgraph_category: :date_grouped_by_object)
|
1299
1299
|
|
1300
1300
|
t.field names.as_date, "Date", graphql_only: true do |f|
|
@@ -1312,7 +1312,7 @@ module ElasticGraph
|
|
1312
1312
|
date_time = schema_def_state.type_ref("DateTime")
|
1313
1313
|
register_framework_object_type date_time.as_grouped_by.name do |t|
|
1314
1314
|
t.documentation "Allows for grouping `DateTime` values based on the desired return type."
|
1315
|
-
t.
|
1315
|
+
t.default_graphql_resolver = :object_with_lookahead
|
1316
1316
|
t.override_runtime_metadata(elasticgraph_category: :date_grouped_by_object)
|
1317
1317
|
|
1318
1318
|
t.field names.as_date_time, "DateTime", graphql_only: true do |f|
|