graphql 0.16.0 → 0.16.1

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: f8d3d315c998e0d44c6ebbcd186825a1d7c86639
4
- data.tar.gz: adfa16f977635d988505202bee3ea8fe54ede003
3
+ metadata.gz: 7e4d95f2f01d1d24633dc5b6c062a67e6a752379
4
+ data.tar.gz: 19634030a6f735243babd83be75d9279c2987795
5
5
  SHA512:
6
- metadata.gz: 34bad6ba6d2ff0e811b2d9abbddf3e834df69e8fb8d6a1b06581f446b8bffee325717df2731874bcec57581cac8d7808a9c97937d43e1d45386edf41f8824a4f
7
- data.tar.gz: e11a5741e64138f68cac3ad51d14243bfa47c8f56b3b03144b685b1d2d71d4fea657221bcdffcfdaef5edd485b7df6262eb018b38ac4dcb0e01b22648c55a080
6
+ metadata.gz: 189c9d0eacdc54969b15f412dbb968c3a1d9aadedd0ccd4e74cc3e9afaf1af33c83c0f4a9b911ed563a3fc9dc8f256c75d74d013832273038087ae38734abeb2
7
+ data.tar.gz: 675427c4e5233153a58f6ff3a2abbe754e9216261872d666301ceeeeb1919b8098c4b7bdf2ee8065ccb781d3ad35c6a2bfa7f1e0e5e719486176655831032efb
@@ -167,6 +167,7 @@ module GraphQL
167
167
  # Merge `node` into `parent_node`'s children, as `name`, applying `extra_directives`
168
168
  def deep_merge_child(parent_node, name, node, extra_directives)
169
169
  child_node = parent_node.children[name] ||= node.dup
170
+ child_node.on_types.merge(node.on_types)
170
171
  node.children.each do |merge_child_name, merge_child_node|
171
172
  deep_merge_child(child_node, merge_child_name, merge_child_node, [])
172
173
  end
@@ -1,3 +1,3 @@
1
1
  module GraphQL
2
- VERSION = "0.16.0"
2
+ VERSION = "0.16.1"
3
3
  end
@@ -132,7 +132,7 @@ describe GraphQL::Analysis::QueryComplexity do
132
132
 
133
133
  it "gets the max among options" do
134
134
  reduce_result
135
- assert_equal 5, complexities.last
135
+ assert_equal 6, complexities.last
136
136
  end
137
137
  end
138
138
 
@@ -18,6 +18,7 @@ describe GraphQL::Introspection::SchemaType do
18
18
  "types" => DummySchema.types.values.map { |t| t.name.nil? ? (p t; raise("no name for #{t}")) : {"name" => t.name} },
19
19
  "queryType"=>{
20
20
  "fields"=>[
21
+ {"name"=>"allDairy"},
21
22
  {"name"=>"cheese"},
22
23
  {"name"=>"cow"},
23
24
  {"name"=>"dairy"},
@@ -28,4 +28,47 @@ describe GraphQL::UnionType do
28
28
  it '#include? returns false if type is not in possible_types' do
29
29
  assert_equal(false, union.include?(type_3))
30
30
  end
31
+
32
+ describe "list of union type" do
33
+ describe "fragment spreads" do
34
+ let(:result) { DummySchema.execute(query_string) }
35
+ let(:query_string) {%|
36
+ {
37
+ allDairy {
38
+ __typename
39
+ ... milkFields
40
+ ... cheeseFields
41
+ }
42
+ }
43
+ fragment milkFields on Milk {
44
+ id
45
+ source
46
+ origin
47
+ flavors
48
+ }
49
+
50
+ fragment cheeseFields on Cheese {
51
+ id
52
+ source
53
+ origin
54
+ flavor
55
+ }
56
+ |}
57
+
58
+ it "resolves the right fragment on the right item" do
59
+ all_dairy = result["data"]["allDairy"]
60
+ cheeses = all_dairy.first(3)
61
+ cheeses.each do |cheese|
62
+ assert_equal "Cheese", cheese["__typename"]
63
+ assert_equal ["__typename", "id", "source", "origin", "flavor"], cheese.keys
64
+ end
65
+
66
+ milks = all_dairy.last(1)
67
+ milks.each do |milk|
68
+ assert_equal "Milk", milk["__typename"]
69
+ assert_equal ["__typename", "id", "source", "origin", "flavors"], milk.keys
70
+ end
71
+ end
72
+ end
73
+ end
31
74
  end
@@ -241,6 +241,10 @@ QueryType = GraphQL::ObjectType.define do
241
241
  }
242
242
  end
243
243
 
244
+ field :allDairy, types[DairyProductUnion] do
245
+ resolve -> (obj, args, ctx) { CHEESES.values + MILKS.values }
246
+ end
247
+
244
248
  field :error do
245
249
  description "Raise an error"
246
250
  type GraphQL::STRING_TYPE
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: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2016-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter
@@ -219,6 +219,7 @@ files:
219
219
  - lib/graphql/int_type.rb
220
220
  - lib/graphql/interface_type.rb
221
221
  - lib/graphql/internal_representation.rb
222
+ - lib/graphql/internal_representation/definition.rb
222
223
  - lib/graphql/internal_representation/node.rb
223
224
  - lib/graphql/internal_representation/rewrite.rb
224
225
  - lib/graphql/introspection.rb