elasticgraph-query_registry 1.0.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de6e5888de8cd4329c1bb198fdcae37b3a2e423e47ea1a43b21c20633e5a5130
4
- data.tar.gz: 8a8c7f3193a40f40bdfe9bdf8ffb32fb8db2dd2ed4cca6e4c2a79e5f22f56ebd
3
+ metadata.gz: 5e3d0d2079bcd83e50a567566b99a4f709c1f0450980665dadd0496cf8d4a6dc
4
+ data.tar.gz: 396a7da0a2ab59a99e3a9da96fd4affdb2cf49090d2e719e7c24a902481fd801
5
5
  SHA512:
6
- metadata.gz: 5b31a04ac7d0f497107fc4e50477524d0be8893f8fe775df52af84dd4e1826ebebaabc2e603888b83beaa1f318aedaa62d6caf1ccd455554a0908bf8568e2add
7
- data.tar.gz: 29187cf7027a40e3086e84846d86797a73b32d69245ae4e819f68ded25ce5fa941faf831a3d8949afba34acbeb3355831bf5684067a42e4211441b29889f24be
6
+ metadata.gz: 0667b5d50436e7b5b96298f0067a01471f8ab6b3b404fdc65a320b3f3de0c9798004db1d07a13c1c4db58b0e4df8fa1133d6d49ecbacbc4bb938def6d7e3471d
7
+ data.tar.gz: acd27bbb6d6b52e4285cf7fb2aeedf55d4a37237a91d108cb30952f39ad5490f0bce62d93115d2c8652e4b8e17f1255c86fbd2f5663a60d2e86c975d9e721c8d
@@ -0,0 +1,43 @@
1
+ # Copyright 2024 - 2025 Block, Inc.
2
+ #
3
+ # Use of this source code is governed by an MIT-style
4
+ # license that can be found in the LICENSE file or at
5
+ # https://opensource.org/licenses/MIT.
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ require "elastic_graph/support/config"
10
+
11
+ module ElasticGraph
12
+ module QueryRegistry
13
+ class Config < Support::Config.define(:path_to_registry, :allow_unregistered_clients, :allow_any_query_for_clients)
14
+ json_schema at: "query_registry",
15
+ optional: true,
16
+ description: "Configuration for client and query registration used by `elasticgraph-query_registry`.",
17
+ properties: {
18
+ path_to_registry: {
19
+ description: "Path to the directory containing the query registry files.",
20
+ type: "string",
21
+ examples: ["config/queries"]
22
+ },
23
+ allow_unregistered_clients: {
24
+ description: "Whether to allow clients that are not registered in the registry.",
25
+ type: "boolean",
26
+ examples: [true, false],
27
+ default: true
28
+ },
29
+ allow_any_query_for_clients: {
30
+ description: "List of client names that are allowed to execute any query, even if not registered.",
31
+ type: "array",
32
+ items: {type: "string"},
33
+ examples: [
34
+ [], # : untyped
35
+ ["admin", "internal"]
36
+ ],
37
+ default: [] # : untyped
38
+ }
39
+ },
40
+ required: ["path_to_registry"]
41
+ end
42
+ end
43
+ end
@@ -7,6 +7,7 @@
7
7
  # frozen_string_literal: true
8
8
 
9
9
  require "elastic_graph/graphql/query_executor"
10
+ require "elastic_graph/query_registry/config"
10
11
  require "elastic_graph/query_registry/registry"
11
12
  require "graphql"
12
13
  require "pathname"
@@ -15,9 +16,7 @@ module ElasticGraph
15
16
  module QueryRegistry
16
17
  module GraphQLExtension
17
18
  def graphql_query_executor
18
- @graphql_query_executor ||= begin
19
- registry_config = QueryRegistry::Config.from_parsed_yaml(config.extension_settings)
20
-
19
+ @graphql_query_executor ||= if (registry_config = QueryRegistry::Config.from_parsed_yaml(config.extension_settings))
21
20
  RegistryAwareQueryExecutor.new(
22
21
  schema: schema,
23
22
  monotonic_clock: monotonic_clock,
@@ -27,6 +26,8 @@ module ElasticGraph
27
26
  allow_unregistered_clients: registry_config.allow_unregistered_clients,
28
27
  allow_any_query_for_clients: registry_config.allow_any_query_for_clients
29
28
  )
29
+ else
30
+ super
30
31
  end
31
32
  end
32
33
  end
@@ -79,23 +80,5 @@ module ElasticGraph
79
80
  end
80
81
  end
81
82
  end
82
-
83
- class Config < ::Data.define(:path_to_registry, :allow_unregistered_clients, :allow_any_query_for_clients)
84
- def self.from_parsed_yaml(hash)
85
- hash = hash.fetch("query_registry") { return DEFAULT }
86
-
87
- new(
88
- path_to_registry: hash.fetch("path_to_registry"),
89
- allow_unregistered_clients: hash.fetch("allow_unregistered_clients"),
90
- allow_any_query_for_clients: hash.fetch("allow_any_query_for_clients")
91
- )
92
- end
93
-
94
- DEFAULT = new(
95
- path_to_registry: (_ = __dir__),
96
- allow_unregistered_clients: true,
97
- allow_any_query_for_clients: []
98
- )
99
- end
100
83
  end
101
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticgraph-query_registry
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 1.0.0
20
+ version: 1.0.1
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
27
+ version: 1.0.1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: elasticgraph-support
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 1.0.0
34
+ version: 1.0.1
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
41
+ version: 1.0.1
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: graphql
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -93,28 +93,28 @@ dependencies:
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 1.0.0
96
+ version: 1.0.1
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 1.0.0
103
+ version: 1.0.1
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: elasticgraph-opensearch
106
106
  requirement: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 1.0.0
110
+ version: 1.0.1
111
111
  type: :development
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 1.0.0
117
+ version: 1.0.1
118
118
  email:
119
119
  - myron@squareup.com
120
120
  executables: []
@@ -124,6 +124,7 @@ files:
124
124
  - LICENSE.txt
125
125
  - README.md
126
126
  - lib/elastic_graph/query_registry/client_data.rb
127
+ - lib/elastic_graph/query_registry/config.rb
127
128
  - lib/elastic_graph/query_registry/graphql_extension.rb
128
129
  - lib/elastic_graph/query_registry/query_validator.rb
129
130
  - lib/elastic_graph/query_registry/query_validators/for_registered_client.rb
@@ -137,10 +138,10 @@ licenses:
137
138
  - MIT
138
139
  metadata:
139
140
  bug_tracker_uri: https://github.com/block/elasticgraph/issues
140
- changelog_uri: https://github.com/block/elasticgraph/releases/tag/v1.0.0
141
- documentation_uri: https://block.github.io/elasticgraph/api-docs/v1.0.0/
141
+ changelog_uri: https://github.com/block/elasticgraph/releases/tag/v1.0.1
142
+ documentation_uri: https://block.github.io/elasticgraph/api-docs/v1.0.1/
142
143
  homepage_uri: https://block.github.io/elasticgraph/
143
- source_code_uri: https://github.com/block/elasticgraph/tree/v1.0.0/elasticgraph-query_registry
144
+ source_code_uri: https://github.com/block/elasticgraph/tree/v1.0.1/elasticgraph-query_registry
144
145
  gem_category: extension
145
146
  rdoc_options: []
146
147
  require_paths: