graphql 1.12.4 → 1.12.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/graphql/install_generator.rb +1 -0
- data/lib/generators/graphql/loader_generator.rb +1 -0
- data/lib/generators/graphql/mutation_generator.rb +1 -0
- data/lib/generators/graphql/relay_generator.rb +1 -0
- data/lib/generators/graphql/type_generator.rb +1 -0
- data/lib/graphql/backtrace/tracer.rb +2 -2
- data/lib/graphql/dataloader.rb +9 -9
- data/lib/graphql/execution/interpreter.rb +1 -1
- data/lib/graphql/pagination/connection.rb +9 -0
- data/lib/graphql/relay/range_add.rb +10 -5
- data/lib/graphql/schema.rb +9 -8
- data/lib/graphql/schema/resolver.rb +28 -1
- data/lib/graphql/version.rb +1 -1
- data/readme.md +1 -1
- 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: 4ec7a782dba5df306d3e0590820d75d520b86651b9293417b115070057c45b8f
|
4
|
+
data.tar.gz: 731f02ddfda3690ecd54cba1b1f373f9c8a53b65d422f853d44ddc9072fa85d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0783dea9b65037ea2d92b9ab88fc98153a541b0821f7b5d38bb53de3d33024a85d626302c8c92ddc9971606806c1a7896fb7a98da0c8c2261f9a034d87624e2
|
7
|
+
data.tar.gz: c4b6035220bf578fc974a3fa437914dd5e652018b651b0c5af57f355e5d08b113a2faa2a6824242b71d01bab844767592f4d6ea5323e66e2ef05bcd74ad62df3
|
@@ -44,13 +44,13 @@ module GraphQL
|
|
44
44
|
end
|
45
45
|
|
46
46
|
if push_data && multiplex
|
47
|
-
multiplex.context[:graphql_backtrace_contexts]
|
47
|
+
push_storage = multiplex.context[:graphql_backtrace_contexts] ||= {}
|
48
|
+
push_storage[push_key] = push_data
|
48
49
|
multiplex.context[:last_graphql_backtrace_context] = push_data
|
49
50
|
end
|
50
51
|
|
51
52
|
if key == "execute_multiplex"
|
52
53
|
multiplex_context = metadata[:multiplex].context
|
53
|
-
multiplex_context[:graphql_backtrace_contexts] = {}
|
54
54
|
begin
|
55
55
|
yield
|
56
56
|
rescue StandardError => err
|
data/lib/graphql/dataloader.rb
CHANGED
@@ -95,7 +95,7 @@ module GraphQL
|
|
95
95
|
else
|
96
96
|
# These fibers were previously waiting for sources to load data,
|
97
97
|
# resume them. (They might wait again, in which case, re-enqueue them.)
|
98
|
-
f
|
98
|
+
resume(f)
|
99
99
|
if f.alive?
|
100
100
|
next_fibers << f
|
101
101
|
end
|
@@ -109,10 +109,7 @@ module GraphQL
|
|
109
109
|
job.call
|
110
110
|
end
|
111
111
|
}
|
112
|
-
|
113
|
-
if result.is_a?(StandardError)
|
114
|
-
raise result
|
115
|
-
end
|
112
|
+
resume(f)
|
116
113
|
# In this case, the job yielded. Queue it up to run again after
|
117
114
|
# we load whatever it's waiting for.
|
118
115
|
if f.alive?
|
@@ -138,10 +135,7 @@ module GraphQL
|
|
138
135
|
# that newly-pending source will run _before_ the one that depends on it.
|
139
136
|
# (See below where the old fiber is pushed to the stack, then the new fiber is pushed on the stack.)
|
140
137
|
while (outer_source_fiber = source_fiber_stack.pop)
|
141
|
-
|
142
|
-
if result.is_a?(StandardError)
|
143
|
-
raise result
|
144
|
-
end
|
138
|
+
resume(outer_source_fiber)
|
145
139
|
|
146
140
|
if outer_source_fiber.alive?
|
147
141
|
source_fiber_stack << outer_source_fiber
|
@@ -204,5 +198,11 @@ module GraphQL
|
|
204
198
|
|
205
199
|
source_fiber
|
206
200
|
end
|
201
|
+
|
202
|
+
def resume(fiber)
|
203
|
+
fiber.resume
|
204
|
+
rescue UncaughtThrowError => e
|
205
|
+
throw e.tag, e.value
|
206
|
+
end
|
207
207
|
end
|
208
208
|
end
|
@@ -113,7 +113,7 @@ module GraphQL
|
|
113
113
|
def initialize(value:, path:, field:)
|
114
114
|
message = "Failed to build a GraphQL list result for field `#{field.path}` at path `#{path.join(".")}`.\n".dup
|
115
115
|
|
116
|
-
message << "Expected `#{value.inspect}` to implement `.each` to satisfy the GraphQL return type `#{field.type.to_type_signature}`.\n"
|
116
|
+
message << "Expected `#{value.inspect}` (#{value.class}) to implement `.each` to satisfy the GraphQL return type `#{field.type.to_type_signature}`.\n"
|
117
117
|
|
118
118
|
if field.connection?
|
119
119
|
message << "\nThis field was treated as a Relay-style connection; add `connection: false` to the `field(...)` to disable this behavior."
|
@@ -105,6 +105,15 @@ module GraphQL
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
+
# This is called by `Relay::RangeAdd` -- it can be overridden
|
109
|
+
# when `item` needs some modifications based on this connection's state.
|
110
|
+
#
|
111
|
+
# @param item [Object] An item newly added to `items`
|
112
|
+
# @return [Edge]
|
113
|
+
def range_add_edge(item)
|
114
|
+
edge_class.new(item, self)
|
115
|
+
end
|
116
|
+
|
108
117
|
attr_writer :last
|
109
118
|
# @return [Integer, nil] A clamped `last` value. (The underlying instance variable doesn't have limits on it)
|
110
119
|
def last
|
@@ -9,7 +9,7 @@ module GraphQL
|
|
9
9
|
# should be ordered and paginated before providing it here.
|
10
10
|
#
|
11
11
|
# @example Adding a comment to list of comments
|
12
|
-
# post = Post.find(args[:
|
12
|
+
# post = Post.find(args[:post_id])
|
13
13
|
# comments = post.comments
|
14
14
|
# new_comment = comments.build(body: args[:body])
|
15
15
|
# new_comment.save!
|
@@ -18,13 +18,13 @@ module GraphQL
|
|
18
18
|
# parent: post,
|
19
19
|
# collection: comments,
|
20
20
|
# item: new_comment,
|
21
|
-
# context:
|
21
|
+
# context: context,
|
22
22
|
# )
|
23
23
|
#
|
24
24
|
# response = {
|
25
25
|
# post: post,
|
26
|
-
#
|
27
|
-
#
|
26
|
+
# comments_connection: range_add.connection,
|
27
|
+
# new_comment_edge: range_add.edge,
|
28
28
|
# }
|
29
29
|
class RangeAdd
|
30
30
|
attr_reader :edge, :connection, :parent
|
@@ -39,7 +39,12 @@ module GraphQL
|
|
39
39
|
conn_class = context.schema.connections.wrapper_for(collection)
|
40
40
|
# The rest will be added by ConnectionExtension
|
41
41
|
@connection = conn_class.new(collection, parent: parent, context: context, edge_class: edge_class)
|
42
|
-
|
42
|
+
# Check if this connection supports it, to support old versions of GraphQL-Pro
|
43
|
+
@edge = if @connection.respond_to?(:range_add_edge)
|
44
|
+
@connection.range_add_edge(item)
|
45
|
+
else
|
46
|
+
@connection.edge_class.new(item, @connection)
|
47
|
+
end
|
43
48
|
else
|
44
49
|
connection_class = BaseConnection.connection_for_nodes(collection)
|
45
50
|
@connection = connection_class.new(collection, {}, parent: parent, context: context)
|
data/lib/graphql/schema.rb
CHANGED
@@ -1118,14 +1118,15 @@ module GraphQL
|
|
1118
1118
|
type.possible_types(context: context)
|
1119
1119
|
else
|
1120
1120
|
stored_possible_types = own_possible_types[type.graphql_name]
|
1121
|
-
visible_possible_types = stored_possible_types
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1121
|
+
visible_possible_types = if stored_possible_types && type.kind.interface?
|
1122
|
+
stored_possible_types.select do |possible_type|
|
1123
|
+
# Use `.graphql_name` comparison to match legacy vs class-based types.
|
1124
|
+
# When we don't need to support legacy `.define` types, use `.include?(type)` instead.
|
1125
|
+
possible_type.interfaces(context).any? { |interface| interface.graphql_name == type.graphql_name }
|
1126
|
+
end
|
1127
|
+
else
|
1128
|
+
stored_possible_types
|
1129
|
+
end
|
1129
1130
|
visible_possible_types ||
|
1130
1131
|
introspection_system.possible_types[type.graphql_name] ||
|
1131
1132
|
(
|
@@ -276,8 +276,29 @@ module GraphQL
|
|
276
276
|
end
|
277
277
|
end
|
278
278
|
|
279
|
+
# Get or set the `max_page_size:` which will be configured for fields using this resolver
|
280
|
+
# (`nil` means "unlimited max page size".)
|
281
|
+
# @param max_page_size [Integer, nil] Set a new value
|
282
|
+
# @return [Integer, nil] The `max_page_size` assigned to fields that use this resolver
|
283
|
+
def max_page_size(new_max_page_size = :not_given)
|
284
|
+
if new_max_page_size != :not_given
|
285
|
+
@max_page_size = new_max_page_size
|
286
|
+
elsif defined?(@max_page_size)
|
287
|
+
@max_page_size
|
288
|
+
elsif superclass.respond_to?(:max_page_size)
|
289
|
+
superclass.max_page_size
|
290
|
+
else
|
291
|
+
nil
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
# @return [Boolean] `true` if this resolver or a superclass has an assigned `max_page_size`
|
296
|
+
def has_max_page_size?
|
297
|
+
defined?(@max_page_size) || (superclass.respond_to?(:has_max_page_size?) && superclass.has_max_page_size?)
|
298
|
+
end
|
299
|
+
|
279
300
|
def field_options
|
280
|
-
{
|
301
|
+
field_opts = {
|
281
302
|
type: type_expr,
|
282
303
|
description: description,
|
283
304
|
extras: extras,
|
@@ -289,6 +310,12 @@ module GraphQL
|
|
289
310
|
extensions: extensions,
|
290
311
|
broadcastable: broadcastable?,
|
291
312
|
}
|
313
|
+
|
314
|
+
if has_max_page_size?
|
315
|
+
field_opts[:max_page_size] = max_page_size
|
316
|
+
end
|
317
|
+
|
318
|
+
field_opts
|
292
319
|
end
|
293
320
|
|
294
321
|
# A non-normalized type configuration, without `null` applied
|
data/lib/graphql/version.rb
CHANGED
data/readme.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# graphql <img src="https://cloud.githubusercontent.com/assets/2231765/9094460/cb43861e-3b66-11e5-9fbf-71066ff3ab13.png" height="40" alt="graphql-ruby"/>
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![CI Suite](https://github.com/rmosolgo/graphql-ruby/actions/workflows/ci.yaml/badge.svg)](https://github.com/rmosolgo/graphql-ruby/actions/workflows/ci.yaml)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/graphql.svg)](https://rubygems.org/gems/graphql)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/rmosolgo/graphql-ruby/badges/gpa.svg)](https://codeclimate.com/github/rmosolgo/graphql-ruby)
|
6
6
|
[![Test Coverage](https://codeclimate.com/github/rmosolgo/graphql-ruby/badges/coverage.svg)](https://codeclimate.com/github/rmosolgo/graphql-ruby)
|
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.5
|
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-02-
|
11
|
+
date: 2021-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|