graphql 1.5.11 → 1.5.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb2841b1c8677bc9188757eca08b2f365f0e0af8
4
- data.tar.gz: 12bc61f9684e3bae2a4d06c22f9378064fcf191d
3
+ metadata.gz: 3e204a82f5db905b17eeaa50f14e7b2af0ddff12
4
+ data.tar.gz: 6c7029686c56fb6ad2ef90084381131f1f06a68c
5
5
  SHA512:
6
- metadata.gz: 7859ae0afed299edb29dedc59d014f057b85dde4e3547a300d312c0ba137f23cc23d6c70c664a3afd6985c3b393483aa012c8e7ba6e70e0713ad203163dbc089
7
- data.tar.gz: 61ab9c38a66e013b09bec6f5865aae178110ba99b230b2a94b325ea1afef7b1bb9beb98744c52cee0d8b2c2813b377a39dbef13c920bf319cddfeef1ba2f3e07
6
+ metadata.gz: d4de6aa1e85f4e2b51ae00866c00fd3ef0b201059ccb6a28a74a97cfe1528b1739086585db4488911893a781b8a0857fd318175e95fd135e91e5cb091cfc55d6
7
+ data.tar.gz: 59ef188909e4f03b6793cf00c935e05bc4fd45f91e1910b068529a4661e7261d778c7e3d78b5b55cd563cc5e23fe5be8cb1a989a56180dff4df48380c3aea286
@@ -116,8 +116,8 @@ module GraphQL
116
116
  # Selections are merged in place, not copied.
117
117
  def deep_merge_node(new_parent, scope: nil, merge_self: true)
118
118
  if merge_self
119
- @ast_nodes.concat(new_parent.ast_nodes)
120
- @definitions.concat(new_parent.definitions)
119
+ @ast_nodes |= new_parent.ast_nodes
120
+ @definitions |= new_parent.definitions
121
121
  end
122
122
  scope ||= Scope.new(@query, @return_type)
123
123
  new_parent.scoped_children.each do |obj_type, new_fields|
@@ -10,7 +10,10 @@ module GraphQL
10
10
 
11
11
  def call(obj, args, ctx)
12
12
  nodes = @underlying_resolve.call(obj, args, ctx)
13
- if ctx.schema.lazy?(nodes)
13
+
14
+ if nodes.nil?
15
+ nil
16
+ elsif ctx.schema.lazy?(nodes)
14
17
  nodes
15
18
  else
16
19
  build_connection(nodes, args, obj, ctx)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.5.11"
3
+ VERSION = "1.5.12"
4
4
  end
@@ -6,6 +6,7 @@ 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!]
9
10
  }
10
11
 
11
12
  union Plant = Grain | Fruit | Vegetable | Nut
@@ -44,7 +45,11 @@ describe GraphQL::InternalRepresentation::Rewrite do
44
45
  habitats: [Habitat]
45
46
  }
46
47
 
47
- type Habitat {
48
+ interface Environ {
49
+ seasons: [String]
50
+ }
51
+
52
+ type Habitat implements Environ {
48
53
  residentName: String!
49
54
  averageWeight: Int!
50
55
  seasons: [String]
@@ -287,6 +292,38 @@ describe GraphQL::InternalRepresentation::Rewrite do
287
292
  end
288
293
  end
289
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.operation_definitions[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
+
290
327
  describe "fragment definition without query" do
291
328
  let(:query_string) {
292
329
  <<-GRAPHQL
@@ -2,44 +2,52 @@
2
2
  require "spec_helper"
3
3
 
4
4
  describe GraphQL::Relay::ConnectionResolve do
5
- describe "when an execution error is returned" do
6
- let(:query_string) { <<-GRAPHQL
7
- query getError($error: String!){
8
- rebels {
9
- ships(nameIncludes: $error) {
10
- edges {
11
- node {
12
- name
13
- }
5
+ let(:query_string) { <<-GRAPHQL
6
+ query getShips($name: String!){
7
+ rebels {
8
+ ships(nameIncludes: $name) {
9
+ edges {
10
+ node {
11
+ name
14
12
  }
15
13
  }
16
14
  }
17
15
  }
18
- GRAPHQL
19
16
  }
17
+ GRAPHQL
18
+ }
20
19
 
20
+ describe "when an execution error is returned" do
21
21
  it "adds an error" do
22
- result = star_wars_query(query_string, { "error" => "error"})
22
+ result = star_wars_query(query_string, { "name" => "error"})
23
23
  assert_equal 1, result["errors"].length
24
24
  assert_equal "error from within connection", result["errors"][0]["message"]
25
25
  end
26
26
 
27
27
  it "adds an error for a lazy error" do
28
- result = star_wars_query(query_string, { "error" => "lazyError"})
28
+ result = star_wars_query(query_string, { "name" => "lazyError"})
29
29
  assert_equal 1, result["errors"].length
30
30
  assert_equal "lazy error from within connection", result["errors"][0]["message"]
31
31
  end
32
32
 
33
33
  it "adds an error for a lazy raised error" do
34
- result = star_wars_query(query_string, { "error" => "lazyRaisedError"})
34
+ result = star_wars_query(query_string, { "name" => "lazyRaisedError"})
35
35
  assert_equal 1, result["errors"].length
36
36
  assert_equal "lazy raised error from within connection", result["errors"][0]["message"]
37
37
  end
38
38
 
39
39
  it "adds an error for a raised error" do
40
- result = star_wars_query(query_string, { "error" => "raisedError"})
40
+ result = star_wars_query(query_string, { "name" => "raisedError"})
41
41
  assert_equal 1, result["errors"].length
42
42
  assert_equal "error raised from within connection", result["errors"][0]["message"]
43
43
  end
44
44
  end
45
+
46
+ describe "when nil is returned" do
47
+ it "becomes null" do
48
+ result = star_wars_query(query_string, { "name" => "null" })
49
+ conn = result["data"]["rebels"]["ships"]
50
+ assert_equal nil, conn
51
+ end
52
+ end
45
53
  end
@@ -102,6 +102,8 @@ module StarWars
102
102
  all_ships = LazyWrapper.new { GraphQL::ExecutionError.new("lazy error from within connection") }
103
103
  when "lazyRaisedError"
104
104
  all_ships = LazyWrapper.new { raise GraphQL::ExecutionError.new("lazy raised error from within connection") }
105
+ when "null"
106
+ all_ships = nil
105
107
  else
106
108
  all_ships = all_ships.select { |ship| ship.name.include?(args[:nameIncludes])}
107
109
  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.5.11
4
+ version: 1.5.12
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-05-08 00:00:00.000000000 Z
11
+ date: 2017-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips