elasticgraph-schema_definition 0.19.2.2 → 0.19.3.1
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 +12 -5
- data/lib/elastic_graph/schema_definition/factory.rb +4 -4
- 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 +17 -4
- 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 +1 -1
- data/lib/elastic_graph/schema_definition/mixins/implements_interfaces.rb +13 -2
- 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 +7 -7
- 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 +113 -5
- 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 +94 -13
- 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 +1 -1
- 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 +1 -1
- data/lib/elastic_graph/schema_definition/schema_elements/type_reference.rb +10 -7
- data/lib/elastic_graph/schema_definition/schema_elements/type_with_subfields.rb +26 -7
- 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/state.rb +1 -1
- data/lib/elastic_graph/schema_definition/test_support.rb +1 -1
- metadata +26 -26
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 06ba81265998cca23b0d1cd192b02d2b90dbf5f5ee4719aab4af06928aabd797
|
|
4
|
+
data.tar.gz: f99da1ae45737e89412090c976c1e00fdb64a2c035cd3c3fc90797ce090ec874
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1528be317ffe61b04c3a9e8dc5c2f42c55e721d6998365d600219acbaa7b412319220a9a2bd51303bdaf6c20b7cee83f6282bb9469a0faba5c5ecc1b4218a09
|
|
7
|
+
data.tar.gz: ff47ac4507c7cf94e918be6ddf5c72a44d2d6d3712bc7a9101819df8e3b6d1c39bc0e598d5600ce4ab66a73067686940806dfb03ff27fbfb7719bc571f6f66a0
|
data/LICENSE.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2024 -
|
|
1
|
+
# Copyright 2024 - 2026 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
|
|
@@ -300,28 +300,35 @@ 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
|
|
303
305
|
#
|
|
304
306
|
# @example Register a custom resolver for use by a custom `Query` field
|
|
305
307
|
# # In `add_resolver.rb`:
|
|
306
308
|
# class AddResolver
|
|
307
309
|
# def initialize(elasticgraph_graphql:, config:)
|
|
310
|
+
# @multiplier = config.fetch(:multiplier, 1)
|
|
308
311
|
# end
|
|
309
312
|
#
|
|
310
313
|
# def resolve(field:, object:, args:, context:)
|
|
311
|
-
# args.fetch("x") + args.fetch("y")
|
|
314
|
+
# sum = args.fetch("x") + args.fetch("y")
|
|
315
|
+
# sum * @multiplier
|
|
312
316
|
# end
|
|
313
317
|
# end
|
|
314
318
|
#
|
|
315
319
|
# # In `config/schema.rb`:
|
|
316
320
|
# ElasticGraph.define_schema do |schema|
|
|
317
321
|
# require(resolver_path = "add_resolver")
|
|
318
|
-
# schema.register_graphql_resolver :add,
|
|
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`.
|
|
319
326
|
#
|
|
320
327
|
# schema.on_root_query_type do |t|
|
|
321
328
|
# t.field "add", "Int" do |f|
|
|
322
329
|
# f.argument "x", "Int!"
|
|
323
330
|
# f.argument "y", "Int!"
|
|
324
|
-
# f.
|
|
331
|
+
# f.resolve_with :add
|
|
325
332
|
# end
|
|
326
333
|
# end
|
|
327
334
|
# end
|
|
@@ -354,7 +361,7 @@ module ElasticGraph
|
|
|
354
361
|
#
|
|
355
362
|
# schema.on_root_query_type do |t|
|
|
356
363
|
# t.field "artist", "Artist" do |f|
|
|
357
|
-
# f.
|
|
364
|
+
# f.resolve_with :artist
|
|
358
365
|
# end
|
|
359
366
|
# end
|
|
360
367
|
# end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2024 -
|
|
1
|
+
# Copyright 2024 - 2026 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
|
|
@@ -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.resolve_fields_with :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|
|
|
@@ -435,7 +435,7 @@ module ElasticGraph
|
|
|
435
435
|
type_ref = @state.type_ref(type_name)
|
|
436
436
|
new_object_type type_ref.as_edge.name do |t|
|
|
437
437
|
t.relay_pagination_type = true
|
|
438
|
-
t.
|
|
438
|
+
t.resolve_fields_with :object_without_lookahead
|
|
439
439
|
t.override_runtime_metadata(elasticgraph_category: :relay_edge)
|
|
440
440
|
|
|
441
441
|
t.documentation <<~EOS
|
|
@@ -463,7 +463,7 @@ module ElasticGraph
|
|
|
463
463
|
type_ref = @state.type_ref(type_name)
|
|
464
464
|
new_object_type type_ref.as_connection.name do |t|
|
|
465
465
|
t.relay_pagination_type = true
|
|
466
|
-
t.
|
|
466
|
+
t.resolve_fields_with :object_without_lookahead
|
|
467
467
|
t.override_runtime_metadata(elasticgraph_category: :relay_connection)
|
|
468
468
|
|
|
469
469
|
if support_pagination
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2024 -
|
|
1
|
+
# Copyright 2024 - 2026 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
|
|
@@ -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_reader :default_graphql_resolver
|
|
24
|
+
# @dynamic 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
|
+
resolve_fields_with :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,6 +72,19 @@ 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
|
+
|
|
75
88
|
# List of indices. (Currently we only store one but we may support multiple in the future).
|
|
76
89
|
#
|
|
77
90
|
# @private
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2024 -
|
|
1
|
+
# Copyright 2024 - 2026 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
|
|
@@ -112,11 +112,22 @@ module ElasticGraph
|
|
|
112
112
|
if implemented_interfaces.empty?
|
|
113
113
|
name
|
|
114
114
|
else
|
|
115
|
-
|
|
115
|
+
# Include all ancestor interfaces in SDL
|
|
116
|
+
all_interfaces = recursively_resolve_interface_supertypes.uniq
|
|
117
|
+
"#{name} implements #{all_interfaces.map(&:name).sort.join(" & ")}"
|
|
116
118
|
end
|
|
117
119
|
|
|
118
120
|
generate_sdl(name_section: name_section, &field_arg_selector)
|
|
119
121
|
end
|
|
122
|
+
|
|
123
|
+
private
|
|
124
|
+
|
|
125
|
+
def recursively_resolve_interface_supertypes
|
|
126
|
+
implemented_interfaces.flat_map do |interface_ref|
|
|
127
|
+
interface = interface_ref.resolved # : SchemaElements::InterfaceType
|
|
128
|
+
[interface] + interface.send(:recursively_resolve_interface_supertypes)
|
|
129
|
+
end
|
|
130
|
+
end
|
|
120
131
|
end
|
|
121
132
|
end
|
|
122
133
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2024 -
|
|
1
|
+
# Copyright 2024 - 2026 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
|
|
@@ -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.resolve_fields_with :object_without_lookahead
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
@@ -117,7 +117,7 @@ module ElasticGraph
|
|
|
117
117
|
schema_def_state.sub_aggregation_paths_for(nested_field_ref.parent_type).map do |path|
|
|
118
118
|
schema_def_state.factory.new_object_type type_ref.as_sub_aggregation(parent_doc_types: path.parent_doc_types).name do |t|
|
|
119
119
|
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.
|
|
120
|
+
t.resolve_fields_with :object_without_lookahead
|
|
121
121
|
|
|
122
122
|
t.field schema_def_state.schema_elements.count_detail, "AggregationCountDetail", graphql_only: true do |f|
|
|
123
123
|
f.documentation "Details of the count of `#{name}` documents in a sub-aggregation bucket."
|
|
@@ -165,7 +165,7 @@ module ElasticGraph
|
|
|
165
165
|
schema_def_state.factory.new_object_type agg_sub_aggs_type_ref.name do |t|
|
|
166
166
|
under_field_description = "under `#{path.field_path_string}` " unless path.field_path.empty?
|
|
167
167
|
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.
|
|
168
|
+
t.resolve_fields_with :object_with_lookahead
|
|
169
169
|
|
|
170
170
|
sub_aggregatable_fields.each do |field|
|
|
171
171
|
if field.nested?
|
|
@@ -228,7 +228,7 @@ module ElasticGraph
|
|
|
228
228
|
|
|
229
229
|
# Record metadata that is necessary for elasticgraph-graphql to correctly recognize and handle
|
|
230
230
|
# this indexed aggregation type correctly.
|
|
231
|
-
t.
|
|
231
|
+
t.resolve_fields_with :object_without_lookahead
|
|
232
232
|
t.override_runtime_metadata(source_type: name, elasticgraph_category: :indexed_aggregation)
|
|
233
233
|
end
|
|
234
234
|
end
|
|
@@ -240,7 +240,7 @@ module ElasticGraph
|
|
|
240
240
|
|
|
241
241
|
new_non_empty_object_type type_ref.as_grouped_by.name do |t|
|
|
242
242
|
t.documentation "Type used to specify the `#{name}` fields to group by for aggregations."
|
|
243
|
-
t.
|
|
243
|
+
t.resolve_fields_with :object_with_lookahead
|
|
244
244
|
|
|
245
245
|
graphql_fields_by_name.values.each do |field|
|
|
246
246
|
field.define_grouped_by_field(t)
|
|
@@ -255,7 +255,7 @@ module ElasticGraph
|
|
|
255
255
|
|
|
256
256
|
new_non_empty_object_type type_ref.as_aggregated_values.name do |t|
|
|
257
257
|
t.documentation "Type used to perform aggregation computations on `#{name}` fields."
|
|
258
|
-
t.
|
|
258
|
+
t.resolve_fields_with :object_with_lookahead
|
|
259
259
|
|
|
260
260
|
graphql_fields_by_name.values.each do |field|
|
|
261
261
|
field.define_aggregated_values_field(t)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2024 -
|
|
1
|
+
# Copyright 2024 - 2026 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
|
|
@@ -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.resolve_fields_with 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.resolve_with :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_name = field.resolver&.name)
|
|
368
|
+
fields_by_resolvers[resolver_name] << "#{type_name}.#{field_name}"
|
|
369
369
|
end
|
|
370
370
|
end
|
|
371
371
|
end
|