graphql 2.6.13 → 2.6.14
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/analysis/max_query_complexity.rb +1 -1
- data/lib/graphql/execution/field_resolve_step.rb +243 -157
- data/lib/graphql/execution/input_values.rb +3 -1
- data/lib/graphql/execution/prepare_object_step.rb +37 -13
- data/lib/graphql/language/lexer.rb +1 -1
- data/lib/graphql/language/parser.rb +5 -1
- data/lib/graphql/pagination/relation_connection.rb +21 -10
- data/lib/graphql/query/partial.rb +1 -2
- data/lib/graphql/schema/addition.rb +55 -48
- data/lib/graphql/schema/argument.rb +14 -3
- data/lib/graphql/schema/build_from_definition.rb +435 -173
- data/lib/graphql/schema/directive.rb +16 -0
- data/lib/graphql/schema/field/connection_extension.rb +1 -1
- data/lib/graphql/schema/field.rb +1 -1
- data/lib/graphql/schema/member/build_type.rb +5 -2
- data/lib/graphql/schema/member/has_arguments.rb +0 -4
- data/lib/graphql/schema/member/has_directives.rb +7 -1
- data/lib/graphql/schema/member/has_interfaces.rb +0 -2
- data/lib/graphql/schema/object.rb +11 -3
- data/lib/graphql/schema.rb +4 -2
- data/lib/graphql/version.rb +1 -1
- metadata +2 -2
|
@@ -114,6 +114,10 @@ module GraphQL
|
|
|
114
114
|
@repeatable = new_value
|
|
115
115
|
end
|
|
116
116
|
|
|
117
|
+
# When this is a Hash, instances with equal, statically coercible arguments reuse the first instance's coerced arguments.
|
|
118
|
+
# BuildFromDefinition uses this while it builds a schema, then removes it.
|
|
119
|
+
attr_accessor :coerced_arguments_cache # :nodoc:
|
|
120
|
+
|
|
117
121
|
private
|
|
118
122
|
|
|
119
123
|
def inherited(subclass)
|
|
@@ -124,6 +128,7 @@ module GraphQL
|
|
|
124
128
|
@locations = parent_class.locations
|
|
125
129
|
@is_runtime = parent_class.runtime?
|
|
126
130
|
@repeatable = false
|
|
131
|
+
@coerced_arguments_cache = nil
|
|
127
132
|
end
|
|
128
133
|
end
|
|
129
134
|
end
|
|
@@ -144,6 +149,14 @@ module GraphQL
|
|
|
144
149
|
def initialize(owner, **arguments)
|
|
145
150
|
@owner = owner
|
|
146
151
|
assert_valid_owner
|
|
152
|
+
if (arguments_cache = self.class.coerced_arguments_cache)
|
|
153
|
+
if !self.class.arguments_statically_coercible?
|
|
154
|
+
arguments_cache = nil
|
|
155
|
+
elsif (cached_arguments = arguments_cache[arguments])
|
|
156
|
+
@arguments = cached_arguments
|
|
157
|
+
return
|
|
158
|
+
end
|
|
159
|
+
end
|
|
147
160
|
# It's be nice if we had the real context here, but we don't. What we _would_ get is:
|
|
148
161
|
# - error handling
|
|
149
162
|
# - lazy resolution
|
|
@@ -195,6 +208,9 @@ module GraphQL
|
|
|
195
208
|
if @arguments.is_a?(GraphQL::ExecutionError)
|
|
196
209
|
raise @arguments
|
|
197
210
|
end
|
|
211
|
+
if arguments_cache
|
|
212
|
+
arguments_cache[arguments] = @arguments
|
|
213
|
+
end
|
|
198
214
|
end
|
|
199
215
|
|
|
200
216
|
def graphql_name
|
|
@@ -31,7 +31,7 @@ module GraphQL
|
|
|
31
31
|
lookahead = arguments[:lookahead]
|
|
32
32
|
context.query.after_lazy(value) do |resolved_value|
|
|
33
33
|
connection = context.schema.connections.populate_connection(field, object.object, resolved_value, original_arguments, context)
|
|
34
|
-
connection.lookahead ||= lookahead if connection
|
|
34
|
+
connection.lookahead ||= lookahead if connection.is_a?(GraphQL::Pagination::Connection)
|
|
35
35
|
connection
|
|
36
36
|
end
|
|
37
37
|
end
|
data/lib/graphql/schema/field.rb
CHANGED
|
@@ -982,7 +982,7 @@ module GraphQL
|
|
|
982
982
|
max_possible_page_size = arguments[:last]
|
|
983
983
|
end
|
|
984
984
|
elsif arguments.is_a?(GraphQL::ExecutionError) || arguments.is_a?(GraphQL::UnauthorizedError)
|
|
985
|
-
|
|
985
|
+
return child_complexity
|
|
986
986
|
end
|
|
987
987
|
|
|
988
988
|
if max_possible_page_size.nil?
|
|
@@ -185,12 +185,15 @@ module GraphQL
|
|
|
185
185
|
end
|
|
186
186
|
string2 = string.dup
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
string2.gsub!(
|
|
188
|
+
# URLDecoder -> URL_Decoder, someThing -> some_Thing
|
|
189
|
+
string2.gsub!(UNDERSCORE_BOUNDARY, "_")
|
|
190
190
|
string2.downcase!
|
|
191
191
|
|
|
192
192
|
string2
|
|
193
193
|
end
|
|
194
|
+
|
|
195
|
+
UNDERSCORE_BOUNDARY = /(?<=[A-Z])(?=[A-Z][a-z])|(?<=[a-z\d])(?=[A-Z])/
|
|
196
|
+
private_constant :UNDERSCORE_BOUNDARY
|
|
194
197
|
end
|
|
195
198
|
end
|
|
196
199
|
end
|
|
@@ -150,8 +150,6 @@ module GraphQL
|
|
|
150
150
|
child_class.extend(InheritedArguments)
|
|
151
151
|
end
|
|
152
152
|
|
|
153
|
-
#--
|
|
154
|
-
# @requires_ancestor: singleton(Object)
|
|
155
153
|
module InheritedArguments
|
|
156
154
|
def arguments(context = GraphQL::Query::NullContext.instance, require_defined_arguments = true)
|
|
157
155
|
own_arguments = super(context, require_defined_arguments)
|
|
@@ -382,8 +380,6 @@ module GraphQL
|
|
|
382
380
|
end
|
|
383
381
|
end
|
|
384
382
|
|
|
385
|
-
#--
|
|
386
|
-
# @requires_ancestor: singleton(Object)
|
|
387
383
|
module ArgumentClassAccessor
|
|
388
384
|
def argument_class(new_arg_class = nil)
|
|
389
385
|
if new_arg_class
|
|
@@ -69,7 +69,13 @@ module GraphQL
|
|
|
69
69
|
case schema_member
|
|
70
70
|
when Class
|
|
71
71
|
inherited_directives = if schema_member.superclass.respond_to?(directives_method)
|
|
72
|
-
|
|
72
|
+
superclass_directives = schema_member.superclass.public_send(directives_method)
|
|
73
|
+
if superclass_directives.empty?
|
|
74
|
+
# `superclass_directives` includes inherited ones, so there's nothing to merge
|
|
75
|
+
GraphQL::EmptyObjects::EMPTY_ARRAY
|
|
76
|
+
else
|
|
77
|
+
get_directives(schema_member.superclass, superclass_directives, directives_method)
|
|
78
|
+
end
|
|
73
79
|
else
|
|
74
80
|
GraphQL::EmptyObjects::EMPTY_ARRAY
|
|
75
81
|
end
|
|
@@ -89,12 +89,15 @@ module GraphQL
|
|
|
89
89
|
# authorized_new(Object object, GraphQL::Query::Context context) -> GraphQL::Schema::Object | GraphQL::Execution::Lazy | GraphQL::UnauthorizedError
|
|
90
90
|
def authorized_new(object, context)
|
|
91
91
|
context.query.current_trace.begin_authorized(self, object, context)
|
|
92
|
+
raised_auth_err = nil
|
|
92
93
|
begin
|
|
93
94
|
maybe_lazy_auth_val = context.query.current_trace.authorized(query: context.query, type: self, object: object) do
|
|
94
95
|
begin
|
|
95
96
|
authorized?(object, context)
|
|
96
97
|
rescue GraphQL::UnauthorizedError => err
|
|
97
|
-
|
|
98
|
+
# Raising is equivalent to returning `false`; `unauthorized_object` is called below
|
|
99
|
+
raised_auth_err = err
|
|
100
|
+
false
|
|
98
101
|
rescue StandardError => err
|
|
99
102
|
context.query.handle_or_reraise(err)
|
|
100
103
|
end
|
|
@@ -107,7 +110,12 @@ module GraphQL
|
|
|
107
110
|
GraphQL::Execution::Lazy.new do
|
|
108
111
|
context.query.current_trace.begin_authorized(self, object, context)
|
|
109
112
|
context.query.current_trace.authorized_lazy(query: context.query, type: self, object: object) do
|
|
110
|
-
res =
|
|
113
|
+
res = begin
|
|
114
|
+
context.schema.sync_lazy(maybe_lazy_auth_val)
|
|
115
|
+
rescue GraphQL::UnauthorizedError => err
|
|
116
|
+
raised_auth_err = err
|
|
117
|
+
false
|
|
118
|
+
end
|
|
111
119
|
context.query.current_trace.end_authorized(self, object, context, res)
|
|
112
120
|
res
|
|
113
121
|
end
|
|
@@ -121,7 +129,7 @@ module GraphQL
|
|
|
121
129
|
self.new(object, context)
|
|
122
130
|
else
|
|
123
131
|
# It failed the authorization check, so go to the schema's authorized object hook
|
|
124
|
-
err = GraphQL::UnauthorizedError.new(object: object, type: self, context: context)
|
|
132
|
+
err = raised_auth_err || GraphQL::UnauthorizedError.new(object: object, type: self, context: context)
|
|
125
133
|
# If a new value was returned, wrap that instead of the original value
|
|
126
134
|
begin
|
|
127
135
|
new_obj = context.schema.unauthorized_object(err)
|
data/lib/graphql/schema.rb
CHANGED
|
@@ -2735,8 +2735,10 @@ module GraphQL
|
|
|
2735
2735
|
own_union_memberships.merge!(addition.union_memberships)
|
|
2736
2736
|
|
|
2737
2737
|
addition.references.each { |thing, pointers|
|
|
2738
|
-
|
|
2739
|
-
own_references_to[thing]
|
|
2738
|
+
new_refs = pointers.keys
|
|
2739
|
+
prev_refs = own_references_to[thing]
|
|
2740
|
+
# Same as `prev_refs | new_refs`, but faster when `prev_refs` is small and `new_refs` is big
|
|
2741
|
+
own_references_to[thing] = prev_refs ? (prev_refs + (new_refs - prev_refs)) : new_refs
|
|
2740
2742
|
}
|
|
2741
2743
|
|
|
2742
2744
|
addition.directives.each { |dir_class| own_directives[dir_class.graphql_name] = dir_class }
|
data/lib/graphql/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: graphql
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.6.
|
|
4
|
+
version: 2.6.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Mosolgo
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-10-
|
|
10
|
+
date: 2026-10-29 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: base64
|