elasticgraph-query_interceptor 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 961eb6f23f91dbac939fa40185205c9cf39a955af23162f5aea96e2bb3e5c16d
|
4
|
+
data.tar.gz: 555bbb6ea906dc064fe0e66c0a654e1b56e9e7b3ec5ce155e14d0a3b22a89724
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19a58a6308abf7e5066baf62433a415c94fbc27f3529d8574e48b0fc64b7e69501c9aaa6c1c4f03deb482f4a993389e5c52b46fbf977190b41115ca238671df5
|
7
|
+
data.tar.gz: b6881dc7647b706070f393bea85baa5c356d3a5d9eff8805f3de7b9fda43b770df3fa3a73afa5dc528e363c5942fafcbea78f999b30de3352189dba35bed8125
|
@@ -6,41 +6,85 @@
|
|
6
6
|
#
|
7
7
|
# frozen_string_literal: true
|
8
8
|
|
9
|
+
require "elastic_graph/support/config"
|
9
10
|
require "elastic_graph/schema_artifacts/runtime_metadata/extension_loader"
|
10
11
|
|
11
12
|
module ElasticGraph
|
12
13
|
module QueryInterceptor
|
13
14
|
# Defines configuration for elasticgraph-query_interceptor
|
14
|
-
class Config < ::
|
15
|
-
|
16
|
-
|
15
|
+
class Config < Support::Config.define(:interceptors)
|
16
|
+
json_schema at: "query_interceptor",
|
17
|
+
optional: true,
|
18
|
+
description: "Configuration of datastore query interceptors used by `elasticgraph-query_interceptor`.",
|
19
|
+
properties: {
|
20
|
+
interceptors: {
|
21
|
+
description: "List of query interceptors to apply to datastore queries before they are executed.",
|
22
|
+
type: "array",
|
23
|
+
items: {
|
24
|
+
type: "object",
|
25
|
+
properties: {
|
26
|
+
name: {
|
27
|
+
description: "The name of the interceptor extension class.",
|
28
|
+
type: "string",
|
29
|
+
pattern: /^[A-Z]\w+(::[A-Z]\w+)*$/.source, # https://rubular.com/r/UuqAz4fR3kdMip
|
30
|
+
examples: ["HideInternalRecordsInterceptor"]
|
31
|
+
},
|
32
|
+
require_path: {
|
33
|
+
description: "The path to require to load the interceptor extension. This should be a relative path from a directory on " \
|
34
|
+
"the Ruby `$LOAD_PATH` or a a relative path from the ElasticGraph application root.",
|
35
|
+
type: "string",
|
36
|
+
minLength: 1,
|
37
|
+
examples: ["./lib/interceptors/hide_internal_records_interceptor"]
|
38
|
+
},
|
39
|
+
config: {
|
40
|
+
description: "Configuration for the interceptor. Will be passed into the interceptors `#initialize` method.",
|
41
|
+
type: "object",
|
42
|
+
examples: [
|
43
|
+
{}, # : untyped
|
44
|
+
{"timeout" => 30}
|
45
|
+
],
|
46
|
+
default: {} # : untyped
|
47
|
+
}
|
48
|
+
},
|
49
|
+
required: ["name", "require_path"]
|
50
|
+
},
|
51
|
+
examples: [
|
52
|
+
[], # : untyped
|
53
|
+
[
|
54
|
+
{
|
55
|
+
"name" => "HideInternalRecordsInterceptor",
|
56
|
+
"require_path" => "./lib/interceptors/hide_internal_records_interceptor"
|
57
|
+
}
|
58
|
+
]
|
59
|
+
],
|
60
|
+
default: [] # : untyped
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
def with_runtime_metadata_configs(parsed_runtime_metadata_hashes)
|
17
65
|
interceptor_hashes = parsed_runtime_metadata_hashes.flat_map { |h| h["interceptors"] || [] }
|
66
|
+
return self if interceptor_hashes.empty?
|
18
67
|
|
19
|
-
|
20
|
-
|
68
|
+
with(interceptors: interceptors + load_interceptors(interceptor_hashes))
|
69
|
+
end
|
21
70
|
|
22
|
-
|
23
|
-
raise Errors::ConfigError, "Unknown `query_interceptor` config settings: #{extra_keys.join(", ")}"
|
24
|
-
end
|
71
|
+
private
|
25
72
|
|
26
|
-
|
27
|
-
|
73
|
+
def convert_values(interceptors:)
|
74
|
+
{interceptors: load_interceptors(interceptors)}
|
75
|
+
end
|
28
76
|
|
77
|
+
def load_interceptors(interceptor_hashes)
|
29
78
|
loader = SchemaArtifacts::RuntimeMetadata::ExtensionLoader.new(InterceptorInterface)
|
79
|
+
empty_config = {} # : ::Hash[::Symbol, untyped]
|
30
80
|
|
31
|
-
|
32
|
-
empty_config = {} # : ::Hash[::Symbol, untyped]
|
81
|
+
interceptor_hashes.map do |hash|
|
33
82
|
ext = loader.load(hash.fetch("name"), from: hash.fetch("require_path"), config: empty_config)
|
34
83
|
config = hash["config"] || {} # : ::Hash[::String, untyped]
|
35
|
-
InterceptorData.new(klass: ext.extension_class, config: config)
|
84
|
+
InterceptorData.new(klass: (_ = ext.extension_class), config: config)
|
36
85
|
end
|
37
|
-
|
38
|
-
new(interceptors)
|
39
86
|
end
|
40
87
|
|
41
|
-
DEFAULT = new([])
|
42
|
-
EXPECTED_KEYS = members.map(&:to_s)
|
43
|
-
|
44
88
|
# Defines a data structure to hold interceptor klass and config
|
45
89
|
InterceptorData = ::Data.define(:klass, :config)
|
46
90
|
|
@@ -19,8 +19,10 @@ module ElasticGraph
|
|
19
19
|
Support::HashUtil.stringify_keys(ext_mod.config) if ext_mod.extension_class == GraphQLExtension
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
query_interceptor_config = Config.from_parsed_yaml(config.extension_settings) || Config.new
|
23
|
+
|
24
|
+
interceptors = query_interceptor_config
|
25
|
+
.with_runtime_metadata_configs(runtime_metadata_configs)
|
24
26
|
.interceptors
|
25
27
|
.map { |data| data.klass.new(elasticgraph_graphql: self, config: data.config) }
|
26
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticgraph-query_interceptor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myron Marston
|
@@ -17,70 +17,70 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.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.
|
27
|
+
version: 1.0.1
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: elasticgraph-schema_artifacts
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - '='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.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.
|
41
|
+
version: 1.0.1
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: elasticgraph-elasticsearch
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - '='
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 1.0.
|
48
|
+
version: 1.0.1
|
49
49
|
type: :development
|
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.
|
55
|
+
version: 1.0.1
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: elasticgraph-opensearch
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - '='
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 1.0.
|
62
|
+
version: 1.0.1
|
63
63
|
type: :development
|
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.
|
69
|
+
version: 1.0.1
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: elasticgraph-schema_definition
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - '='
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 1.0.
|
76
|
+
version: 1.0.1
|
77
77
|
type: :development
|
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.
|
83
|
+
version: 1.0.1
|
84
84
|
email:
|
85
85
|
- myron@squareup.com
|
86
86
|
executables: []
|
@@ -97,10 +97,10 @@ licenses:
|
|
97
97
|
- MIT
|
98
98
|
metadata:
|
99
99
|
bug_tracker_uri: https://github.com/block/elasticgraph/issues
|
100
|
-
changelog_uri: https://github.com/block/elasticgraph/releases/tag/v1.0.
|
101
|
-
documentation_uri: https://block.github.io/elasticgraph/api-docs/v1.0.
|
100
|
+
changelog_uri: https://github.com/block/elasticgraph/releases/tag/v1.0.1
|
101
|
+
documentation_uri: https://block.github.io/elasticgraph/api-docs/v1.0.1/
|
102
102
|
homepage_uri: https://block.github.io/elasticgraph/
|
103
|
-
source_code_uri: https://github.com/block/elasticgraph/tree/v1.0.
|
103
|
+
source_code_uri: https://github.com/block/elasticgraph/tree/v1.0.1/elasticgraph-query_interceptor
|
104
104
|
gem_category: extension
|
105
105
|
rdoc_options: []
|
106
106
|
require_paths:
|