graphql 1.5.7.1 → 1.5.8
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/compatibility/lazy_execution_specification.rb +1 -0
- data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +4 -0
- data/lib/graphql/define/assign_connection.rb +3 -2
- data/lib/graphql/execution/typecast.rb +2 -2
- data/lib/graphql/field.rb +12 -0
- data/lib/graphql/internal_representation.rb +1 -0
- data/lib/graphql/internal_representation/node.rb +17 -10
- data/lib/graphql/internal_representation/print.rb +51 -0
- data/lib/graphql/internal_representation/rewrite.rb +5 -1
- data/lib/graphql/relay.rb +1 -1
- data/lib/graphql/relay/{connection_field.rb → connection_instrumentation.rb} +17 -11
- data/lib/graphql/relay/connection_resolve.rb +3 -5
- data/lib/graphql/relay/mutation.rb +21 -7
- data/lib/graphql/relay/page_info.rb +4 -4
- data/lib/graphql/schema.rb +8 -1
- data/lib/graphql/version.rb +1 -1
- data/spec/graphql/internal_representation/print_spec.rb +41 -0
- data/spec/graphql/internal_representation/rewrite_spec.rb +2 -39
- data/spec/graphql/relay/{connection_field_spec.rb → connection_instrumentation_spec.rb} +13 -9
- data/spec/graphql/static_validation/rules/fields_will_merge_spec.rb +11 -2
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96bef39c8a37b049f8843e78d2f15f1c10430d16
|
4
|
+
data.tar.gz: 23c0c140f6e0bba9fc17468b702102d61cd48044
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5e3451aa0669e2896255851dcfdae11fae11e190db815d2b322076915633f482eef27749374cdab094fdd456ba6420afce12b075f25a71aa709da57374184f3
|
7
|
+
data.tar.gz: 442f220e5edf3087e9bc4fed9fa263096a551c66d88d01f03d58fe431eee72a7fb9067a54569d4f33768a2ebb274f8ec91e4492223281febe29eb12164039c87
|
@@ -4,8 +4,9 @@ module GraphQL
|
|
4
4
|
module AssignConnection
|
5
5
|
def self.call(type_defn, *field_args, max_page_size: nil, **field_kwargs, &field_block)
|
6
6
|
underlying_field = GraphQL::Define::AssignObjectField.call(type_defn, *field_args, **field_kwargs, &field_block)
|
7
|
-
|
8
|
-
|
7
|
+
underlying_field.connection_max_page_size = max_page_size
|
8
|
+
underlying_field.connection = true
|
9
|
+
type_defn.fields[underlying_field.name] = underlying_field
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -28,8 +28,8 @@ module GraphQL
|
|
28
28
|
false
|
29
29
|
end
|
30
30
|
when GraphQL::UnionType
|
31
|
-
# A type is a subtype of that
|
32
|
-
# if the union includes that
|
31
|
+
# A type is a subtype of that union
|
32
|
+
# if the union includes that type
|
33
33
|
parent_type.possible_types.include?(child_type)
|
34
34
|
when GraphQL::ListType
|
35
35
|
# A list type is a subtype of another list type
|
data/lib/graphql/field.rb
CHANGED
@@ -177,6 +177,16 @@ module GraphQL
|
|
177
177
|
# @return [Object, GraphQL::Function] The function used to derive this field
|
178
178
|
attr_accessor :function
|
179
179
|
|
180
|
+
attr_writer :connection
|
181
|
+
|
182
|
+
# @return [Boolean]
|
183
|
+
def connection?
|
184
|
+
@connection
|
185
|
+
end
|
186
|
+
|
187
|
+
# @return [nil, Integer]
|
188
|
+
attr_accessor :connection_max_page_size
|
189
|
+
|
180
190
|
def initialize
|
181
191
|
@complexity = 1
|
182
192
|
@arguments = {}
|
@@ -184,6 +194,8 @@ module GraphQL
|
|
184
194
|
@lazy_resolve_proc = DefaultLazyResolve
|
185
195
|
@relay_node_field = false
|
186
196
|
@default_arguments = nil
|
197
|
+
@connection = false
|
198
|
+
@connection_max_page_size = nil
|
187
199
|
end
|
188
200
|
|
189
201
|
def initialize_copy(other)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "graphql/internal_representation/node"
|
3
|
+
require "graphql/internal_representation/print"
|
3
4
|
require "graphql/internal_representation/rewrite"
|
4
5
|
require "graphql/internal_representation/scope"
|
5
6
|
require "graphql/internal_representation/visit"
|
@@ -19,6 +19,9 @@ module GraphQL
|
|
19
19
|
if @scoped_children.any?
|
20
20
|
all_object_types = Set.new
|
21
21
|
scoped_children.each_key { |t| all_object_types.merge(@query.possible_types(t)) }
|
22
|
+
# Remove any scoped children which don't follow this return type
|
23
|
+
# (This can happen with fragment merging where lexical scope is lost)
|
24
|
+
all_object_types &= @query.possible_types(@return_type)
|
22
25
|
all_object_types.each do |t|
|
23
26
|
new_tc[t] = get_typed_children(t)
|
24
27
|
end
|
@@ -111,19 +114,23 @@ module GraphQL
|
|
111
114
|
|
112
115
|
# Merge selections from `new_parent` into `self`.
|
113
116
|
# Selections are merged in place, not copied.
|
114
|
-
def deep_merge_node(new_parent, merge_self: true)
|
117
|
+
def deep_merge_node(new_parent, scope: nil, merge_self: true)
|
115
118
|
if merge_self
|
116
|
-
@ast_nodes
|
117
|
-
@definitions
|
119
|
+
@ast_nodes.concat(new_parent.ast_nodes)
|
120
|
+
@definitions.concat(new_parent.definitions)
|
118
121
|
end
|
122
|
+
scope ||= Scope.new(@query, @return_type)
|
119
123
|
new_parent.scoped_children.each do |obj_type, new_fields|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
prev_node
|
125
|
-
|
126
|
-
|
124
|
+
inner_scope = scope.enter(obj_type)
|
125
|
+
inner_scope.each do |scoped_type|
|
126
|
+
prev_fields = @scoped_children[scoped_type]
|
127
|
+
new_fields.each do |name, new_node|
|
128
|
+
prev_node = prev_fields[name]
|
129
|
+
if prev_node
|
130
|
+
prev_node.deep_merge_node(new_node)
|
131
|
+
else
|
132
|
+
prev_fields[name] = new_node
|
133
|
+
end
|
127
134
|
end
|
128
135
|
end
|
129
136
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
module InternalRepresentation
|
4
|
+
module Print
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def print(schema, query_string)
|
8
|
+
query = GraphQL::Query.new(schema, query_string)
|
9
|
+
print_node(query.irep_selection)
|
10
|
+
end
|
11
|
+
|
12
|
+
def print_node(node, indent: 0)
|
13
|
+
padding = " " * indent
|
14
|
+
typed_children_padding = " " * (indent + 2)
|
15
|
+
query_str = "".dup
|
16
|
+
|
17
|
+
if !node.definition
|
18
|
+
op_node = node.ast_node
|
19
|
+
name = op_node.name ? " " + op_node.name : ""
|
20
|
+
op_type = op_node.operation_type
|
21
|
+
query_str << "#{op_type}#{name}"
|
22
|
+
else
|
23
|
+
if node.name == node.definition_name
|
24
|
+
query_str << "#{padding}#{node.name}"
|
25
|
+
else
|
26
|
+
query_str << "#{padding}#{node.name}: #{node.definition_name}"
|
27
|
+
end
|
28
|
+
|
29
|
+
args = node.ast_nodes.map { |n| n.arguments.map(&:to_query_string).join(",") }.uniq
|
30
|
+
query_str << args.map { |a| "(#{a})"}.join("|")
|
31
|
+
end
|
32
|
+
|
33
|
+
if node.typed_children.any?
|
34
|
+
query_str << " {\n"
|
35
|
+
node.typed_children.each do |type, children|
|
36
|
+
query_str << "#{typed_children_padding}... on #{type.name} {\n"
|
37
|
+
children.each do |name, child|
|
38
|
+
query_str << print_node(child, indent: indent + 4)
|
39
|
+
end
|
40
|
+
query_str << "#{typed_children_padding}}\n"
|
41
|
+
end
|
42
|
+
query_str << "#{padding}}\n"
|
43
|
+
else
|
44
|
+
query_str << "\n"
|
45
|
+
end
|
46
|
+
|
47
|
+
query_str
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -31,6 +31,8 @@ module GraphQL
|
|
31
31
|
# Hash<Nodes::FragmentSpread => Set<InternalRepresentation::Node>>
|
32
32
|
# A record of fragment spreads and the irep nodes that used them
|
33
33
|
spread_parents = Hash.new { |h, k| h[k] = Set.new }
|
34
|
+
# Hash<Nodes::FragmentSpread => Scope>
|
35
|
+
spread_scopes = {}
|
34
36
|
# Array<Set<InternalRepresentation::Node>>
|
35
37
|
# The current point of the irep_tree during visitation
|
36
38
|
nodes_stack = []
|
@@ -124,6 +126,7 @@ module GraphQL
|
|
124
126
|
if skip_nodes.none? && !skip?(ast_node, query)
|
125
127
|
# Register the irep nodes that depend on this AST node:
|
126
128
|
spread_parents[ast_node].merge(nodes_stack.last)
|
129
|
+
spread_scopes[ast_node] = scopes_stack.last
|
127
130
|
end
|
128
131
|
}
|
129
132
|
|
@@ -139,8 +142,9 @@ module GraphQL
|
|
139
142
|
if fragment_node
|
140
143
|
spread_ast_nodes.each do |spread_ast_node|
|
141
144
|
parent_nodes = spread_parents[spread_ast_node]
|
145
|
+
parent_scope = spread_scopes[spread_ast_node]
|
142
146
|
parent_nodes.each do |parent_node|
|
143
|
-
parent_node.deep_merge_node(fragment_node, merge_self: false)
|
147
|
+
parent_node.deep_merge_node(fragment_node, scope: parent_scope, merge_self: false)
|
144
148
|
end
|
145
149
|
end
|
146
150
|
end
|
data/lib/graphql/relay.rb
CHANGED
@@ -11,6 +11,6 @@ require 'graphql/relay/relation_connection'
|
|
11
11
|
require 'graphql/relay/global_id_resolve'
|
12
12
|
require 'graphql/relay/mutation'
|
13
13
|
require 'graphql/relay/node'
|
14
|
-
require 'graphql/relay/
|
14
|
+
require 'graphql/relay/connection_instrumentation'
|
15
15
|
require 'graphql/relay/connection_resolve'
|
16
16
|
require 'graphql/relay/connection_type'
|
@@ -2,12 +2,11 @@
|
|
2
2
|
module GraphQL
|
3
3
|
module Relay
|
4
4
|
# Provided a GraphQL field which returns a collection of nodes,
|
5
|
-
#
|
6
|
-
# as a collection.
|
5
|
+
# wrap that field to expose those nodes as a connection.
|
7
6
|
#
|
8
7
|
# The original resolve proc is used to fetch nodes,
|
9
8
|
# then a connection implementation is fetched with {BaseConnection.connection_for_nodes}.
|
10
|
-
|
9
|
+
module ConnectionInstrumentation
|
11
10
|
ARGUMENT_DEFINITIONS = [
|
12
11
|
["first", GraphQL::INT_TYPE, "Returns the first _n_ elements from the list."],
|
13
12
|
["after", GraphQL::STRING_TYPE, "Returns the elements in the list that come after the specified global ID."],
|
@@ -28,14 +27,21 @@ module GraphQL
|
|
28
27
|
# Build a connection field from a {GraphQL::Field} by:
|
29
28
|
# - Merging in the default arguments
|
30
29
|
# - Transforming its resolve function to return a connection object
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
def self.instrument(type, field)
|
31
|
+
if field.connection?
|
32
|
+
connection_arguments = DEFAULT_ARGUMENTS.merge(field.arguments)
|
33
|
+
original_resolve = field.resolve_proc
|
34
|
+
original_lazy_resolve = field.lazy_resolve_proc
|
35
|
+
connection_resolve = GraphQL::Relay::ConnectionResolve.new(field, original_resolve)
|
36
|
+
connection_lazy_resolve = GraphQL::Relay::ConnectionResolve.new(field, original_lazy_resolve)
|
37
|
+
field.redefine(
|
38
|
+
resolve: connection_resolve,
|
39
|
+
lazy_resolve: connection_lazy_resolve,
|
40
|
+
arguments: connection_arguments,
|
41
|
+
)
|
42
|
+
else
|
43
|
+
field
|
44
|
+
end
|
39
45
|
end
|
40
46
|
end
|
41
47
|
end
|
@@ -2,18 +2,16 @@
|
|
2
2
|
module GraphQL
|
3
3
|
module Relay
|
4
4
|
class ConnectionResolve
|
5
|
-
def initialize(field, underlying_resolve
|
5
|
+
def initialize(field, underlying_resolve)
|
6
6
|
@field = field
|
7
7
|
@underlying_resolve = underlying_resolve
|
8
|
-
@max_page_size =
|
8
|
+
@max_page_size = field.connection_max_page_size
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(obj, args, ctx)
|
12
12
|
nodes = @underlying_resolve.call(obj, args, ctx)
|
13
13
|
if ctx.schema.lazy?(nodes)
|
14
|
-
|
15
|
-
build_connection(resolved_nodes, args, obj, ctx)
|
16
|
-
}
|
14
|
+
nodes
|
17
15
|
else
|
18
16
|
build_connection(nodes, args, obj, ctx)
|
19
17
|
end
|
@@ -122,7 +122,7 @@ module GraphQL
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def resolve=(new_resolve_proc)
|
125
|
-
@resolve_proc =
|
125
|
+
@resolve_proc = new_resolve_proc
|
126
126
|
end
|
127
127
|
|
128
128
|
def field
|
@@ -218,20 +218,34 @@ module GraphQL
|
|
218
218
|
end
|
219
219
|
end
|
220
220
|
|
221
|
+
module MutationInstrumentation
|
222
|
+
def self.instrument(type, field)
|
223
|
+
if field.mutation
|
224
|
+
new_resolve = MutationResolve.new(field.mutation, field.resolve_proc)
|
225
|
+
new_lazy_resolve = MutationResolve.new(field.mutation, field.lazy_resolve_proc)
|
226
|
+
field.redefine(resolve: new_resolve, lazy_resolve: new_lazy_resolve)
|
227
|
+
else
|
228
|
+
field
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
221
233
|
class MutationResolve
|
222
|
-
def initialize(mutation, resolve
|
234
|
+
def initialize(mutation, resolve)
|
223
235
|
@mutation = mutation
|
224
236
|
@resolve = resolve
|
225
|
-
@wrap_result =
|
237
|
+
@wrap_result = mutation.has_generated_return_type?
|
226
238
|
end
|
227
239
|
|
228
240
|
def call(obj, args, ctx)
|
229
|
-
|
241
|
+
begin
|
242
|
+
mutation_result = @resolve.call(obj, args[:input], ctx)
|
243
|
+
rescue GraphQL::ExecutionError => err
|
244
|
+
mutation_result = err
|
245
|
+
end
|
230
246
|
|
231
247
|
if ctx.schema.lazy?(mutation_result)
|
232
|
-
|
233
|
-
build_result(inner_obj, args, ctx)
|
234
|
-
}
|
248
|
+
mutation_result
|
235
249
|
else
|
236
250
|
build_result(mutation_result, args, ctx)
|
237
251
|
end
|
@@ -5,10 +5,10 @@ module GraphQL
|
|
5
5
|
PageInfo = GraphQL::ObjectType.define do
|
6
6
|
name("PageInfo")
|
7
7
|
description("Information about pagination in a connection.")
|
8
|
-
field :hasNextPage, !types.Boolean, "
|
9
|
-
field :hasPreviousPage, !types.Boolean, "
|
10
|
-
field :startCursor, types.String, "When paginating backwards, the cursor to continue", property: :start_cursor
|
11
|
-
field :endCursor, types.String, "When paginating forwards, the cursor to continue", property: :end_cursor
|
8
|
+
field :hasNextPage, !types.Boolean, "When paginating forwards, are there more items?", property: :has_next_page
|
9
|
+
field :hasPreviousPage, !types.Boolean, "When paginating backwards, are there more items?", property: :has_previous_page
|
10
|
+
field :startCursor, types.String, "When paginating backwards, the cursor to continue.", property: :start_cursor
|
11
|
+
field :endCursor, types.String, "When paginating forwards, the cursor to continue.", property: :end_cursor
|
12
12
|
default_relay true
|
13
13
|
end
|
14
14
|
end
|
data/lib/graphql/schema.rb
CHANGED
@@ -433,8 +433,15 @@ module GraphQL
|
|
433
433
|
|
434
434
|
private
|
435
435
|
|
436
|
+
# Apply instrumentation to fields. Relay instrumentation is applied last
|
437
|
+
# so that user-provided instrumentation can wrap user-provided resolve functions,
|
438
|
+
# _then_ Relay helpers can wrap the returned objects.
|
436
439
|
def build_instrumented_field_map
|
437
|
-
|
440
|
+
all_instrumenters = @instrumenters[:field] + [
|
441
|
+
GraphQL::Relay::ConnectionInstrumentation,
|
442
|
+
GraphQL::Relay::Mutation::MutationInstrumentation,
|
443
|
+
]
|
444
|
+
@instrumented_field_map = InstrumentedFieldMap.new(self, all_instrumenters)
|
438
445
|
end
|
439
446
|
|
440
447
|
def build_types_map
|
data/lib/graphql/version.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe GraphQL::InternalRepresentation::Print do
|
5
|
+
describe "printing queries" do
|
6
|
+
let(:query_str) { <<-GRAPHQL
|
7
|
+
{
|
8
|
+
cheese(id: 1) {
|
9
|
+
flavor
|
10
|
+
...EdibleFields
|
11
|
+
... on Edible {
|
12
|
+
o2: origin
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
fragment EdibleFields on Edible {
|
18
|
+
o: origin
|
19
|
+
}
|
20
|
+
GRAPHQL
|
21
|
+
}
|
22
|
+
it "prints the rewritten query" do
|
23
|
+
query_plan = GraphQL::InternalRepresentation::Print.print(Dummy::Schema, query_str)
|
24
|
+
expected_plan = <<-GRAPHQL
|
25
|
+
query {
|
26
|
+
... on Query {
|
27
|
+
cheese(id: 1) {
|
28
|
+
... on Cheese {
|
29
|
+
flavor()
|
30
|
+
o2: origin()
|
31
|
+
o: origin()
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
GRAPHQL
|
37
|
+
|
38
|
+
assert_equal expected_plan, query_plan
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -6,7 +6,6 @@ describe GraphQL::InternalRepresentation::Rewrite do
|
|
6
6
|
GraphQL::Schema.from_definition <<-GRAPHQL
|
7
7
|
type Query {
|
8
8
|
plant(id: ID!): Plant
|
9
|
-
fruit(id: ID!): [Fruit!]
|
10
9
|
}
|
11
10
|
|
12
11
|
union Plant = Grain | Fruit | Vegetable | Nut
|
@@ -45,11 +44,7 @@ describe GraphQL::InternalRepresentation::Rewrite do
|
|
45
44
|
habitats: [Habitat]
|
46
45
|
}
|
47
46
|
|
48
|
-
|
49
|
-
seasons: [String]
|
50
|
-
}
|
51
|
-
|
52
|
-
type Habitat implements Environ {
|
47
|
+
type Habitat {
|
53
48
|
residentName: String!
|
54
49
|
averageWeight: Int!
|
55
50
|
seasons: [String]
|
@@ -113,7 +108,7 @@ describe GraphQL::InternalRepresentation::Rewrite do
|
|
113
108
|
assert_equal nil, doc.definition
|
114
109
|
|
115
110
|
plant_scoped_selection = doc.scoped_children[schema.types["Query"]]["plant"]
|
116
|
-
assert_equal ["Fruit", "Nut", "Plant"
|
111
|
+
assert_equal ["Fruit", "Nut", "Plant"], plant_scoped_selection.scoped_children.keys.map(&:name).sort
|
117
112
|
|
118
113
|
plant_selection = doc.typed_children[schema.types["Query"]]["plant"]
|
119
114
|
assert_equal ["Fruit", "Grain", "Nut", "Vegetable"], plant_selection.typed_children.keys.map(&:name).sort
|
@@ -291,36 +286,4 @@ describe GraphQL::InternalRepresentation::Rewrite do
|
|
291
286
|
end
|
292
287
|
end
|
293
288
|
end
|
294
|
-
|
295
|
-
describe "fragment merging bug" do
|
296
|
-
let(:query_string) {
|
297
|
-
<<-GRAPHQL
|
298
|
-
{
|
299
|
-
...Frag1
|
300
|
-
__type(name: "Query") {
|
301
|
-
...Frag2
|
302
|
-
}
|
303
|
-
}
|
304
|
-
|
305
|
-
fragment Frag1 on Query {
|
306
|
-
__type(name: "Query") {
|
307
|
-
...Frag2
|
308
|
-
}
|
309
|
-
}
|
310
|
-
|
311
|
-
fragment Frag2 on __Type {
|
312
|
-
__typename
|
313
|
-
}
|
314
|
-
GRAPHQL
|
315
|
-
}
|
316
|
-
|
317
|
-
it "finishes" do
|
318
|
-
doc = rewrite_result[nil]
|
319
|
-
type_node = doc.typed_children[schema.types["Query"]]["__type"]
|
320
|
-
typename_node = type_node.typed_children[schema.types["__Type"]]["__typename"]
|
321
|
-
assert_equal 1, typename_node.ast_nodes.size
|
322
|
-
assert_equal 15, typename_node.ast_node.line
|
323
|
-
assert_equal 9, typename_node.ast_node.col
|
324
|
-
end
|
325
|
-
end
|
326
289
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "spec_helper"
|
3
3
|
|
4
|
-
describe GraphQL::Relay::
|
4
|
+
describe GraphQL::Relay::ConnectionInstrumentation do
|
5
5
|
it "replaces the previous field definition" do
|
6
6
|
test_type = GraphQL::ObjectType.define do
|
7
7
|
name "Test"
|
@@ -16,7 +16,7 @@ describe GraphQL::Relay::ConnectionField do
|
|
16
16
|
assert_instance_of StarWars::ShipsWithMaxPageSize, conn_field.function
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
let(:build_schema) {
|
20
20
|
test_type = nil
|
21
21
|
|
22
22
|
test_field = GraphQL::Field.define do
|
@@ -29,7 +29,15 @@ describe GraphQL::Relay::ConnectionField do
|
|
29
29
|
connection :tests, test_field
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
[
|
33
|
+
test_field,
|
34
|
+
GraphQL::Schema.define(query: test_type, raise_definition_error: true)
|
35
|
+
]
|
36
|
+
}
|
37
|
+
|
38
|
+
it "leaves the original field untouched" do
|
39
|
+
test_field, test_schema = build_schema
|
40
|
+
conn_field = test_schema.get_field(test_schema.query, "tests")
|
33
41
|
|
34
42
|
assert_equal 0, test_field.arguments.length
|
35
43
|
assert_equal 4, conn_field.arguments.length
|
@@ -39,12 +47,8 @@ describe GraphQL::Relay::ConnectionField do
|
|
39
47
|
end
|
40
48
|
|
41
49
|
it "passes connection behaviors to redefinitions" do
|
42
|
-
|
43
|
-
|
44
|
-
connection :tests, test_type.connection_type
|
45
|
-
end
|
46
|
-
|
47
|
-
connection_field = test_type.fields["tests"]
|
50
|
+
_test_field, test_schema = build_schema
|
51
|
+
connection_field = test_schema.get_field(test_schema.query, "tests")
|
48
52
|
redefined_connection_field = connection_field.redefine { argument "name", types.String }
|
49
53
|
|
50
54
|
assert_equal 4, connection_field.arguments.size
|
@@ -422,19 +422,28 @@ describe GraphQL::StaticValidation::FieldsWillMerge do
|
|
422
422
|
{
|
423
423
|
pet {
|
424
424
|
... on Dog {
|
425
|
-
|
425
|
+
...X
|
426
426
|
}
|
427
427
|
... on Cat {
|
428
|
-
|
428
|
+
...Y
|
429
429
|
}
|
430
430
|
}
|
431
431
|
}
|
432
|
+
|
433
|
+
fragment X on Pet {
|
434
|
+
name(surname: true)
|
435
|
+
}
|
436
|
+
|
437
|
+
fragment Y on Pet {
|
438
|
+
name
|
439
|
+
}
|
432
440
|
|}
|
433
441
|
|
434
442
|
it "passes rule" do
|
435
443
|
assert_equal [], errors
|
436
444
|
end
|
437
445
|
end
|
446
|
+
|
438
447
|
describe "return types must be unambiguous" do
|
439
448
|
let(:schema) {
|
440
449
|
GraphQL::Schema.from_definition(%|
|
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.5.
|
4
|
+
version: 1.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -363,6 +363,7 @@ files:
|
|
363
363
|
- lib/graphql/interface_type.rb
|
364
364
|
- lib/graphql/internal_representation.rb
|
365
365
|
- lib/graphql/internal_representation/node.rb
|
366
|
+
- lib/graphql/internal_representation/print.rb
|
366
367
|
- lib/graphql/internal_representation/rewrite.rb
|
367
368
|
- lib/graphql/internal_representation/scope.rb
|
368
369
|
- lib/graphql/internal_representation/visit.rb
|
@@ -420,7 +421,7 @@ files:
|
|
420
421
|
- lib/graphql/relay.rb
|
421
422
|
- lib/graphql/relay/array_connection.rb
|
422
423
|
- lib/graphql/relay/base_connection.rb
|
423
|
-
- lib/graphql/relay/
|
424
|
+
- lib/graphql/relay/connection_instrumentation.rb
|
424
425
|
- lib/graphql/relay/connection_resolve.rb
|
425
426
|
- lib/graphql/relay/connection_type.rb
|
426
427
|
- lib/graphql/relay/edge.rb
|
@@ -533,6 +534,7 @@ files:
|
|
533
534
|
- spec/graphql/input_object_type_spec.rb
|
534
535
|
- spec/graphql/int_type_spec.rb
|
535
536
|
- spec/graphql/interface_type_spec.rb
|
537
|
+
- spec/graphql/internal_representation/print_spec.rb
|
536
538
|
- spec/graphql/internal_representation/rewrite_spec.rb
|
537
539
|
- spec/graphql/introspection/directive_type_spec.rb
|
538
540
|
- spec/graphql/introspection/input_value_type_spec.rb
|
@@ -558,7 +560,7 @@ files:
|
|
558
560
|
- spec/graphql/query_spec.rb
|
559
561
|
- spec/graphql/relay/array_connection_spec.rb
|
560
562
|
- spec/graphql/relay/base_connection_spec.rb
|
561
|
-
- spec/graphql/relay/
|
563
|
+
- spec/graphql/relay/connection_instrumentation_spec.rb
|
562
564
|
- spec/graphql/relay/connection_resolve_spec.rb
|
563
565
|
- spec/graphql/relay/connection_type_spec.rb
|
564
566
|
- spec/graphql/relay/mutation_spec.rb
|
@@ -679,6 +681,7 @@ test_files:
|
|
679
681
|
- spec/graphql/input_object_type_spec.rb
|
680
682
|
- spec/graphql/int_type_spec.rb
|
681
683
|
- spec/graphql/interface_type_spec.rb
|
684
|
+
- spec/graphql/internal_representation/print_spec.rb
|
682
685
|
- spec/graphql/internal_representation/rewrite_spec.rb
|
683
686
|
- spec/graphql/introspection/directive_type_spec.rb
|
684
687
|
- spec/graphql/introspection/input_value_type_spec.rb
|
@@ -704,7 +707,7 @@ test_files:
|
|
704
707
|
- spec/graphql/query_spec.rb
|
705
708
|
- spec/graphql/relay/array_connection_spec.rb
|
706
709
|
- spec/graphql/relay/base_connection_spec.rb
|
707
|
-
- spec/graphql/relay/
|
710
|
+
- spec/graphql/relay/connection_instrumentation_spec.rb
|
708
711
|
- spec/graphql/relay/connection_resolve_spec.rb
|
709
712
|
- spec/graphql/relay/connection_type_spec.rb
|
710
713
|
- spec/graphql/relay/mutation_spec.rb
|