graphql 2.2.8 → 2.2.9
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.
Potentially problematic release.
This version of graphql might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/graphql/schema/field.rb +31 -30
- data/lib/graphql/schema/resolver.rb +9 -5
- data/lib/graphql/subscriptions/serialize.rb +2 -0
- data/lib/graphql/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a6fd973959b00f0c33ea17df3e1a5b8a11f51b426c987ea9f202e925c721e14
|
4
|
+
data.tar.gz: 89191c20a40c0084375f2f711d12989e349982c5f27a27390889dc291f016e4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e862a85cf5f43693401461886d4f984703a6b221dc56c175f42a82fa81f0d9c77b7793247edab69eb85a2aa9930b7ba45ec3412a6642e263dc0e03ea5f58fe7
|
7
|
+
data.tar.gz: 81d6a4de1214ed84ac55cf37ce76825de67e62a0728a950f5c20dbf3faa8e61420099dcfcc1841ea09f69f94b8a1c36e60a90799a33df64e2dd676a13b4cd1dd
|
data/lib/graphql/schema/field.rb
CHANGED
@@ -483,41 +483,24 @@ module GraphQL
|
|
483
483
|
metadata_complexity = 0
|
484
484
|
lookahead = GraphQL::Execution::Lookahead.new(query: query, field: self, ast_nodes: nodes, owner_type: owner)
|
485
485
|
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
486
|
+
lookahead.selections.each do |next_lookahead|
|
487
|
+
# this includes `pageInfo`, `nodes` and `edges` and any custom fields
|
488
|
+
# TODO this doesn't support procs yet -- unlikely to need it.
|
489
|
+
metadata_complexity += next_lookahead.field.complexity
|
490
|
+
if next_lookahead.name != :nodes && next_lookahead.name != :edges
|
491
|
+
# subfields, eg, for pageInfo -- assumes no subselections
|
492
|
+
metadata_complexity += next_lookahead.selections.size
|
493
|
+
end
|
493
494
|
end
|
494
495
|
|
495
|
-
nodes_edges_complexity = 0
|
496
|
-
nodes_edges_complexity += 1 if lookahead.selects?(:edges)
|
497
|
-
nodes_edges_complexity += 1 if lookahead.selects?(:nodes)
|
498
|
-
|
499
496
|
# Possible bug: selections on `edges` and `nodes` are _both_ multiplied here. Should they be?
|
500
|
-
items_complexity = child_complexity - metadata_complexity
|
501
|
-
|
502
|
-
|
497
|
+
items_complexity = child_complexity - metadata_complexity
|
498
|
+
subfields_complexity = (max_possible_page_size * items_complexity) + metadata_complexity
|
499
|
+
# Apply this field's own complexity
|
500
|
+
apply_own_complexity_to(subfields_complexity, query, nodes)
|
503
501
|
end
|
504
502
|
else
|
505
|
-
|
506
|
-
case defined_complexity
|
507
|
-
when Proc
|
508
|
-
arguments = query.arguments_for(nodes.first, self)
|
509
|
-
if arguments.is_a?(GraphQL::ExecutionError)
|
510
|
-
return child_complexity
|
511
|
-
elsif arguments.respond_to?(:keyword_arguments)
|
512
|
-
arguments = arguments.keyword_arguments
|
513
|
-
end
|
514
|
-
|
515
|
-
defined_complexity.call(query.context, arguments, child_complexity)
|
516
|
-
when Numeric
|
517
|
-
defined_complexity + child_complexity
|
518
|
-
else
|
519
|
-
raise("Invalid complexity: #{defined_complexity.inspect} on #{path} (#{inspect})")
|
520
|
-
end
|
503
|
+
apply_own_complexity_to(child_complexity, query, nodes)
|
521
504
|
end
|
522
505
|
end
|
523
506
|
|
@@ -882,6 +865,24 @@ ERR
|
|
882
865
|
yield(obj, args)
|
883
866
|
end
|
884
867
|
end
|
868
|
+
|
869
|
+
def apply_own_complexity_to(child_complexity, query, nodes)
|
870
|
+
case (own_complexity = complexity)
|
871
|
+
when Numeric
|
872
|
+
own_complexity + child_complexity
|
873
|
+
when Proc
|
874
|
+
arguments = query.arguments_for(nodes.first, self)
|
875
|
+
if arguments.is_a?(GraphQL::ExecutionError)
|
876
|
+
return child_complexity
|
877
|
+
elsif arguments.respond_to?(:keyword_arguments)
|
878
|
+
arguments = arguments.keyword_arguments
|
879
|
+
end
|
880
|
+
|
881
|
+
own_complexity.call(query.context, arguments, child_complexity)
|
882
|
+
else
|
883
|
+
raise ArgumentError, "Invalid complexity for #{self.path}: #{own_complexity.inspect}"
|
884
|
+
end
|
885
|
+
end
|
885
886
|
end
|
886
887
|
end
|
887
888
|
end
|
@@ -166,11 +166,15 @@ module GraphQL
|
|
166
166
|
args.each_value do |argument|
|
167
167
|
arg_keyword = argument.keyword
|
168
168
|
if inputs.key?(arg_keyword) && !(arg_value = inputs[arg_keyword]).nil? && (arg_value != argument.default_value)
|
169
|
-
|
170
|
-
if
|
171
|
-
return
|
172
|
-
|
173
|
-
|
169
|
+
auth_result = argument.authorized?(self, arg_value, context)
|
170
|
+
if auth_result.is_a?(Array)
|
171
|
+
# only return this second value if the application returned a second value
|
172
|
+
arg_auth, err = auth_result
|
173
|
+
if !arg_auth
|
174
|
+
return arg_auth, err
|
175
|
+
end
|
176
|
+
elsif auth_result == false
|
177
|
+
return auth_result
|
174
178
|
end
|
175
179
|
else
|
176
180
|
true
|
@@ -148,6 +148,8 @@ module GraphQL
|
|
148
148
|
{ TIMESTAMP_KEY => [obj.class.name, obj.strftime(TIMESTAMP_FORMAT)] }
|
149
149
|
elsif obj.is_a?(OpenStruct)
|
150
150
|
{ OPEN_STRUCT_KEY => dump_value(obj.to_h) }
|
151
|
+
elsif defined?(ActiveRecord::Relation) && obj.is_a?(ActiveRecord::Relation)
|
152
|
+
dump_value(obj.to_a)
|
151
153
|
else
|
152
154
|
obj
|
153
155
|
end
|
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: 2.2.
|
4
|
+
version: 2.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -601,6 +601,7 @@ metadata:
|
|
601
601
|
source_code_uri: https://github.com/rmosolgo/graphql-ruby
|
602
602
|
bug_tracker_uri: https://github.com/rmosolgo/graphql-ruby/issues
|
603
603
|
mailing_list_uri: https://buttondown.email/graphql-ruby
|
604
|
+
rubygems_mfa_required: 'true'
|
604
605
|
post_install_message:
|
605
606
|
rdoc_options: []
|
606
607
|
require_paths:
|