elasticgraph-query_registry 0.19.1.1 → 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: ea253843c96ee654d080a4744fbbb3fb0eb807377a16c699f79f1a3ba6438fbf
4
- data.tar.gz: 39e42aaf009a6cbd8e69e62e4abc759e149d1ffc9f3ee99012a66731bbc334dd
3
+ metadata.gz: d62adb1979caa109bdd915d9dff034c3f79983a5d956afd9de8026300592f217
4
+ data.tar.gz: 3a2d0176810a12d6b2fa315330a4af2589b609efe3bf02f80531df04a40cff1a
5
5
  SHA512:
6
- metadata.gz: fa73799303ca3f14b2c75065d17c5ead0650f9450d83045deeaae22130bd5bc55f304ae3f604582ec30054dae3f6b75831bebbb0fd526c400770998236671c3b
7
- data.tar.gz: e5ad2848519e28ff8f48df253677b1d6ee355c7686e735b87cdcf2cdad99e7f08ba6e3328df982293dd244a1af612af8f6c9267ed0d7a86666395e4c592a92e3
6
+ metadata.gz: 4d076ddab2b7d15b94718f394b2e0ae0cbdc29dd85a9084968249f5dd8d40b30ac6e72860310561ee88d585f0a3eba99c4ff4239cf286d1f4c7f09bc4dfa97dd
7
+ data.tar.gz: f9ee94d7f41d76532f22171e721ebc23dd4383aeee5f102b9be9b232ca28de5fcb69ce8c624439850534b71d926a86fd901174fcef86d029fb35f5bd350793c4
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2024 Block, Inc.
3
+ Copyright (c) 2024 - 2025 Block, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -87,7 +87,7 @@ Next, configure this library in your ElasticGraph config YAML files:
87
87
  graphql:
88
88
  extension_modules:
89
89
  - require_path: elastic_graph/query_registry/graphql_extension
90
- extension_name: ElasticGraph::QueryRegistry::GraphQLExtension
90
+ name: ElasticGraph::QueryRegistry::GraphQLExtension
91
91
  query_registry:
92
92
  allow_unregistered_clients: false
93
93
  allow_any_query_for_clients:
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Block, Inc.
1
+ # Copyright 2024 - 2025 Block, Inc.
2
2
  #
3
3
  # Use of this source code is governed by an MIT-style
4
4
  # license that can be found in the LICENSE file or at
@@ -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|
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Block, Inc.
1
+ # Copyright 2024 - 2025 Block, Inc.
2
2
  #
3
3
  # Use of this source code is governed by an MIT-style
4
4
  # license that can be found in the LICENSE file or at
@@ -23,7 +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
26
  registry_directory: registry_config.path_to_registry,
28
27
  allow_unregistered_clients: registry_config.allow_unregistered_clients,
29
28
  allow_any_query_for_clients: registry_config.allow_any_query_for_clients
@@ -40,15 +39,13 @@ module ElasticGraph
40
39
  schema:,
41
40
  monotonic_clock:,
42
41
  logger:,
43
- slow_query_threshold_ms:,
44
- datastore_search_router:
42
+ slow_query_threshold_ms:
45
43
  )
46
44
  super(
47
45
  schema: schema,
48
46
  monotonic_clock: monotonic_clock,
49
47
  logger: logger,
50
- slow_query_threshold_ms: slow_query_threshold_ms,
51
- datastore_search_router: datastore_search_router
48
+ slow_query_threshold_ms: slow_query_threshold_ms
52
49
  )
53
50
 
54
51
  @registry = Registry.build_from_directory(
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Block, Inc.
1
+ # Copyright 2024 - 2025 Block, Inc.
2
2
  #
3
3
  # Use of this source code is governed by an MIT-style
4
4
  # license that can be found in the LICENSE file or at
@@ -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
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Block, Inc.
1
+ # Copyright 2024 - 2025 Block, Inc.
2
2
  #
3
3
  # Use of this source code is governed by an MIT-style
4
4
  # license that can be found in the LICENSE file or at
@@ -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,
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Block, Inc.
1
+ # Copyright 2024 - 2025 Block, Inc.
2
2
  #
3
3
  # Use of this source code is governed by an MIT-style
4
4
  # license that can be found in the LICENSE file or at
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Block, Inc.
1
+ # Copyright 2024 - 2025 Block, Inc.
2
2
  #
3
3
  # Use of this source code is governed by an MIT-style
4
4
  # license that can be found in the LICENSE file or at
@@ -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)
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Block, Inc.
1
+ # Copyright 2024 - 2025 Block, Inc.
2
2
  #
3
3
  # Use of this source code is governed by an MIT-style
4
4
  # license that can be found in the LICENSE file or at
