Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ class Config < Support::Config.define(:client_faraday_adapter, :clusters, :index
}],
properties: {
query_cluster: {
type: "string",
description: "Named search cluster to be used for queries on this index. The value must match be a key in the `clusters` map.",
examples: ["main", "search_cluster"]
type: ["string", "null"],
description: "Named search cluster to be used for queries on this index. The value must match be a key in the `clusters` map. Set to `null` to hide this index's types in the GraphQL schema returned from the GraphQL endpoint.",
examples: ["main", "search_cluster", nil]
},
index_into_clusters: {
type: "array",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module ElasticGraph
module Configuration
class IndexDefinitionSupertype
attr_reader ignore_routing_values: ::Set[::String]
attr_reader query_cluster: ::String
attr_reader query_cluster: ::String?
attr_reader index_into_clusters: ::Array[::String]
attr_reader setting_overrides: ::Hash[::String, untyped]
attr_reader setting_overrides_by_timestamp: ::Hash[::String, ::Hash[::String, untyped]]
attr_reader custom_timestamp_ranges: ::Array[IndexDefinition::CustomTimestampRange]

def initialize: (
ignore_routing_values: ::Set[::String],
query_cluster: ::String,
query_cluster: ::String?,
index_into_clusters: ::Array[::String],
setting_overrides: ::Hash[::String, untyped],
setting_overrides_by_timestamp: ::Hash[::String, ::Hash[::String, untyped]],
Expand All @@ -20,7 +20,7 @@ module ElasticGraph

def with: (
?ignore_routing_values: ::Set[::String],
?query_cluster: ::String,
?query_cluster: ::String?,
?index_into_clusters: ::Array[::String],
?setting_overrides: ::Hash[::String, untyped],
?setting_overrides_by_timestamp: ::Hash[::String, ::Hash[::String, untyped]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,43 @@ class DatastoreCore
expect(config.max_client_retries).to eq 3
end

it "allows `query_cluster: null` to hide index types from GraphQL schema" do
config = config_from_yaml(<<~YAML)
client_faraday_adapter: {}
clusters:
main1:
url: http://example.com/1234
backend: elasticsearch
settings:
foo: 23
index_definitions:
widgets:
query_cluster: null
index_into_clusters: ["main1"]
ignore_routing_values: []
setting_overrides: {}
setting_overrides_by_timestamp: {}
custom_timestamp_ranges: []
YAML

widgets_config = config.index_definitions.fetch("widgets")

# Verify the config was loaded correctly from YAML
expect(widgets_config).to eq(Configuration::IndexDefinition.new(
ignore_routing_values: [],
query_cluster: nil,
index_into_clusters: ["main1"],
setting_overrides: {},
setting_overrides_by_timestamp: {},
custom_timestamp_ranges: []
))

# Verify the key property: query_cluster is nil (not a string, not missing)
# This nil value will cause accessible_from_queries? to return false,
# which hides the index's types from the GraphQL schema.
expect(widgets_config.query_cluster).to be_nil
end

it "surfaces misspellings in `backend`" do
expect {
config_from_yaml(<<~YAML)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,17 @@ properties:
number_of_shards: 32
properties:
query_cluster:
type: string
type:
- string
- 'null'
description: Named search cluster to be used for queries on this index.
The value must match be a key in the `clusters` map.
The value must match be a key in the `clusters` map. Set to `null`
to hide this index's types in the GraphQL schema returned from the
GraphQL endpoint.
examples:
- main
- search_cluster
-
index_into_clusters:
type: array
items:
Expand Down
Loading