elasticgraph-query_registry 0.19.2.0 → 0.19.2.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: 15936723cde48765d3beb730307317c8aeb23c01802db79d7492fe8939e2be30
4
- data.tar.gz: bbd79c94f0af60f13d34149796c4643b4d01d539c65ba6475c4b213470dd4824
3
+ metadata.gz: d62adb1979caa109bdd915d9dff034c3f79983a5d956afd9de8026300592f217
4
+ data.tar.gz: 3a2d0176810a12d6b2fa315330a4af2589b609efe3bf02f80531df04a40cff1a
5
5
  SHA512:
6
- metadata.gz: 5bd4b017d58b2e5fe0f477373372bdf82c40e63ff8b4cc597f9000c1b09c5f463f4249b63974f8043916d7f33487f8c8a01b637dd2b689c9d72b2f2c12b17f7d
7
- data.tar.gz: ef3d679b89173f45d424cce0354e09b03f110de8a65b01e48723af24d519aca11d87aa7f2c1061a91b95f147c231abaaa48eb5ee2162b6f2a7a14b153e8d102d
6
+ metadata.gz: 4d076ddab2b7d15b94718f394b2e0ae0cbdc29dd85a9084968249f5dd8d40b30ac6e72860310561ee88d585f0a3eba99c4ff4239cf286d1f4c7f09bc4dfa97dd
7
+ data.tar.gz: f9ee94d7f41d76532f22171e721ebc23dd4383aeee5f102b9be9b232ca28de5fcb69ce8c624439850534b71d926a86fd901174fcef86d029fb35f5bd350793c4
@@ -12,7 +12,7 @@ module ElasticGraph
12
12
  # @implements ClientData
13
13
  def self.from(schema, registered_query_strings)
14
14
  queries_by_original_string = registered_query_strings.to_h do |query_string|
15
- [query_string, ::GraphQL::Query.new(schema.graphql_schema, query_string, validate: false)]
15
+ [query_string, schema.new_graphql_query(query_string, validate: false)]
16
16
  end
17
17
 
18
18
  canonical_query_strings = queries_by_original_string.values.map do |q|
@@ -23,8 +23,6 @@ module ElasticGraph
23
23
  monotonic_clock: monotonic_clock,
24
24
  logger: logger,
25
25
  slow_query_threshold_ms: config.slow_query_latency_warning_threshold_in_ms,
26
- datastore_search_router: datastore_search_router,
27
- config: config,
28
26
  registry_directory: registry_config.path_to_registry,
29
27
  allow_unregistered_clients: registry_config.allow_unregistered_clients,
30
28
  allow_any_query_for_clients: registry_config.allow_any_query_for_clients
@@ -41,17 +39,13 @@ module ElasticGraph
41
39
  schema:,
42
40
  monotonic_clock:,
43
41
  logger:,
44
- slow_query_threshold_ms:,
45
- datastore_search_router:,
46
- config:
42
+ slow_query_threshold_ms:
47
43
  )
48
44
  super(
49
45
  schema: schema,
50
46
  monotonic_clock: monotonic_clock,
51
47
  logger: logger,
52
- slow_query_threshold_ms: slow_query_threshold_ms,
53
- datastore_search_router: datastore_search_router,
54
- config: config
48
+ slow_query_threshold_ms: slow_query_threshold_ms
55
49
  )
56
50
 
57
51
  @registry = Registry.build_from_directory(
@@ -9,21 +9,22 @@
9
9
  require "elastic_graph/query_registry/variable_backward_incompatibility_detector"
10
10
  require "elastic_graph/query_registry/variable_dumper"
11
11
  require "graphql"
12
+ require "graphql/c_parser"
12
13
 
13
14
  module ElasticGraph
14
15
  module QueryRegistry
15
16
  class QueryValidator
16
17
  def initialize(schema, require_eg_latency_slo_directive:)
17
- @graphql_schema = schema.graphql_schema
18
+ @schema = schema
18
19
  @schema_element_names = schema.element_names
19
- @var_dumper = VariableDumper.new(@graphql_schema)
20
+ @var_dumper = VariableDumper.new(schema)
20
21
  @var_incompat_detector = VariableBackwardIncompatibilityDetector.new
21
22
  @require_eg_latency_slo_directive = require_eg_latency_slo_directive
22
23
  end
23
24
 
24
25
  def validate(query_string, previously_dumped_variables:, client_name:, query_name:)
25
26
  # We pass `validate: false` since we do query validation on the operation level down below.
26
- query = ::GraphQL::Query.new(@graphql_schema, query_string, validate: false)
27
+ query = @schema.new_graphql_query(query_string, validate: false)
27
28
 
28
29
  if query.document.nil?
29
30
  {nil => query.static_errors.map(&:to_h)}
@@ -90,8 +91,8 @@ module ElasticGraph
90
91
  def static_validation_errors_for(query, operation, fragments)
91
92
  # Build a document with just this operation so that we can validate it in isolation, apart from the other operations.
92
93
  document = query.document.merge(definitions: [operation] + fragments)
93
- query = ::GraphQL::Query.new(@graphql_schema, nil, document: document, validate: false)
94
- @graphql_schema.static_validator.validate(query).fetch(:errors).map(&:to_h)
94
+ query = @schema.new_graphql_query(nil, document: document, validate: false)
95
+ @schema.graphql_schema.static_validator.validate(query).fetch(:errors).map(&:to_h)
95
96
  end
96
97
  end
97
98
  end
@@ -16,7 +16,6 @@ module ElasticGraph
16
16
  # Query validator implementation used for registered clients.
17
17
  class ForRegisteredClient < ::Data.define(
18
18
  :schema,
19
- :graphql_schema,
20
19
  :allow_any_query_for_clients,
21
20
  :client_data_by_client_name,
22
21
  :client_cache_mutex,
@@ -25,7 +24,6 @@ module ElasticGraph
25
24
  def initialize(schema:, client_names:, allow_any_query_for_clients:, provide_query_strings_for_client:)
26
25
  super(
27
26
  schema: schema,
28
- graphql_schema: schema.graphql_schema,
29
27
  allow_any_query_for_clients: allow_any_query_for_clients,
30
28
  client_cache_mutex: ::Mutex.new,
31
29
  provide_query_strings_for_client: provide_query_strings_for_client,
@@ -107,8 +105,7 @@ module ElasticGraph
107
105
  end
108
106
 
109
107
  def prepare_query_for_execution(query, variables:, operation_name:, context:)
110
- ::GraphQL::Query.new(
111
- graphql_schema,
108
+ schema.new_graphql_query(
112
109
  # Here we pass `document` instead of query string, so that we don't have to re-parse the query.
113
110
  # However, when the document is nil, we still need to pass the query string.
114
111
  query.document ? nil : query.query_string,
@@ -57,7 +57,7 @@ module ElasticGraph
57
57
  require "elastic_graph/query_registry/variable_dumper"
58
58
  require "yaml"
59
59
 
60
- variable_dumper = VariableDumper.new(graphql.schema.graphql_schema)
60
+ variable_dumper = VariableDumper.new(graphql.schema)
61
61
 
62
62
  @registered_queries_by_client_dir.glob(query_glob) do |file|
63
63
  dumped_variables = variable_dumper.dump_variables_for_query(file.read)
@@ -68,8 +68,7 @@ module ElasticGraph
68
68
  end
69
69
 
70
70
  validator.build_and_validate_query(query_string, client: client, variables: variables, operation_name: operation_name, context: context) do
71
- ::GraphQL::Query.new(
72
- @graphql_schema,
71
+ @schema.new_graphql_query(
73
72
  query_string,
74
73
  variables: variables,
75
74
  operation_name: operation_name,
@@ -81,7 +80,7 @@ module ElasticGraph
81
80
  private
82
81
 
83
82
  def initialize(schema, client_names:, allow_unregistered_clients:, allow_any_query_for_clients:, &provide_query_strings_for_client)
84
- @graphql_schema = schema.graphql_schema
83
+ @schema = schema
85
84
  allow_any_query_for_clients_set = allow_any_query_for_clients.to_set
86
85
 
87
86
  @registered_client_validator = QueryValidators::ForRegisteredClient.new(
@@ -24,14 +24,15 @@ module ElasticGraph
24
24
  # When the structure of variables changes, we can then tell the engineer that they need to verify
25
25
  # that it won't break the client.
26
26
  class VariableDumper
27
- def initialize(graphql_schema)
28
- @graphql_schema = graphql_schema
27
+ def initialize(schema)
28
+ @schema = schema
29
+ @graphql_schema = schema.graphql_schema
29
30
  end
30
31
 
31
32
  # Returns a hash of operations from the given query string. For each operation, the value
32
33
  # is a hash of variables.
33
34
  def dump_variables_for_query(query_string)
34
- query = ::GraphQL::Query.new(@graphql_schema, query_string, validate: false)
35
+ query = @schema.new_graphql_query(query_string, validate: false)
35
36
 
36
37
  if query.document.nil?
37
38
  # If the query was unparsable, we don't know anything about the variables and must just return an empty hash.
@@ -56,7 +57,7 @@ module ElasticGraph
56
57
  def variables_for_op(operation)
57
58
  operation.variables.sort_by(&:name).to_h do |variable|
58
59
  type_info =
59
- if (type = @graphql_schema.type_from_ast(variable.type))
60
+ if (type = @graphql_schema.type_from_ast(variable.type, context: @schema.graphql_query_context))
60
61
  type_info(type)
61
62
  else
62
63
  # We should only get here if a variable references a type that is undefined. Since we
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: 0.19.2.0
4
+ version: 0.19.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
@@ -9,7 +9,7 @@ authors:
9
9
  - Block Engineering
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-04-09 00:00:00.000000000 Z
12
+ date: 2025-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: elasticgraph-graphql
@@ -17,42 +17,62 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 0.19.2.0
20
+ version: 0.19.2.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: 0.19.2.0
27
+ version: 0.19.2.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: 0.19.2.0
34
+ version: 0.19.2.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: 0.19.2.0
41
+ version: 0.19.2.1
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: graphql
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 2.5.1
48
+ version: 2.5.4
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: 2.5.1
55
+ version: 2.5.4
56
+ - !ruby/object:Gem::Dependency
57
+ name: graphql-c_parser
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.1'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 1.1.2
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.1'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.1.2
56
76
  - !ruby/object:Gem::Dependency
57
77
  name: rake
58
78
  requirement: !ruby/object:Gem::Requirement
@@ -79,28 +99,28 @@ dependencies:
79
99
  requirements:
80
100
  - - '='
81
101
  - !ruby/object:Gem::Version
82
- version: 0.19.2.0
102
+ version: 0.19.2.1
83
103
  type: :development
84
104
  prerelease: false
85
105
  version_requirements: !ruby/object:Gem::Requirement
86
106
  requirements:
87
107
  - - '='
88
108
  - !ruby/object:Gem::Version
89
- version: 0.19.2.0
109
+ version: 0.19.2.1
90
110
  - !ruby/object:Gem::Dependency
91
111
  name: elasticgraph-opensearch
92
112
  requirement: !ruby/object:Gem::Requirement
93
113
  requirements:
94
114
  - - '='
95
115
  - !ruby/object:Gem::Version
96
- version: 0.19.2.0
116
+ version: 0.19.2.1
97
117
  type: :development
98
118
  prerelease: false
99
119
  version_requirements: !ruby/object:Gem::Requirement
100
120
  requirements:
101
121
  - - '='
102
122
  - !ruby/object:Gem::Version
103
- version: 0.19.2.0
123
+ version: 0.19.2.1
104
124
  email:
105
125
  - myron@squareup.com
106
126
  executables: []
@@ -123,10 +143,10 @@ licenses:
123
143
  - MIT
124
144
  metadata:
125
145
  bug_tracker_uri: https://github.com/block/elasticgraph/issues
126
- changelog_uri: https://github.com/block/elasticgraph/releases/tag/v0.19.2.0
127
- documentation_uri: https://block.github.io/elasticgraph/api-docs/v0.19.2.0/
146
+ changelog_uri: https://github.com/block/elasticgraph/releases/tag/v0.19.2.1
147
+ documentation_uri: https://block.github.io/elasticgraph/api-docs/v0.19.2.1/
128
148
  homepage_uri: https://block.github.io/elasticgraph/
129
- source_code_uri: https://github.com/block/elasticgraph/tree/v0.19.2.0/elasticgraph-query_registry
149
+ source_code_uri: https://github.com/block/elasticgraph/tree/v0.19.2.1/elasticgraph-query_registry
130
150
  gem_category: extension
131
151
  rdoc_options: []
132
152
  require_paths: