elasticgraph-schema_definition 1.0.0.rc1 → 1.0.0.rc2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54e9fd94b73a36f09e090c68605743766da45b9f1777e5622a8b1b0e6985a5a5
4
- data.tar.gz: c656f8bf79e9dcfa7bf88d9f4e2944a606d436b440e337fd3db9d064ad59aad5
3
+ metadata.gz: 2df8cb5a519f1210397de38c6400bb7bbe8ee9f9cdec00c7bc3cb42a774b0b12
4
+ data.tar.gz: 8217dffbed272a98a731ecac27306b3618aedcbfd0a644ff2baaafcc54b1ca2a
5
5
  SHA512:
6
- metadata.gz: d348ef2187ff3dbd29c7c3c198a61153fdf86219bca6b37c35f92bafa0bbc17a26ac46d655f5a871c5d33f14568d27ff91a413ed1431a714491119b94d2ac67b
7
- data.tar.gz: 7db25426957cd9ddfd2a0af5ee78c7248040a270438d95016b73edf9e2c74a08f830866f17a381488bf11706624ef0c58cfe41405b2eaaa485b5277fd2f75914
6
+ metadata.gz: '0924aaa26ccb012d51b22208e7c5184b2d9f7c5003c7d405aa2afa189e316a2c11c1075e096ebbad24c951ef611546c8ec8ec358a54fd47c69bfd3747abede1f'
7
+ data.tar.gz: '091641a18d8483b84c2fb095f1152a310015559fa1a1ae4ae5fcba14bd34db9e7faf86c21a7c15c1f6d6197dd091a7f0408a4ee141a3dc53b2a3e8cf89bd80e1'
data/README.md CHANGED
@@ -5,3 +5,44 @@ generate ElasticGraph's schema artifacts.
5
5
 
6
6
  This gem is not intended to be used in production--production should
7
7
  just use the schema artifacts instead.
8
+
9
+ ## Dependency Diagram
10
+
11
+ ```mermaid
12
+ graph LR;
13
+ classDef targetGemStyle fill:#FADBD8,stroke:#EC7063,color:#000,stroke-width:2px;
14
+ classDef otherEgGemStyle fill:#A9DFBF,stroke:#2ECC71,color:#000;
15
+ classDef externalGemStyle fill:#E0EFFF,stroke:#70A1D7,color:#2980B9;
16
+ elasticgraph-schema_definition["elasticgraph-schema_definition"];
17
+ class elasticgraph-schema_definition targetGemStyle;
18
+ elasticgraph-graphql["elasticgraph-graphql"];
19
+ elasticgraph-schema_definition --> elasticgraph-graphql;
20
+ class elasticgraph-graphql otherEgGemStyle;
21
+ elasticgraph-indexer["elasticgraph-indexer"];
22
+ elasticgraph-schema_definition --> elasticgraph-indexer;
23
+ class elasticgraph-indexer otherEgGemStyle;
24
+ elasticgraph-json_schema["elasticgraph-json_schema"];
25
+ elasticgraph-schema_definition --> elasticgraph-json_schema;
26
+ class elasticgraph-json_schema otherEgGemStyle;
27
+ elasticgraph-schema_artifacts["elasticgraph-schema_artifacts"];
28
+ elasticgraph-schema_definition --> elasticgraph-schema_artifacts;
29
+ class elasticgraph-schema_artifacts otherEgGemStyle;
30
+ elasticgraph-support["elasticgraph-support"];
31
+ elasticgraph-schema_definition --> elasticgraph-support;
32
+ class elasticgraph-support otherEgGemStyle;
33
+ graphql["graphql"];
34
+ elasticgraph-schema_definition --> graphql;
35
+ class graphql externalGemStyle;
36
+ graphql-c_parser["graphql-c_parser"];
37
+ elasticgraph-schema_definition --> graphql-c_parser;
38
+ class graphql-c_parser externalGemStyle;
39
+ rake["rake"];
40
+ elasticgraph-schema_definition --> rake;
41
+ class rake externalGemStyle;
42
+ elasticgraph-local["elasticgraph-local"];
43
+ elasticgraph-local --> elasticgraph-schema_definition;
44
+ class elasticgraph-local otherEgGemStyle;
45
+ click graphql href "https://rubygems.org/gems/graphql" "Open on RubyGems.org" _blank;
46
+ click graphql-c_parser href "https://rubygems.org/gems/graphql-c_parser" "Open on RubyGems.org" _blank;
47
+ click rake href "https://rubygems.org/gems/rake" "Open on RubyGems.org" _blank;
48
+ ```
@@ -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, AddResolver, defined_at: resolver_path
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.resolver = :add
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.resolver = :artist
364
+ # f.resolve_with :artist
358
365
  # end
359
366
  # end
360
367
  # 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.default_graphql_resolver = :object_with_lookahead
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|
@@ -437,7 +437,7 @@ module ElasticGraph
437
437
 
438
438
  new_object_type type_ref.as_edge.name do |t|
439
439
  t.relay_pagination_type = true
440
- t.default_graphql_resolver = :object_without_lookahead
440
+ t.resolve_fields_with :object_without_lookahead
441
441
  t.override_runtime_metadata(elasticgraph_category: :relay_edge)
442
442
 
443
443
  t.documentation <<~EOS
@@ -477,7 +477,7 @@ module ElasticGraph
477
477
  type_ref = @state.type_ref(type_name)
478
478
  new_object_type type_ref.as_connection.name do |t|
479
479
  t.relay_pagination_type = true
480
- t.default_graphql_resolver = :object_without_lookahead
480
+ t.resolve_fields_with :object_without_lookahead
481
481
  t.override_runtime_metadata(elasticgraph_category: :relay_connection)
482
482
 
483
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
- attr_accessor :default_graphql_resolver
24
- # @dynamic default_graphql_resolver, 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
- self.default_graphql_resolver = :get_record_field_value
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
84
+ SchemaArtifacts::RuntimeMetadata::ConfiguredGraphQLResolver.new(it, 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
@@ -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.default_graphql_resolver = :object_without_lookahead
49
+ t.resolve_fields_with :object_without_lookahead
50
50
  end
51
51
  end
52
52
 
@@ -118,7 +118,7 @@ module ElasticGraph
118
118
  schema_def_state.sub_aggregation_paths_for(nested_field_ref.parent_type).map do |path|
119
119
  schema_def_state.factory.new_object_type type_ref.as_sub_aggregation(parent_doc_types: path.parent_doc_types).name do |t|
120
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}`."
121
- t.default_graphql_resolver = :object_without_lookahead
121
+ t.resolve_fields_with :object_without_lookahead
122
122
 
123
123
  t.field schema_def_state.schema_elements.count_detail, "AggregationCountDetail", graphql_only: true do |f|
124
124
  f.documentation "Details of the count of `#{name}` documents in a sub-aggregation bucket."
@@ -166,7 +166,7 @@ module ElasticGraph
166
166
  schema_def_state.factory.new_object_type agg_sub_aggs_type_ref.name do |t|
167
167
  under_field_description = "under `#{path.field_path_string}` " unless path.field_path.empty?
168
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}`."
169
- t.default_graphql_resolver = :object_with_lookahead
169
+ t.resolve_fields_with :object_with_lookahead
170
170
 
171
171
  sub_aggregatable_fields.each do |field|
172
172
  if field.nested?
@@ -229,7 +229,7 @@ module ElasticGraph
229
229
 
230
230
  # Record metadata that is necessary for elasticgraph-graphql to correctly recognize and handle
231
231
  # this indexed aggregation type correctly.
232
- t.default_graphql_resolver = :object_without_lookahead
232
+ t.resolve_fields_with :object_without_lookahead
233
233
  t.override_runtime_metadata(source_type: name, elasticgraph_category: :indexed_aggregation)
234
234
  end
235
235
  end
@@ -241,7 +241,7 @@ module ElasticGraph
241
241
 
242
242
  new_non_empty_object_type type_ref.as_grouped_by.name do |t|
243
243
  t.documentation "Type used to specify the `#{name}` fields to group by for aggregations."
244
- t.default_graphql_resolver = :object_with_lookahead
244
+ t.resolve_fields_with :object_with_lookahead
245
245
 
246
246
  graphql_fields_by_name.values.each do |field|
247
247
  field.define_grouped_by_field(t)
@@ -256,7 +256,7 @@ module ElasticGraph
256
256
 
257
257
  new_non_empty_object_type type_ref.as_aggregated_values.name do |t|
258
258
  t.documentation "Type used to perform aggregation computations on `#{name}` fields."
259
- t.default_graphql_resolver = :object_with_lookahead
259
+ t.resolve_fields_with :object_with_lookahead
260
260
 
261
261
  graphql_fields_by_name.values.each do |field|
262
262
  field.define_aggregated_values_field(t)
@@ -270,7 +270,7 @@ module ElasticGraph
270
270
 
271
271
  new_non_empty_object_type type_ref.as_highlights.name do |t|
272
272
  t.documentation "Type used to request desired `#{name}` search highlight fields."
273
- t.default_graphql_resolver = :get_record_field_value
273
+ t.resolve_fields_with :get_record_field_value
274
274
 
275
275
  graphql_fields_by_name.values.each do |field|
276
276
  field.define_highlights_field(t)
@@ -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.default_graphql_resolver = nil
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.resolver = :list_records
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 (resolver = field.resolver)
368
- fields_by_resolvers[resolver] << "#{type_name}.#{field_name}"
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
@@ -438,7 +438,7 @@ module ElasticGraph
438
438
  # to go from non-null to null, but is not a breaking change to make it non-null
439
439
  # in the future.
440
440
  register_framework_object_type "PageInfo" do |t|
441
- t.default_graphql_resolver = :object_without_lookahead
441
+ t.resolve_fields_with :object_without_lookahead
442
442
 
443
443
  t.documentation <<~EOS
444
444
  Provides information about the specific fetched page. This implements the `PageInfo`
@@ -470,7 +470,7 @@ module ElasticGraph
470
470
  end
471
471
 
472
472
  register_framework_object_type "SearchHighlight" do |t|
473
- t.default_graphql_resolver = :object_without_lookahead
473
+ t.resolve_fields_with :object_without_lookahead
474
474
 
475
475
  t.documentation "Provides information about why a document matched a search via highlighted snippets."
476
476
 
@@ -573,7 +573,7 @@ module ElasticGraph
573
573
 
574
574
  register_framework_object_type "AggregationCountDetail" do |t|
575
575
  t.documentation "Provides detail about an aggregation `#{names.count}`."
576
- t.default_graphql_resolver = :object_without_lookahead
576
+ t.resolve_fields_with :object_without_lookahead
577
577
 
578
578
  t.field names.approximate_value, "JsonSafeLong!", graphql_only: true do |f|
579
579
  f.documentation <<~EOS
@@ -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.default_graphql_resolver = :object_with_lookahead
1297
+ t.resolve_fields_with :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.default_graphql_resolver = :object_with_lookahead
1315
+ t.resolve_fields_with :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|
@@ -8,6 +8,7 @@
8
8
 
9
9
  require "delegate"
10
10
  require "elastic_graph/constants"
11
+ require "elastic_graph/schema_artifacts/runtime_metadata/configured_graphql_resolver"
11
12
  require "elastic_graph/schema_definition/indexing/field"
12
13
  require "elastic_graph/schema_definition/indexing/field_reference"
13
14
  require "elastic_graph/schema_definition/mixins/has_directives"
@@ -141,14 +142,28 @@ module ElasticGraph
141
142
  resolver: resolver
142
143
  )
143
144
 
