Skip to content

Commit 8e9b12f

Browse files
committed
Rename fetchable field option to returnable
1 parent 1ed1f2b commit 8e9b12f

5 files changed

Lines changed: 31 additions & 31 deletions

File tree

elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/index.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,11 @@ def mappings
325325
hash["_routing"] = {"required" => true} if uses_custom_routing?
326326
hash["_size"] = {"enabled" => true} if schema_def_state.index_document_sizes?
327327

328-
# Exclude non-fetchable fields from `_source` to save storage. These fields are still
328+
# Exclude non-returnable fields from `_source` to save storage. These fields are still
329329
# indexed (in the inverted index and/or doc_values) for filtering, sorting, and aggregation,
330330
# but their values are not stored in the compressed `_source` blob.
331-
if indexed_type.respond_to?(:non_fetchable_field_paths)
332-
source_excludes = indexed_type.non_fetchable_field_paths
331+
if indexed_type.respond_to?(:non_returnable_field_paths)
332+
source_excludes = indexed_type.non_returnable_field_paths
333333
hash["_source"] = {"excludes" => source_excludes} if source_excludes.any?
334334
end
335335
end

elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/field.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Field < Struct.new(
9191
:name, :original_type, :parent_type, :original_type_for_derived_types, :schema_def_state, :accuracy_confidence,
9292
:filter_customizations, :grouped_by_customizations, :highlights_customizations, :sub_aggregations_customizations,
9393
:aggregated_values_customizations, :sort_order_enum_value_customizations, :args,
94-
:sortable, :filterable, :aggregatable, :groupable, :highlightable, :fetchable,
94+
:sortable, :filterable, :aggregatable, :groupable, :highlightable, :returnable,
9595
:graphql_only, :source, :runtime_field_script, :relationship, :singular_name,
9696
:computation_detail, :non_nullable_in_json_schema, :as_input,
9797
:name_in_index, :resolver
@@ -106,7 +106,7 @@ def initialize(
106106
name:, type:, parent_type:, schema_def_state:,
107107
accuracy_confidence: :high, name_in_index: name,
108108
type_for_derived_types: nil, graphql_only: nil, singular: nil,
109-
sortable: nil, filterable: nil, aggregatable: nil, groupable: nil, highlightable: nil, fetchable: nil,
109+
sortable: nil, filterable: nil, aggregatable: nil, groupable: nil, highlightable: nil, returnable: nil,
110110
as_input: false, resolver: nil
111111
)
112112
type_ref = schema_def_state.type_ref(type)
@@ -129,7 +129,7 @@ def initialize(
129129
aggregatable: aggregatable,
130130
groupable: groupable,
131131
highlightable: highlightable,
132-
fetchable: fetchable,
132+
returnable: returnable,
133133
graphql_only: graphql_only,
134134
source: nil,
135135
runtime_field_script: nil,
@@ -744,14 +744,14 @@ def highlightable?
744744
type_for_derived_types.fully_unwrapped.as_object_type&.supports?(&:highlightable?)
745745
end
746746

747-
# Indicates if this field is fetchable in GraphQL query responses. When `false`, the field will
747+
# Indicates if this field is returnable in GraphQL query responses. When `false`, the field will
748748
# still be available for filtering, sorting, grouping, and aggregation, but will not appear in the
749749
# GraphQL output type and its data will be excluded from `_source` in the datastore for storage savings.
750750
#
751-
# @return [Boolean] true if this field's data can be fetched (default: true)
752-
def fetchable?
753-
return true if fetchable.nil?
754-
fetchable
751+
# @return [Boolean] true if this field's data can be returned (default: true)
752+
def returnable?
753+
return true if returnable.nil?
754+
returnable
755755
end
756756

757757
# Defines an argument on the field.
@@ -905,8 +905,8 @@ def to_filter_field(parent_type:, for_single_value: !type_for_derived_types.list
905905
type_for_derived_types: nil,
906906
resolver: nil,
907907
# Filter fields should always appear in their parent input type's SDL regardless
908-
# of the source field's fetchability.
909-
fetchable: nil
908+
# of the source field's returnability.
909+
returnable: nil
910910
)
911911

912912
schema_def_state.factory.new_field(**params).tap do |f|

elasticgraph-schema_definition/lib/elastic_graph/schema_definition/schema_elements/type_with_subfields.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def name
137137
# ElasticGraph will infer field sortability based on the field's GraphQL type and mapping type.
138138
# @option options [Boolean] highlightable force-enables or disables the ability to request search highlights for this field. When
139139
# not provided, ElasticGraph will infer field highlightable based on the field's mapping type.
140-
# @option options [Boolean] fetchable when set to `false`, the field will not appear in the GraphQL output type and its data
140+
# @option options [Boolean] returnable when set to `false`, the field will not appear in the GraphQL output type and its data
141141
# will be excluded from `_source` in the datastore for storage savings. The field will still be available for filtering,
142142
# sorting, grouping, and aggregation. Defaults to `true`.
143143
# @yield [Field] the field for further customization
@@ -485,21 +485,21 @@ def to_indexing_field_type
485485
)
486486
end
487487

488-
# Returns the list of field paths (in dotted notation) for fields that have `fetchable: false`.
488+
# Returns the list of field paths (in dotted notation) for fields that have `returnable: false`.
489489
# These paths are used to populate `_source.excludes` in the datastore mapping so that
490-
# non-fetchable field data is not stored in `_source`, saving storage space.
490+
# non-returnable field data is not stored in `_source`, saving storage space.
491491
#
492492
# Uses `indexing_fields_by_name_in_index` for traversal (same as `index_field_runtime_metadata_tuples`)
493493
# to avoid infinite recursion through interface/union subtype cycles.
494494
#
495495
# @private
496-
def non_fetchable_field_paths(path_prefix: "")
496+
def non_returnable_field_paths(path_prefix: "")
497497
indexing_fields_by_name_in_index.flat_map do |name, field|
498498
path = path_prefix + name
499-
if !field.fetchable?
499+
if !field.returnable?
500500
[path]
501-
elsif (object_type = field.type.fully_unwrapped.as_object_type) && object_type.respond_to?(:non_fetchable_field_paths)
502-
object_type.non_fetchable_field_paths(path_prefix: "#{path}.")
501+
elsif (object_type = field.type.fully_unwrapped.as_object_type) && object_type.respond_to?(:non_returnable_field_paths)
502+
object_type.non_returnable_field_paths(path_prefix: "#{path}.")
503503
else
504504
[]
505505
end
@@ -555,7 +555,7 @@ def index_field_runtime_metadata_tuples(
555555

556556
def fields_sdl(&arg_selector)
557557
graphql_fields_by_name.values
558-
.select(&:fetchable?)
558+
.select(&:returnable?)
559559
.map { |f| f.to_sdl(&arg_selector) }
560560
.flat_map { |sdl| sdl.split("\n") }
561561
.join("\n ")

elasticgraph-schema_definition/spec/unit/elastic_graph/schema_definition/datastore_config/index_mappings/miscellaneous_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ module SchemaDefinition
117117
})
118118
end
119119

