graphql 1.12.15 → 1.12.16
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/runtime.rb +24 -19
- data/lib/graphql/pagination/connections.rb +5 -0
- data/lib/graphql/schema/subscription.rb +20 -0
- data/lib/graphql/subscriptions/event.rb +4 -20
- data/lib/graphql/types/big_int.rb +5 -1
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +15 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03b30407d3081dad5d25f3a3f9a9e2781cd34db838688816b01c231aaa5a6dc5
|
4
|
+
data.tar.gz: a06092995f8e3ea0ed2c75485124b0123d41a23d77eedd773e15a1d00fad80ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3af391b8f7394985a42595af2d7b3735a6666310a4583ffd2a9ddce46cf868a6a8d7f2a9cb28ba6a1b85fb70cce8d7425074df847f8b113420e59599bd0379b5
|
7
|
+
data.tar.gz: ca7370709ff588ba437a2f5b277482f2a00543b057ee96e164198ea44f81ad1e470fafe4c7eb89a9e1e64c0aeeddcc128983a67458040c855115516c09adcfd0
|
@@ -10,7 +10,19 @@ module GraphQL
|
|
10
10
|
class Runtime
|
11
11
|
|
12
12
|
module GraphQLResult
|
13
|
-
|
13
|
+
def initialize(result_name, parent_result)
|
14
|
+
@graphql_parent = parent_result
|
15
|
+
if parent_result && parent_result.graphql_dead
|
16
|
+
@graphql_dead = true
|
17
|
+
end
|
18
|
+
@graphql_result_name = result_name
|
19
|
+
# Jump through some hoops to avoid creating this duplicate storage if at all possible.
|
20
|
+
@graphql_metadata = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_accessor :graphql_dead
|
24
|
+
attr_reader :graphql_parent, :graphql_result_name
|
25
|
+
|
14
26
|
# Although these are used by only one of the Result classes,
|
15
27
|
# it's handy to have the methods implemented on both (even though they just return `nil`)
|
16
28
|
# because it makes it easy to check if anything is assigned.
|
@@ -24,9 +36,8 @@ module GraphQL
|
|
24
36
|
end
|
25
37
|
|
26
38
|
class GraphQLResultHash
|
27
|
-
def initialize
|
28
|
-
|
29
|
-
@graphql_metadata = nil
|
39
|
+
def initialize(_result_name, _parent_result)
|
40
|
+
super
|
30
41
|
@graphql_result_data = {}
|
31
42
|
end
|
32
43
|
|
@@ -86,10 +97,8 @@ module GraphQL
|
|
86
97
|
class GraphQLResultArray
|
87
98
|
include GraphQLResult
|
88
99
|
|
89
|
-
def initialize
|
90
|
-
|
91
|
-
# but it will require some work to keep it up-to-date if it's created.
|
92
|
-
@graphql_metadata = nil
|
100
|
+
def initialize(_result_name, _parent_result)
|
101
|
+
super
|
93
102
|
@graphql_result_data = []
|
94
103
|
end
|
95
104
|
|
@@ -146,7 +155,7 @@ module GraphQL
|
|
146
155
|
@context = query.context
|
147
156
|
@multiplex_context = query.multiplex.context
|
148
157
|
@interpreter_context = @context.namespace(:interpreter)
|
149
|
-
@response = GraphQLResultHash.new
|
158
|
+
@response = GraphQLResultHash.new(nil, nil)
|
150
159
|
# Identify runtime directives by checking which of this schema's directives have overridden `def self.resolve`
|
151
160
|
@runtime_directive_names = []
|
152
161
|
noop_resolve_owner = GraphQL::Schema::Directive.singleton_class
|
@@ -208,7 +217,7 @@ module GraphQL
|
|
208
217
|
# directly evaluated and the results can be written right into the main response hash.
|
209
218
|
tap_or_each(gathered_selections) do |selections, is_selection_array|
|
210
219
|
if is_selection_array
|
211
|
-
selection_response = GraphQLResultHash.new
|
220
|
+
selection_response = GraphQLResultHash.new(nil, nil)
|
212
221
|
final_response = @response
|
213
222
|
else
|
214
223
|
selection_response = @response
|
@@ -362,6 +371,7 @@ module GraphQL
|
|
362
371
|
|
363
372
|
# @return [void]
|
364
373
|
def evaluate_selection(path, result_name, field_ast_nodes_or_ast_node, scoped_context, owner_object, owner_type, is_eager_field, selections_result) # rubocop:disable Metrics/ParameterLists
|
374
|
+
return if dead_result?(selections_result)
|
365
375
|
# As a performance optimization, the hash key will be a `Node` if
|
366
376
|
# there's only one selection of the field. But if there are multiple
|
367
377
|
# selections of the field, it will be an Array of nodes
|
@@ -693,9 +703,7 @@ module GraphQL
|
|
693
703
|
after_lazy(object_proxy, owner: current_type, path: path, ast_node: ast_node, scoped_context: context.scoped_context, field: field, owner_object: owner_object, arguments: arguments, trace: false, result_name: result_name, result: selection_result) do |inner_object|
|
694
704
|
continue_value = continue_value(path, inner_object, owner_type, field, is_non_null, ast_node, result_name, selection_result)
|
695
705
|
if HALT != continue_value
|
696
|
-
response_hash = GraphQLResultHash.new
|
697
|
-
response_hash.graphql_parent = selection_result
|
698
|
-
response_hash.graphql_result_name = result_name
|
706
|
+
response_hash = GraphQLResultHash.new(result_name, selection_result)
|
699
707
|
set_result(selection_result, result_name, response_hash)
|
700
708
|
gathered_selections = gather_selections(continue_value, current_type, next_selections)
|
701
709
|
# There are two possibilities for `gathered_selections`:
|
@@ -708,9 +716,7 @@ module GraphQL
|
|
708
716
|
# (Technically, it's possible that one of those entries _doesn't_ require isolation.)
|
709
717
|
tap_or_each(gathered_selections) do |selections, is_selection_array|
|
710
718
|
if is_selection_array
|
711
|
-
this_result = GraphQLResultHash.new
|
712
|
-
this_result.graphql_parent = selection_result
|
713
|
-
this_result.graphql_result_name = result_name
|
719
|
+
this_result = GraphQLResultHash.new(result_name, selection_result)
|
714
720
|
final_result = response_hash
|
715
721
|
else
|
716
722
|
this_result = response_hash
|
@@ -735,16 +741,15 @@ module GraphQL
|
|
735
741
|
end
|
736
742
|
when "LIST"
|
737
743
|
inner_type = current_type.of_type
|
738
|
-
response_list = GraphQLResultArray.new
|
744
|
+
response_list = GraphQLResultArray.new(result_name, selection_result)
|
739
745
|
response_list.graphql_non_null_list_items = inner_type.non_null?
|
740
|
-
response_list.graphql_parent = selection_result
|
741
|
-
response_list.graphql_result_name = result_name
|
742
746
|
set_result(selection_result, result_name, response_list)
|
743
747
|
|
744
748
|
idx = 0
|
745
749
|
scoped_context = context.scoped_context
|
746
750
|
begin
|
747
751
|
value.each do |inner_value|
|
752
|
+
break if dead_result?(response_list)
|
748
753
|
next_path = path.dup
|
749
754
|
next_path << idx
|
750
755
|
this_idx = idx
|
@@ -130,6 +130,11 @@ module GraphQL
|
|
130
130
|
if defined?(Mongoid::Association::Referenced::HasMany::Targets::Enumerable)
|
131
131
|
add(Mongoid::Association::Referenced::HasMany::Targets::Enumerable, Pagination::MongoidRelationConnection)
|
132
132
|
end
|
133
|
+
|
134
|
+
# Mongoid 7.3+
|
135
|
+
if defined?(Mongoid::Association::Referenced::HasMany::Enumerable)
|
136
|
+
add(Mongoid::Association::Referenced::HasMany::Enumerable, Pagination::MongoidRelationConnection)
|
137
|
+
end
|
133
138
|
end
|
134
139
|
end
|
135
140
|
end
|
@@ -116,6 +116,26 @@ module GraphQL
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
+
# This is called during initial subscription to get a "name" for this subscription.
|
120
|
+
# Later, when `.trigger` is called, this will be called again to build another "name".
|
121
|
+
# Any subscribers with matching topic will begin the update flow.
|
122
|
+
#
|
123
|
+
# The default implementation creates a string using the field name, subscription scope, and argument keys and values.
|
124
|
+
# In that implementation, only `.trigger` calls with _exact matches_ result in updates to subscribers.
|
125
|
+
#
|
126
|
+
# To implement a filtered stream-type subscription flow, override this method to return a string with field name and subscription scope.
|
127
|
+
# Then, implement {#update} to compare its arguments to the current `object` and return `:no_update` when an
|
128
|
+
# update should be filtered out.
|
129
|
+
#
|
130
|
+
# @see {#update} for how to skip updates when an event comes with a matching topic.
|
131
|
+
# @param arguments [Hash<String => Object>] The arguments for this topic, in GraphQL-style (camelized strings)
|
132
|
+
# @param field [GraphQL::Schema::Field]
|
133
|
+
# @param scope [Object, nil] A value corresponding to `.trigger(... scope:)` (for updates) or the `subscription_scope` found in `context` (for initial subscriptions).
|
134
|
+
# @return [String] An identifier corresponding to a stream of updates
|
135
|
+
def self.topic_for(arguments:, field:, scope:)
|
136
|
+
Subscriptions::Serialize.dump_recursive([scope, field.graphql_name, arguments])
|
137
|
+
end
|
138
|
+
|
119
139
|
# Overriding Resolver#field_options to include subscription_scope
|
120
140
|
def self.field_options
|
121
141
|
super.merge(
|
@@ -29,26 +29,10 @@ module GraphQL
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# @return [String] an identifier for this unit of subscription
|
32
|
-
def self.serialize(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
when Hash
|
37
|
-
if field.is_a?(GraphQL::Schema::Field)
|
38
|
-
stringify_args(field, arguments)
|
39
|
-
else
|
40
|
-
GraphQL::Query::LiteralInput.from_arguments(
|
41
|
-
arguments,
|
42
|
-
field,
|
43
|
-
nil,
|
44
|
-
)
|
45
|
-
end
|
46
|
-
else
|
47
|
-
raise ArgumentError, "Unexpected arguments: #{arguments}, must be Hash or GraphQL::Arguments"
|
48
|
-
end
|
49
|
-
|
50
|
-
sorted_h = stringify_args(field, normalized_args.to_h)
|
51
|
-
Serialize.dump_recursive([scope, name, sorted_h])
|
32
|
+
def self.serialize(_name, arguments, field, scope:)
|
33
|
+
subscription = field.resolver || GraphQL::Schema::Subscription
|
34
|
+
normalized_args = stringify_args(field, arguments.to_h)
|
35
|
+
subscription.topic_for(arguments: normalized_args, field: field, scope: scope)
|
52
36
|
end
|
53
37
|
|
54
38
|
# @return [String] a logical identifier for this event. (Stable when the query is broadcastable.)
|
@@ -6,7 +6,7 @@ module GraphQL
|
|
6
6
|
description "Represents non-fractional signed whole numeric values. Since the value may exceed the size of a 32-bit integer, it's encoded as a string."
|
7
7
|
|
8
8
|
def self.coerce_input(value, _ctx)
|
9
|
-
value &&
|
9
|
+
value && parse_int(value)
|
10
10
|
rescue ArgumentError
|
11
11
|
nil
|
12
12
|
end
|
@@ -14,6 +14,10 @@ module GraphQL
|
|
14
14
|
def self.coerce_result(value, _ctx)
|
15
15
|
value.to_i.to_s
|
16
16
|
end
|
17
|
+
|
18
|
+
def self.parse_int(value)
|
19
|
+
value.is_a?(Numeric) ? value : Integer(value, 10)
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
data/lib/graphql/version.rb
CHANGED
data/lib/graphql.rb
CHANGED
@@ -57,22 +57,26 @@ module GraphQL
|
|
57
57
|
end
|
58
58
|
|
59
59
|
# Support Ruby 2.2 by implementing `-"str"`. If we drop 2.2 support, we can remove this backport.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
60
|
+
if !String.method_defined?(:-@)
|
61
|
+
module StringDedupBackport
|
62
|
+
refine String do
|
63
|
+
def -@
|
64
|
+
if frozen?
|
65
|
+
self
|
66
|
+
else
|
67
|
+
self.dup.freeze
|
68
|
+
end
|
67
69
|
end
|
68
70
|
end
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
74
|
+
if !String.method_defined?(:match?)
|
75
|
+
module StringMatchBackport
|
76
|
+
refine String do
|
77
|
+
def match?(pattern)
|
78
|
+
self =~ pattern
|
79
|
+
end
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
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.12.
|
4
|
+
version: 1.12.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|