144
- if name != name_in_index && name_in_index.include?(".") && !graphql_only
145
- raise Errors::SchemaError, "#{self} has an invalid `name_in_index`: #{name_in_index.inspect}. Only `graphql_only: true` fields can have a `name_in_index` that references a child field."
145
+ if name != name_in_index
146
+ if graphql_only
147
+ schema_def_state.after_user_definition_complete do
148
+ unless backing_indexing_field
149
+ raise Errors::SchemaError,
150
+ "GraphQL-only field `#{parent_type.name}.#{name}` has a `name_in_index` (#{name_in_index}) which does not reference an " \
151
+ "existing indexing field. To proceed, remove `graphql_only: true` or update `name_in_index` to match an existing indexing field."
152
+ end
153
+ end
154
+ elsif name_in_index.include?(".")
155
+ raise Errors::SchemaError,
156
+ "#{self} has an invalid `name_in_index`: #{name_in_index.inspect}. " \
157
+ "Only `graphql_only: true` fields can have a `name_in_index` that references a child field."
158
+ end
146
159
  end
147
160
 
148
161
  schema_def_state.register_user_defined_field(self)
149
162
  yield self if block_given?
150
163
  end
151
164
 
165
+ private :resolver=
166
+
152
167
  # @private
153
168
  @@initialize_param_names = instance_method(:initialize).parameters.map(&:last).to_set
154
169
 
@@ -492,6 +507,46 @@ module ElasticGraph
492
507
  )
493
508
  end
494
509
 
510
+ # Configures the GraphQL resolver used to resolve this field. If not set, the resolver configured on the parent type
511
+ # via {Mixins::HasIndices#resolve_fields_with} will be used.
512
+ #
513
+ # @param resolver_name [Symbol] name of the GraphQL resolver
514
+ # @param config [Hash<Symbol, Object>] configuration parameters for the resolver
515
+ # @return [void]
516
+ # @see API#register_graphql_resolver
517
+ #
518
+ # @example Use a custom resolver for a custom `Query` field
519
+ # # In `add_resolver.rb`:
520
+ # class AddResolver
521
+ # def initialize(elasticgraph_graphql:, config:)
522
+ # @multiplier = config.fetch(:multiplier, 1)
523
+ # end
524
+ #
525
+ # def resolve(field:, object:, args:, context:)
526
+ # sum = args.fetch("x") + args.fetch("y")
527
+ # sum * @multiplier
528
+ # end
529
+ # end
530
+ #
531
+ # # In `config/schema.rb`:
532
+ # ElasticGraph.define_schema do |schema|
533
+ # require(resolver_path = "add_resolver")
534
+ # schema.register_graphql_resolver :add, AddResolver, defined_at: resolver_path
535
+ #
536
+ # schema.on_root_query_type do |t|
537
+ # t.field "add", "Int" do |f|
538
+ # f.argument "x", "Int!"
539
+ # f.argument "y", "Int!"
540
+ #
541
+ # # Extra args (`multiplier: 2`, in this example) are passed to the resolver within `config`.
542
+ # f.resolve_with :add, multiplier: 2
543
+ # end
544
+ # end
545
+ # end
546
+ def resolve_with(resolver_name, **config)
547
+ self.resolver = resolver_name&.then { SchemaArtifacts::RuntimeMetadata::ConfiguredGraphQLResolver.new(it, config) }
548
+ end
549
+
495
550
  # @private
496
551
  def runtime_script(script)
497
552
  self.runtime_field_script = script
@@ -1005,13 +1060,29 @@ module ElasticGraph
1005
1060
  )
1006
1061
  end
1007
1062
 
1008
- private
1009
-
1063
+ # The alternate field that is backing this field in the datastore index. Will only be non-`nil` for `graphql_only` fields.
1064
+ # @return [Field, nil] the field backing this field in the index
1065
+ #
1066
+ # @private
1010
1067
  def backing_indexing_field
1011
1068
  return nil unless graphql_only