120-
it "includes `_source.excludes` for `fetchable: false` fields" do
120+
it "includes `_source.excludes` for `returnable: false` fields" do
121121
mapping = index_mapping_for "my_type" do |s|
122122
s.object_type "MyType" do |t|
123123
t.field "id", "ID"
124124
t.field "name", "String"
125-
t.field "internal_code", "String", fetchable: false
125+
t.field "internal_code", "String", returnable: false
126126
t.index "my_type"
127127
end
128128
end
@@ -132,7 +132,7 @@ module SchemaDefinition
132132
expect(mapping.dig("properties", "internal_code")).to eq({"type" => "keyword"})
133133
end
134134

135-
it "does not include `_source` config when all fields are fetchable" do
135+
it "does not include `_source` config when all fields are returnable" do
136136
mapping = index_mapping_for "my_type" do |s|
137137
s.object_type "MyType" do |t|
138138
t.field "id", "ID"

elasticgraph-schema_definition/spec/unit/elastic_graph/schema_definition/graphql_schema/object_type_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -643,12 +643,12 @@ module SchemaDefinition
643643
end
644644
end
645645

646-
it "excludes `fetchable: false` fields from the output type but keeps them in filter, sort, grouped_by, aggregated_values, and highlights types" do
646+
it "excludes `returnable: false` fields from the output type but keeps them in filter, sort, grouped_by, aggregated_values, and highlights types" do
647647
result = define_schema do |api|
648648
api.object_type "Widget" do |t|
649649
t.field "id", "ID"
650650
t.field "name", "String"
651-
t.field "internal_code", "String", fetchable: false
651+
t.field "internal_code", "String", returnable: false
652652
t.index "widgets"
653653
end
654654
end
@@ -660,19 +660,19 @@ module SchemaDefinition
660660
}
661661
EOS
662662

663-
# fetchable: false field should still appear in filter input
663+
# returnable: false field should still appear in filter input
664664
expect(filter_type_from(result, "Widget")).to include("internal_code: StringFilterInput")
665665

666-
# fetchable: false field should still appear in sort order
666+
# returnable: false field should still appear in sort order
667667
expect(sort_order_type_from(result, "Widget")).to include("internal_code_ASC")
668668

669-
# fetchable: false field should still appear in grouped_by
669+
# returnable: false field should still appear in grouped_by
670670
expect(grouped_by_type_from(result, "Widget")).to include("internal_code: String")
671671

672-
# fetchable: false field should still appear in aggregated_values
672+
# returnable: false field should still appear in aggregated_values
673673
expect(aggregated_values_type_from(result, "Widget")).to include("internal_code: NonNumericAggregatedValues")
674674

675-
# fetchable: false field should still appear in highlights
675+
# returnable: false field should still appear in highlights
676676
expect(highlights_type_from(result, "Widget")).to include("internal_code: [String!]!")
677677
end
678678

0 commit comments

Comments
 (0)