graphql 1.11.10 → 1.11.11
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 +4 -4
- data/lib/graphql/language/nodes.rb +5 -0
- data/lib/graphql/language/visitor.rb +1 -0
- data/lib/graphql/query/validation_pipeline.rb +1 -1
- data/lib/graphql/schema/argument.rb +3 -5
- data/lib/graphql/schema/build_from_definition.rb +8 -7
- data/lib/graphql/schema/enum_value.rb +1 -1
- data/lib/graphql/schema/field.rb +1 -0
- data/lib/graphql/schema/input_object.rb +9 -6
- data/lib/graphql/schema.rb +11 -26
- data/lib/graphql/static_validation/base_visitor.rb +0 -3
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +4 -4
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +2 -2
- data/lib/graphql/static_validation/validation_context.rb +1 -6
- data/lib/graphql/static_validation/validator.rb +10 -14
- data/lib/graphql/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d5cb52d52c7bff9e3ec317756e7f2d171fac202208ca3bfe4bce711b4f3216b
|
4
|
+
data.tar.gz: 0d087f84cd41caaea9e8953b78b4bef69349209a8e62321bb604cc68f5a3765d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68ae0b7fec852524c7527b3222a06c217dd03723120204baed3a6bc67b87e5e629010b2b393c9e4c2c0747e10655f17d1cc06196ac6864bf899569039d9d3b21
|
7
|
+
data.tar.gz: 56ed8bd3fb0b5e3c27cee6180a91b9b8ece3364a7682a90e2a4e4604663e2744d30d46ac85988394b00f41c2341b4c761c09c83d21925e08e1223a91fdba333f
|
@@ -133,6 +133,8 @@ module GraphQL
|
|
133
133
|
end
|
134
134
|
|
135
135
|
class << self
|
136
|
+
# rubocop:disable Development/NoEvalCop This eval takes static inputs at load-time
|
137
|
+
|
136
138
|
# Add a default `#visit_method` and `#children_method_name` using the class name
|
137
139
|
def inherited(child_class)
|
138
140
|
super
|
@@ -265,8 +267,11 @@ module GraphQL
|
|
265
267
|
#{assignments.join("\n")}
|
266
268
|
end
|
267
269
|
RUBY
|
270
|
+
|
271
|
+
# rubocop:enable Development/NoEvalCop
|
268
272
|
end
|
269
273
|
end
|
274
|
+
# rubocop:enable Development/NoEvalCop
|
270
275
|
end
|
271
276
|
end
|
272
277
|
|
@@ -72,7 +72,7 @@ module GraphQL
|
|
72
72
|
elsif @operation_name_error
|
73
73
|
@validation_errors << @operation_name_error
|
74
74
|
else
|
75
|
-
validation_result = @schema.static_validator.validate(@query, validate: @validate, timeout: @schema.validate_timeout
|
75
|
+
validation_result = @schema.static_validator.validate(@query, validate: @validate, timeout: @schema.validate_timeout)
|
76
76
|
@validation_errors.concat(validation_result[:errors])
|
77
77
|
@internal_representation = validation_result[:irep]
|
78
78
|
|
@@ -49,6 +49,7 @@ module GraphQL
|
|
49
49
|
def initialize(arg_name = nil, type_expr = nil, desc = nil, required:, type: nil, name: nil, loads: nil, description: nil, ast_node: nil, default_value: NO_DEFAULT, as: nil, from_resolver: false, camelize: true, prepare: nil, method_access: true, owner:, deprecation_reason: nil, &definition_block)
|
50
50
|
arg_name ||= name
|
51
51
|
@name = -(camelize ? Member::BuildType.camelize(arg_name.to_s) : arg_name.to_s)
|
52
|
+
NameValidator.validate!(@name)
|
52
53
|
@type_expr = type_expr || type
|
53
54
|
@description = desc || description
|
54
55
|
@null = !required
|
@@ -64,11 +65,8 @@ module GraphQL
|
|
64
65
|
self.deprecation_reason = deprecation_reason
|
65
66
|
|
66
67
|
if definition_block
|
67
|
-
|
68
|
-
|
69
|
-
else
|
70
|
-
instance_eval(&definition_block)
|
71
|
-
end
|
68
|
+
# `self` will still be self, it will also be the first argument to the block:
|
69
|
+
instance_exec(self, &definition_block)
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
@@ -342,13 +342,7 @@ module GraphQL
|
|
342
342
|
|
343
343
|
# Don't do this for interfaces
|
344
344
|
if default_resolve
|
345
|
-
owner
|
346
|
-
# frozen_string_literal: true
|
347
|
-
def #{resolve_method_name}(**args)
|
348
|
-
field_instance = self.class.get_field("#{field_definition.name}")
|
349
|
-
context.schema.definition_default_resolve.call(self.class, field_instance, object, args, context)
|
350
|
-
end
|
351
|
-
RUBY
|
345
|
+
define_field_resolve_method(owner, resolve_method_name, field_definition.name)
|
352
346
|
end
|
353
347
|
end
|
354
348
|
end
|
@@ -367,6 +361,13 @@ module GraphQL
|
|
367
361
|
end
|
368
362
|
end
|
369
363
|
|
364
|
+
def define_field_resolve_method(owner, method_name, field_name)
|
365
|
+
owner.define_method(method_name) { |**args|
|
366
|
+
field_instance = self.class.get_field(field_name)
|
367
|
+
context.schema.definition_default_resolve.call(self.class, field_instance, object, args, context)
|
368
|
+
}
|
369
|
+
end
|
370
|
+
|
370
371
|
def resolve_type_name(type)
|
371
372
|
case type
|
372
373
|
when GraphQL::Language::Nodes::TypeName
|
data/lib/graphql/schema/field.rb
CHANGED
@@ -222,6 +222,7 @@ module GraphQL
|
|
222
222
|
name_s = -name.to_s
|
223
223
|
@underscored_name = -Member::BuildType.underscore(name_s)
|
224
224
|
@name = -(camelize ? Member::BuildType.camelize(name_s) : name_s)
|
225
|
+
NameValidator.validate!(@name)
|
225
226
|
@description = description
|
226
227
|
if field.is_a?(GraphQL::Schema::Field)
|
227
228
|
raise ArgumentError, "Instead of passing a field as `field:`, use `add_field(field)` to add an already-defined field."
|
@@ -125,12 +125,8 @@ module GraphQL
|
|
125
125
|
def argument(*args, **kwargs, &block)
|
126
126
|
argument_defn = super(*args, **kwargs, &block)
|
127
127
|
# Add a method access
|
128
|
-
|
129
|
-
|
130
|
-
def #{method_name}
|
131
|
-
self[#{method_name.inspect}]
|
132
|
-
end
|
133
|
-
RUBY
|
128
|
+
define_accessor_method(argument_defn.keyword)
|
129
|
+
argument_defn
|
134
130
|
end
|
135
131
|
|
136
132
|
def to_graphql
|
@@ -239,6 +235,13 @@ module GraphQL
|
|
239
235
|
|
240
236
|
result
|
241
237
|
end
|
238
|
+
|
239
|
+
private
|
240
|
+
|
241
|
+
def define_accessor_method(method_name)
|
242
|
+
define_method(method_name) { self[method_name] }
|
243
|
+
alias_method(method_name, method_name)
|
244
|
+
end
|
242
245
|
end
|
243
246
|
end
|
244
247
|
end
|
data/lib/graphql/schema.rb
CHANGED
@@ -157,7 +157,7 @@ module GraphQL
|
|
157
157
|
|
158
158
|
accepts_definitions \
|
159
159
|
:query_execution_strategy, :mutation_execution_strategy, :subscription_execution_strategy,
|
160
|
-
:validate_timeout, :
|
160
|
+
:validate_timeout, :max_depth, :max_complexity, :default_max_page_size,
|
161
161
|
:orphan_types, :resolve_type, :type_error, :parse_error,
|
162
162
|
:error_bubbling,
|
163
163
|
:raise_definition_error,
|
@@ -196,7 +196,7 @@ module GraphQL
|
|
196
196
|
attr_accessor \
|
197
197
|
:query, :mutation, :subscription,
|
198
198
|
:query_execution_strategy, :mutation_execution_strategy, :subscription_execution_strategy,
|
199
|
-
:validate_timeout, :
|
199
|
+
:validate_timeout, :max_depth, :max_complexity, :default_max_page_size,
|
200
200
|
:orphan_types, :directives,
|
201
201
|
:query_analyzers, :multiplex_analyzers, :instrumenters, :lazy_methods,
|
202
202
|
:cursor_encoder,
|
@@ -366,7 +366,7 @@ module GraphQL
|
|
366
366
|
validator_opts = { schema: self }
|
367
367
|
rules && (validator_opts[:rules] = rules)
|
368
368
|
validator = GraphQL::StaticValidation::Validator.new(**validator_opts)
|
369
|
-
res = validator.validate(query, timeout: validate_timeout
|
369
|
+
res = validator.validate(query, timeout: validate_timeout)
|
370
370
|
res[:errors]
|
371
371
|
end
|
372
372
|
|
@@ -951,7 +951,6 @@ module GraphQL
|
|
951
951
|
schema_defn.mutation = mutation && mutation.graphql_definition
|
952
952
|
schema_defn.subscription = subscription && subscription.graphql_definition
|
953
953
|
schema_defn.validate_timeout = validate_timeout
|
954
|
-
schema_defn.validate_max_errors = validate_max_errors
|
955
954
|
schema_defn.max_complexity = max_complexity
|
956
955
|
schema_defn.error_bubbling = error_bubbling
|
957
956
|
schema_defn.max_depth = max_depth
|
@@ -1120,15 +1119,14 @@ module GraphQL
|
|
1120
1119
|
type.possible_types(context: context)
|
1121
1120
|
else
|
1122
1121
|
stored_possible_types = own_possible_types[type.graphql_name]
|
1123
|
-
visible_possible_types =
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
end
|
1122
|
+
visible_possible_types = stored_possible_types.select do |possible_type|
|
1123
|
+
next true unless type.kind.interface?
|
1124
|
+
next true unless possible_type.kind.object?
|
1125
|
+
|
1126
|
+
# Use `.graphql_name` comparison to match legacy vs class-based types.
|
1127
|
+
# When we don't need to support legacy `.define` types, use `.include?(type)` instead.
|
1128
|
+
possible_type.interfaces(context).any? { |interface| interface.graphql_name == type.graphql_name }
|
1129
|
+
end if stored_possible_types
|
1132
1130
|
visible_possible_types ||
|
1133
1131
|
introspection_system.possible_types[type.graphql_name] ||
|
1134
1132
|
(
|
@@ -1287,19 +1285,6 @@ module GraphQL
|
|
1287
1285
|
end
|
1288
1286
|
end
|
1289
1287
|
|
1290
|
-
attr_writer :validate_max_errors
|
1291
|
-
|
1292
|
-
def validate_max_errors(new_validate_max_errors = nil)
|
1293
|
-
if new_validate_max_errors
|
1294
|
-
@validate_max_errors = new_validate_max_errors
|
1295
|
-
elsif defined?(@validate_max_errors)
|
1296
|
-
@validate_max_errors
|
1297
|
-
else
|
1298
|
-
find_inherited_value(:validate_max_errors)
|
1299
|
-
end
|
1300
|
-
end
|
1301
|
-
|
1302
|
-
|
1303
1288
|
attr_writer :max_complexity
|
1304
1289
|
|
1305
1290
|
def max_complexity(max_complexity = nil)
|
@@ -193,26 +193,26 @@ module GraphQL
|
|
193
193
|
if node1.name != node2.name
|
194
194
|
errored_nodes = [node1.name, node2.name].sort.join(" or ")
|
195
195
|
msg = "Field '#{response_key}' has a field conflict: #{errored_nodes}?"
|
196
|
-
|
196
|
+
context.errors << GraphQL::StaticValidation::FieldsWillMergeError.new(
|
197
197
|
msg,
|
198
198
|
nodes: [node1, node2],
|
199
199
|
path: [],
|
200
200
|
field_name: response_key,
|
201
201
|
conflicts: errored_nodes
|
202
|
-
)
|
202
|
+
)
|
203
203
|
end
|
204
204
|
|
205
205
|
if !same_arguments?(node1, node2)
|
206
206
|
args = [serialize_field_args(node1), serialize_field_args(node2)]
|
207
207
|
conflicts = args.map { |arg| GraphQL::Language.serialize(arg) }.join(" or ")
|
208
208
|
msg = "Field '#{response_key}' has an argument conflict: #{conflicts}?"
|
209
|
-
|
209
|
+
context.errors << GraphQL::StaticValidation::FieldsWillMergeError.new(
|
210
210
|
msg,
|
211
211
|
nodes: [node1, node2],
|
212
212
|
path: [],
|
213
213
|
field_name: response_key,
|
214
214
|
conflicts: conflicts
|
215
|
-
)
|
215
|
+
)
|
216
216
|
end
|
217
217
|
end
|
218
218
|
|
@@ -7,12 +7,12 @@ module GraphQL
|
|
7
7
|
dependency_map = context.dependencies
|
8
8
|
dependency_map.cyclical_definitions.each do |defn|
|
9
9
|
if defn.node.is_a?(GraphQL::Language::Nodes::FragmentDefinition)
|
10
|
-
|
10
|
+
context.errors << GraphQL::StaticValidation::FragmentsAreFiniteError.new(
|
11
11
|
"Fragment #{defn.name} contains an infinite loop",
|
12
12
|
nodes: defn.node,
|
13
13
|
path: defn.path,
|
14
14
|
name: defn.name
|
15
|
-
)
|
15
|
+
)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -19,11 +19,10 @@ module GraphQL
|
|
19
19
|
|
20
20
|
def_delegators :@query, :schema, :document, :fragments, :operations, :warden
|
21
21
|
|
22
|
-
def initialize(query, visitor_class
|
22
|
+
def initialize(query, visitor_class)
|
23
23
|
@query = query
|
24
24
|
@literal_validator = LiteralValidator.new(context: query.context)
|
25
25
|
@errors = []
|
26
|
-
@max_errors = max_errors || Float::INFINITY
|
27
26
|
@on_dependency_resolve_handlers = []
|
28
27
|
@visitor = visitor_class.new(document, self)
|
29
28
|
end
|
@@ -39,10 +38,6 @@ module GraphQL
|
|
39
38
|
def validate_literal(ast_value, type)
|
40
39
|
@literal_validator.validate(ast_value, type)
|
41
40
|
end
|
42
|
-
|
43
|
-
def too_many_errors?
|
44
|
-
@errors.length >= @max_errors
|
45
|
-
end
|
46
41
|
end
|
47
42
|
end
|
48
43
|
end
|
@@ -22,9 +22,8 @@ module GraphQL
|
|
22
22
|
# @param query [GraphQL::Query]
|
23
23
|
# @param validate [Boolean]
|
24
24
|
# @param timeout [Float] Number of seconds to wait before aborting validation. Any positive number may be used, including Floats to specify fractional seconds.
|
25
|
-
# @param max_errors [Integer] Maximum number of errors before aborting validation. Any positive number will limit the number of errors. Defaults to nil for no limit.
|
26
25
|
# @return [Array<Hash>]
|
27
|
-
def validate(query, validate: true, timeout: nil
|
26
|
+
def validate(query, validate: true, timeout: nil)
|
28
27
|
query.trace("validate", { validate: validate, query: query }) do
|
29
28
|
can_skip_rewrite = query.context.interpreter? && query.schema.using_ast_analysis? && query.schema.is_a?(Class)
|
30
29
|
errors = if validate == false && can_skip_rewrite
|
@@ -33,26 +32,23 @@ module GraphQL
|
|
33
32
|
rules_to_use = validate ? @rules : []
|
34
33
|
visitor_class = BaseVisitor.including_rules(rules_to_use, rewrite: !can_skip_rewrite)
|
35
34
|
|
36
|
-
context = GraphQL::StaticValidation::ValidationContext.new(query, visitor_class
|
35
|
+
context = GraphQL::StaticValidation::ValidationContext.new(query, visitor_class)
|
37
36
|
|
38
37
|
begin
|
39
38
|
# CAUTION: Usage of the timeout module makes the assumption that validation rules are stateless Ruby code that requires no cleanup if process was interrupted. This means no blocking IO calls, native gems, locks, or `rescue` clauses that must be reached.
|
40
39
|
# A timeout value of 0 or nil will execute the block without any timeout.
|
41
40
|
Timeout::timeout(timeout) do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
if rule_class_or_module.method_defined?(:validate)
|
49
|
-
rule_class_or_module.new.validate(context)
|
50
|
-
end
|
41
|
+
# Attach legacy-style rules.
|
42
|
+
# Only loop through rules if it has legacy-style rules
|
43
|
+
unless (legacy_rules = rules_to_use - GraphQL::StaticValidation::ALL_RULES).empty?
|
44
|
+
legacy_rules.each do |rule_class_or_module|
|
45
|
+
if rule_class_or_module.method_defined?(:validate)
|
46
|
+
rule_class_or_module.new.validate(context)
|
51
47
|
end
|
52
48
|
end
|
53
|
-
|
54
|
-
context.visitor.visit
|
55
49
|
end
|
50
|
+
|
51
|
+
context.visitor.visit
|
56
52
|
end
|
57
53
|
rescue Timeout::Error
|
58
54
|
handle_timeout(query, context)
|
data/lib/graphql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -741,7 +741,7 @@ metadata:
|
|
741
741
|
source_code_uri: https://github.com/rmosolgo/graphql-ruby
|
742
742
|
bug_tracker_uri: https://github.com/rmosolgo/graphql-ruby/issues
|
743
743
|
mailing_list_uri: https://tinyletter.com/graphql-ruby
|
744
|
-
post_install_message:
|
744
|
+
post_install_message:
|
745
745
|
rdoc_options: []
|
746
746
|
require_paths:
|
747
747
|
- lib
|
@@ -756,8 +756,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
756
756
|
- !ruby/object:Gem::Version
|
757
757
|
version: '0'
|
758
758
|
requirements: []
|
759
|
-
rubygems_version: 3.
|
760
|
-
signing_key:
|
759
|
+
rubygems_version: 3.1.6
|
760
|
+
signing_key:
|
761
761
|
specification_version: 4
|
762
762
|
summary: A GraphQL language and runtime for Ruby
|
763
763
|
test_files: []
|