1012
- parent_type.indexing_fields_by_name_in_index[name_in_index]
1069
+
1070
+ type = parent_type
1071
+ field = nil
1072
+
1073
+ name_in_index.split(".").each do |path_part|
1074
+ if (field = type&.indexing_fields_by_name_in_index&.fetch(path_part, nil))
1075
+ type = field.type.fully_unwrapped.as_object_type
1076
+ else
1077
+ return nil
1078
+ end
1079
+ end
1080
+
1081
+ field
1013
1082
  end
1014
1083
 
1084
+ private
1085
+
1015
1086
  def args_sdl(joiner:, after_opening_paren: "", &arg_selector)
1016
1087
  selected_args = args.values.select(&arg_selector)
1017
1088
  args_sdl = selected_args.map(&:to_sdl).flat_map { |s| s.split("\n") }.join(joiner)
@@ -108,8 +108,12 @@ module ElasticGraph
108
108
  when :enum
109
109
  true
110
110
  else
111
- # If we can't determine the type from the name, just raise an error.
112
- raise Errors::SchemaError, "Type `#{name}` cannot be resolved. Is it misspelled?"
111
+ if block_given?
112
+ yield
113
+ else
114
+ # If we can't determine the type from the name, just raise an error.
115
+ raise Errors::SchemaError, "Type `#{name}` cannot be resolved. Is it misspelled?"
116
+ end
113
117
  end
114
118
  end
115
119
 
@@ -339,7 +343,8 @@ module ElasticGraph
339
343
  return :object if OBJECT_FORMATS.any? { |f| type_namer.matches_format?(name, f) }
340
344
 
341
345
  if (as_output_enum_name = type_namer.extract_base_from(name, format: :InputEnum))
342
- :enum if ENUM_FORMATS.any? { |f| type_namer.matches_format?(as_output_enum_name, f) }
346
+ return :enum if ENUM_FORMATS.any? { |f| type_namer.matches_format?(as_output_enum_name, f) }
347
+ :enum if as_output_enum_name != self.name && schema_def_state.type_ref(as_output_enum_name).enum? { false }
343
348
  end
344
349
  end
345
350
 
@@ -135,6 +135,8 @@ module ElasticGraph
135
135
  # not provided, ElasticGraph will infer field groupability based on the field's GraphQL type and mapping type.
136
136
  # @option options [Boolean] sortable force-enables or disables the ability for queries to sort by this field. When not provided,
137
137
  # ElasticGraph will infer field sortability based on the field's GraphQL type and mapping type.
138
+ # @option options [Boolean] highlightable force-enables or disables the ability to request search highlights for this field. When
139
+ # not provided, ElasticGraph will infer field highlightable based on the field's mapping type.
138
140
  # @yield [Field] the field for further customization
139
141
  # @return [void]
140
142
  #
@@ -279,6 +281,14 @@ module ElasticGraph
279
281
  # differently named field in the index.
280
282
  # @param singular [String] indicates what the singular form of a field's name is. When provided, ElasticGraph will define a
281
283
  # `groupedBy` field (using the singular form) allowing clients to group by individual values from the field.
284
+ # @param aggregatable [Boolean] force-enables or disables the ability for aggregation queries to aggregate over this field.
285
+ # When not provided, ElasticGraph will infer field aggregatability based on the field's GraphQL type and mapping type.
286
+ # @param filterable [Boolean] force-enables or disables the ability for queries to filter by this field. When not provided,
287
+ # ElasticGraph will infer field filterability based on the field's GraphQL type and mapping type.
288
+ # @param groupable [Boolean] force-enables or disables the ability for aggregation queries to group by this field. When
289
+ # not provided, ElasticGraph will infer field groupability based on the field's GraphQL type and mapping type.
290
+ # @param highlightable [Boolean] force-enables or disables the ability to request search highlights for this field. When
291
+ # not provided, ElasticGraph will infer field highlightable based on the field's mapping type.
282
292
  # @yield [Field] the field for further customization
283
293
  # @return [void]
284
294
  #
@@ -295,23 +305,39 @@ module ElasticGraph
295
305
  # t.index "authors"
296
306
  # end
297
307
  # end
298
- def paginated_collection_field(name, element_type, name_in_index: name, singular: nil, &block)
308
+ def paginated_collection_field(
309
+ name,
310
+ element_type,
311
+ name_in_index: name,
312
+ graphql_only: false,
313
+ singular: nil,
314
+ groupable: !!singular,
315
+ filterable: nil,
316
+ aggregatable: nil,
317
+ highlightable: nil,
318
+ &block
319
+ )
299
320
  element_type_ref = schema_def_state.type_ref(element_type).to_final_form
300
321
  element_type = element_type_ref.name
301
322
 
302
323
  schema_def_state.paginated_collection_element_types << element_type
303
324
 
304
- field(name, "[#{element_type}!]!", indexing_only: true, name_in_index: name_in_index, &block)
325
+ unless graphql_only
326
+ field(name, "[#{element_type}!]!", indexing_only: true, name_in_index: name_in_index, &block)
327
+ end
305
328
 
306
329
  field(
307
330
  name,
308
331
  element_type_ref.as_connection.name,
309
332
  name_in_index: name_in_index,
310
333
  type_for_derived_types: "[#{element_type}]",
311
- groupable: !!singular,
312
- sortable: false,
313
334
  graphql_only: true,
314
- singular: singular
335
+ singular: singular,
336
+ groupable: groupable,
337
+ filterable: filterable,
338
+ aggregatable: aggregatable,
339
+ highlightable: highlightable,
340
+ sortable: false
315
341
  ) do |f|
316
342
  f.define_relay_pagination_arguments!
317
343
  block&.call(f)
@@ -535,7 +561,7 @@ module ElasticGraph
535
561
  )
536
562
 
537
563
  field.relationship = relationship
538
- field.resolver = :nested_relationships
564
+ field.resolve_with :nested_relationships
539
565
 
540
566
  yield relationship if block_given?
541
567
 
@@ -173,8 +173,7 @@ module ElasticGraph
173
173
  raise Errors::SchemaError, "Cannot access `user_defined_field_references_by_type_name` until the schema definition is complete."
174
174
  end
175
175
 
176
- @user_defined_field_references_by_type_name ||= user_defined_fields
177
- .group_by { |f| f.type.fully_unwrapped.name }
176
+ user_defined_fields.group_by { |f| f.type.fully_unwrapped.name }
178
177
  end
179
178
  end
180
179
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticgraph-schema_definition
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
@@ -17,84 +17,84 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 1.0.0.rc1
20
+ version: 1.0.0.rc2
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 1.0.0.rc1
27
+ version: 1.0.0.rc2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: elasticgraph-indexer
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 1.0.0.rc1
34
+ version: 1.0.0.rc2
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: 1.0.0.rc1
41
+ version: 1.0.0.rc2
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: elasticgraph-json_schema
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: 1.0.0.rc1
48
+ version: 1.0.0.rc2
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: 1.0.0.rc1
55
+ version: 1.0.0.rc2
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: elasticgraph-schema_artifacts
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: 1.0.0.rc1
62
+ version: 1.0.0.rc2
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
- version: 1.0.0.rc1
69
+ version: 1.0.0.rc2
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: elasticgraph-support
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - '='
75
75
  - !ruby/object:Gem::Version
76
- version: 1.0.0.rc1
76
+ version: 1.0.0.rc2
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - '='
82
82
  - !ruby/object:Gem::Version
83
- version: 1.0.0.rc1
83
+ version: 1.0.0.rc2
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: graphql
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 2.5.6
90
+ version: 2.5.10
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: 2.5.6
97
+ version: 2.5.10
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: graphql-c_parser
100
100
  requirement: !ruby/object:Gem::Requirement
@@ -121,76 +121,70 @@ dependencies:
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '13.2'
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- version: 13.2.1
124
+ version: '13.3'
128
125
  type: :runtime
129
126
  prerelease: false
130
127
  version_requirements: !ruby/object:Gem::Requirement
131
128
  requirements:
132
129
  - - "~>"
133
130
  - !ruby/object:Gem::Version
134
- version: '13.2'
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: 13.2.1
131
+ version: '13.3'
138
132
  - !ruby/object:Gem::Dependency
139
133
  name: elasticgraph-admin
140
134
  requirement: !ruby/object:Gem::Requirement
141
135
  requirements:
142
136
  - - '='
143
137
  - !ruby/object:Gem::Version
144
- version: 1.0.0.rc1
138
+ version: 1.0.0.rc2
145
139
  type: :development
146
140
  prerelease: false
147
141
  version_requirements: !ruby/object:Gem::Requirement
148
142
  requirements:
149
143
  - - '='
150
144
  - !ruby/object:Gem::Version
151
- version: 1.0.0.rc1
145
+ version: 1.0.0.rc2
152
146
  - !ruby/object:Gem::Dependency
153
147
  name: elasticgraph-datastore_core
154
148
  requirement: !ruby/object:Gem::Requirement
155
149
  requirements:
156
150
  - - '='
157
151
  - !ruby/object:Gem::Version
158
- version: 1.0.0.rc1
152
+ version: 1.0.0.rc2
159
153
  type: :development
160
154
  prerelease: false
161
155
  version_requirements: !ruby/object:Gem::Requirement
162
156
  requirements:
163
157
  - - '='
164
158
  - !ruby/object:Gem::Version
165
- version: 1.0.0.rc1
159
+ version: 1.0.0.rc2
166
160
  - !ruby/object:Gem::Dependency
167
161
  name: elasticgraph-elasticsearch
168
162
  requirement: !ruby/object:Gem::Requirement
169
163
  requirements:
170
164
  - - '='
171
165
  - !ruby/object:Gem::Version
172
- version: 1.0.0.rc1
166
+ version: 1.0.0.rc2
173
167
  type: :development
174
168
  prerelease: false
175
169
  version_requirements: !ruby/object:Gem::Requirement
176
170
  requirements:
177
171
  - - '='
178
172
  - !ruby/object:Gem::Version
179
- version: 1.0.0.rc1
173
+ version: 1.0.0.rc2
180
174
  - !ruby/object:Gem::Dependency
181
175
  name: elasticgraph-opensearch
182
176
  requirement: !ruby/object:Gem::Requirement
183
177
  requirements:
184
178
  - - '='
185
179
  - !ruby/object:Gem::Version
186
- version: 1.0.0.rc1
180
+ version: 1.0.0.rc2
187
181
  type: :development
188
182
  prerelease: false
189
183
  version_requirements: !ruby/object:Gem::Requirement
190
184
  requirements:
191
185
  - - '='
192
186
  - !ruby/object:Gem::Version
193
- version: 1.0.0.rc1
187
+ version: 1.0.0.rc2
194
188
  email:
195
189
  - myron@squareup.com
196
190
  executables: []
@@ -275,10 +269,10 @@ licenses:
275
269
  - MIT
276
270
  metadata:
277
271
  bug_tracker_uri: https://github.com/block/elasticgraph/issues
278
- changelog_uri: https://github.com/block/elasticgraph/releases/tag/v1.0.0.rc1
279
- documentation_uri: https://block.github.io/elasticgraph/api-docs/v1.0.0.rc1/
272
+ changelog_uri: https://github.com/block/elasticgraph/releases/tag/v1.0.0.rc2
273
+ documentation_uri: https://block.github.io/elasticgraph/api-docs/v1.0.0.rc2/
280
274
  homepage_uri: https://block.github.io/elasticgraph/
281
- source_code_uri: https://github.com/block/elasticgraph/tree/v1.0.0.rc1/elasticgraph-schema_definition
275
+ source_code_uri: https://github.com/block/elasticgraph/tree/v1.0.0.rc2/elasticgraph-schema_definition
282
276
  gem_category: local
283
277
  rdoc_options: []
284
278
  require_paths: