graphql 2.2.7 → 2.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/execution/interpreter.rb +3 -3
- data/lib/graphql/schema/base_64_encoder.rb +3 -5
- data/lib/graphql/schema/field.rb +31 -30
- data/lib/graphql/schema/resolver.rb +9 -5
- data/lib/graphql/schema/unique_within_type.rb +1 -1
- data/lib/graphql/subscriptions/serialize.rb +2 -0
- data/lib/graphql/testing/helpers.rb +8 -4
- data/lib/graphql/tracing/sentry_trace.rb +5 -4
- data/lib/graphql/version.rb +1 -1
- metadata +3 -3
- data/lib/graphql/schema/base_64_bp.rb +0 -26
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
|
@@ -111,15 +111,15 @@ module GraphQL
|
|
111
111
|
data_result
|
112
112
|
end
|
113
113
|
else
|
114
|
-
result = {
|
115
|
-
"data" => query.context.namespace(:interpreter_runtime)[:runtime].final_result
|
116
|
-
}
|
114
|
+
result = {}
|
117
115
|
|
118
116
|
if query.context.errors.any?
|
119
117
|
error_result = query.context.errors.map(&:to_h)
|
120
118
|
result["errors"] = error_result
|
121
119
|
end
|
122
120
|
|
121
|
+
result["data"] = query.context.namespace(:interpreter_runtime)[:runtime].final_result
|
122
|
+
|
123
123
|
result
|
124
124
|
end
|
125
125
|
if query.context.namespace?(:__query_result_extensions__)
|
@@ -1,18 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'graphql/schema/base_64_bp'
|
4
|
-
|
2
|
+
require "base64"
|
5
3
|
module GraphQL
|
6
4
|
class Schema
|
7
5
|
# @api private
|
8
6
|
module Base64Encoder
|
9
7
|
def self.encode(unencoded_text, nonce: false)
|
10
|
-
|
8
|
+
Base64.urlsafe_encode64(unencoded_text, padding: false)
|
11
9
|
end
|
12
10
|
|
13
11
|
def self.decode(encoded_text, nonce: false)
|
14
12
|
# urlsafe_decode64 is for forward compatibility
|
15
|
-
|
13
|
+
Base64.urlsafe_decode64(encoded_text)
|
16
14
|
rescue ArgumentError
|
17
15
|
raise GraphQL::ExecutionError, "Invalid input: #{encoded_text.inspect}"
|
18
16
|
end
|
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
|
@@ -5,10 +5,7 @@ module GraphQL
|
|
5
5
|
# @param schema_class [Class<GraphQL::Schema>]
|
6
6
|
# @return [Module] A helpers module which always uses the given schema
|
7
7
|
def self.for(schema_class)
|
8
|
-
|
9
|
-
include SchemaHelpers
|
10
|
-
@@schema_class_for_helpers = schema_class
|
11
|
-
end
|
8
|
+
SchemaHelpers.for(schema_class)
|
12
9
|
end
|
13
10
|
|
14
11
|
class Error < GraphQL::Error
|
@@ -119,6 +116,13 @@ module GraphQL
|
|
119
116
|
# schema will be added later
|
120
117
|
super(nil, *args, **kwargs, &block)
|
121
118
|
end
|
119
|
+
|
120
|
+
def self.for(schema_class)
|
121
|
+
Module.new do
|
122
|
+
include SchemaHelpers
|
123
|
+
@@schema_class_for_helpers = schema_class
|
124
|
+
end
|
125
|
+
end
|
122
126
|
end
|
123
127
|
end
|
124
128
|
end
|
@@ -16,8 +16,8 @@ module GraphQL
|
|
16
16
|
"execute_query_lazy" => "graphql.execute"
|
17
17
|
}.each do |trace_method, platform_key|
|
18
18
|
module_eval <<-RUBY, __FILE__, __LINE__
|
19
|
-
def #{trace_method}(**data
|
20
|
-
instrument_execution("#{platform_key}", "#{trace_method}", data
|
19
|
+
def #{trace_method}(**data)
|
20
|
+
instrument_execution("#{platform_key}", "#{trace_method}", data) { super }
|
21
21
|
end
|
22
22
|
RUBY
|
23
23
|
end
|
@@ -64,9 +64,10 @@ module GraphQL
|
|
64
64
|
return yield unless Sentry.initialized?
|
65
65
|
|
66
66
|
Sentry.with_child_span(op: platform_key, start_timestamp: Sentry.utc_now.to_f) do |span|
|
67
|
-
result =
|
68
|
-
span
|
67
|
+
result = yield
|
68
|
+
return result unless span
|
69
69
|
|
70
|
+
span.finish
|
70
71
|
if trace_method == "execute_multiplex" && data.key?(:multiplex)
|
71
72
|
operation_names = data[:multiplex].queries.map{|q| operation_name(q) }
|
72
73
|
span.set_description(operation_names.join(", "))
|
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-
|
11
|
+
date: 2024-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -386,7 +386,6 @@ files:
|
|
386
386
|
- lib/graphql/schema/addition.rb
|
387
387
|
- lib/graphql/schema/always_visible.rb
|
388
388
|
- lib/graphql/schema/argument.rb
|
389
|
-
- lib/graphql/schema/base_64_bp.rb
|
390
389
|
- lib/graphql/schema/base_64_encoder.rb
|
391
390
|
- lib/graphql/schema/build_from_definition.rb
|
392
391
|
- lib/graphql/schema/build_from_definition/resolve_map.rb
|
@@ -602,6 +601,7 @@ metadata:
|
|
602
601
|
source_code_uri: https://github.com/rmosolgo/graphql-ruby
|
603
602
|
bug_tracker_uri: https://github.com/rmosolgo/graphql-ruby/issues
|
604
603
|
mailing_list_uri: https://buttondown.email/graphql-ruby
|
604
|
+
rubygems_mfa_required: 'true'
|
605
605
|
post_install_message:
|
606
606
|
rdoc_options: []
|
607
607
|
require_paths:
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'base64'
|
4
|
-
|
5
|
-
# backport from ruby v2.5 to v2.2 that has no `padding` things
|
6
|
-
# @api private
|
7
|
-
module Base64Bp
|
8
|
-
extend Base64
|
9
|
-
|
10
|
-
module_function
|
11
|
-
|
12
|
-
def urlsafe_encode64(bin, padding:)
|
13
|
-
str = strict_encode64(bin)
|
14
|
-
str.tr!("+/", "-_")
|
15
|
-
str.delete!("=") unless padding
|
16
|
-
str
|
17
|
-
end
|
18
|
-
|
19
|
-
def urlsafe_decode64(str)
|
20
|
-
str = str.tr("-_", "+/")
|
21
|
-
if !str.end_with?("=") && str.length % 4 != 0
|
22
|
-
str = str.ljust((str.length + 3) & ~3, "=")
|
23
|
-
end
|
24
|
-
strict_decode64(str)
|
25
|
-
end
|
26
|
-
end
|