@@ -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(
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Block, Inc.
1
+ # Copyright 2024 - 2025 Block, Inc.
2
2
  #
3
3
  # Use of this source code is governed by an MIT-style
4
4
  # license that can be found in the LICENSE file or at
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Block, Inc.
1
+ # Copyright 2024 - 2025 Block, Inc.
2
2
  #
3
3
  # Use of this source code is governed by an MIT-style
4
4
  # license that can be found in the LICENSE file or at
@@ -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,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticgraph-query_registry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.1.1
4
+ version: 0.19.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
8
8
  - Ben VandenBos
9
9
  - Block Engineering
10
- autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2025-02-07 00:00:00.000000000 Z
12
+ date: 2025-04-24 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: elasticgraph-graphql
@@ -18,42 +17,62 @@ dependencies:
18
17
  requirements:
19
18
  - - '='
20
19
  - !ruby/object:Gem::Version
21
- version: 0.19.1.1
20
+ version: 0.19.2.1
22
21
  type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
24
  requirements:
26
25
  - - '='
27
26
  - !ruby/object:Gem::Version
28
- version: 0.19.1.1
27
+ version: 0.19.2.1
29
28
  - !ruby/object:Gem::Dependency
30
29
  name: elasticgraph-support
31
30
  requirement: !ruby/object:Gem::Requirement
32
31
  requirements:
33
32
  - - '='
34
33
  - !ruby/object:Gem::Version
35
- version: 0.19.1.1
34
+ version: 0.19.2.1
36
35
  type: :runtime
37
36
  prerelease: false
38
37
  version_requirements: !ruby/object:Gem::Requirement
39
38
  requirements:
40
39
  - - '='
41
40
  - !ruby/object:Gem::Version
42
- version: 0.19.1.1
41
+ version: 0.19.2.1
43
42
  - !ruby/object:Gem::Dependency
44
43
  name: graphql
45
44
  requirement: !ruby/object:Gem::Requirement
46
45
  requirements:
47
46
  - - "~>"
48
47
  - !ruby/object:Gem::Version
49
- version: 2.4.8
48
+ version: 2.5.4
50
49
  type: :runtime
51
50
  prerelease: false
52
51
  version_requirements: !ruby/object:Gem::Requirement
53
52
  requirements:
54
53
  - - "~>"
55
54
  - !ruby/object:Gem::Version
56
- version: 2.4.8
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
57
76
  - !ruby/object:Gem::Dependency
58
77
  name: rake
59
78
  requirement: !ruby/object:Gem::Requirement
@@ -61,6 +80,9 @@ dependencies:
61
80
  - - "~>"
62
81
  - !ruby/object:Gem::Version
63
82
  version: '13.2'
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 13.2.1
64
86
  type: :runtime
65
87
  prerelease: false
66
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -68,35 +90,37 @@ dependencies:
68
90
  - - "~>"
69
91
  - !ruby/object:Gem::Version
70
92
  version: '13.2'
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 13.2.1
71
96
  - !ruby/object:Gem::Dependency
72
97
  name: elasticgraph-elasticsearch
73
98
  requirement: !ruby/object:Gem::Requirement
74
99
  requirements:
75
100
  - - '='
76
101
  - !ruby/object:Gem::Version
77
- version: 0.19.1.1
102
+ version: 0.19.2.1
78
103
  type: :development
79
104
  prerelease: false
80
105
  version_requirements: !ruby/object:Gem::Requirement
81
106
  requirements:
82
107
  - - '='
83
108
  - !ruby/object:Gem::Version
84
- version: 0.19.1.1
109
+ version: 0.19.2.1
85
110
  - !ruby/object:Gem::Dependency
86
111
  name: elasticgraph-opensearch
87
112
  requirement: !ruby/object:Gem::Requirement
88
113
  requirements:
89
114
  - - '='
90
115
  - !ruby/object:Gem::Version
91
- version: 0.19.1.1
116
+ version: 0.19.2.1
92
117
  type: :development
93
118
  prerelease: false
94
119
  version_requirements: !ruby/object:Gem::Requirement
95
120
  requirements:
96
121
  - - '='
97
122
  - !ruby/object:Gem::Version
98
- version: 0.19.1.1
99
- description:
123
+ version: 0.19.2.1
100
124
  email:
101
125
  - myron@squareup.com
102
126
  executables: []
@@ -119,12 +143,11 @@ licenses:
119
143
  - MIT
120
144
  metadata:
121
145
  bug_tracker_uri: https://github.com/block/elasticgraph/issues
122
- changelog_uri: https://github.com/block/elasticgraph/releases/tag/v0.19.1.1
123
- documentation_uri: https://block.github.io/elasticgraph/docs/main/
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/
124
148
  homepage_uri: https://block.github.io/elasticgraph/
125
- source_code_uri: https://github.com/block/elasticgraph/tree/v0.19.1.1/elasticgraph-query_registry
149
+ source_code_uri: https://github.com/block/elasticgraph/tree/v0.19.2.1/elasticgraph-query_registry
126
150
  gem_category: extension
127
- post_install_message:
128
151
  rdoc_options: []
129
152
  require_paths:
130
153
  - lib
@@ -142,8 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
165
  - !ruby/object:Gem::Version
143
166
  version: '0'
144
167
  requirements: []
145
- rubygems_version: 3.5.22
146
- signing_key:
168
+ rubygems_version: 3.6.2
147
169
  specification_version: 4
148
170
  summary: An ElasticGraph extension that supports safer schema evolution by limiting
149
171
  GraphQL queries based on a registry and validating registered queries against the