graphql 0.18.12 → 0.18.13

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: fbb584f225769c48d6c7d9878ff6d237068f0c5b
4
- data.tar.gz: cf2c4052c0b5facfcf788524bf6a9b3b1b89b167
3
+ metadata.gz: 4ede8bf16e041625d9150b4a02ca1203e5f77f67
4
+ data.tar.gz: be963dcb88acc294fd826798a1d1e480d3abb8f1
5
5
  SHA512:
6
- metadata.gz: 4d09502f2198d2e0cc265db03d49bc80061c999e23471615622793b8d7ef25cea10e7a9fbd4ff48302f01453ae36652cb8c9b6fcca1ceac8c8c17578d3f2beb7
7
- data.tar.gz: 81eb4cd1c6d3f00f9770a6929da390caac133266b89bd3c1ad8737ce8fd53a4cd750942db35332c34ba856559c1bfa53f33e82777a8b88b08eec74fda9921e2e
6
+ metadata.gz: 6e440fc7cc28cf50d1817e5a7bf9d04b3a4e0cb7fc85708f8b7820b1a239305494015e487fbfd3417e24cfe3198ee40507daa709e66267913569f08f7df94a4a
7
+ data.tar.gz: c3f9943e6016f805f6f2340065ab703c30d96b8130be5369b6095814f6c68b248d4a586dda1a35d9554294ba449698ac18a0e4817b4402a103f69752efe481bc
@@ -14,14 +14,25 @@ module GraphQL
14
14
  private
15
15
 
16
16
  def has_nested_spread(fragment_def, parent_fragment_names, context)
17
- nested_spreads = fragment_def.selections
18
- .select {|f| f.is_a?(GraphQL::Language::Nodes::FragmentSpread)}
17
+ nested_spreads = get_spreads(fragment_def.selections)
19
18
 
20
19
  nested_spreads.any? do |spread|
21
20
  nested_def = context.fragments[spread.name]
22
21
  parent_fragment_names.include?(spread.name) || has_nested_spread(nested_def, parent_fragment_names + [fragment_def.name], context)
23
22
  end
24
23
  end
24
+
25
+ # Find spreads contained in this selection & return them in a flat array
26
+ def get_spreads(selection)
27
+ case selection
28
+ when GraphQL::Language::Nodes::FragmentSpread
29
+ [selection]
30
+ when GraphQL::Language::Nodes::Field, GraphQL::Language::Nodes::InlineFragment
31
+ get_spreads(selection.selections)
32
+ when Array
33
+ selection.map { |s| get_spreads(s) }.flatten
34
+ end
35
+ end
25
36
  end
26
37
  end
27
38
  end
@@ -1,3 +1,3 @@
1
1
  module GraphQL
2
- VERSION = "0.18.12"
2
+ VERSION = "0.18.13"
3
3
  end
@@ -6,7 +6,9 @@ describe GraphQL::StaticValidation::FragmentsAreFinite do
6
6
  cheese(id: 1) {
7
7
  ... idField
8
8
  ... sourceField
9
- ... flavorField
9
+ similarCheese {
10
+ ... flavorField
11
+ }
10
12
  }
11
13
  }
12
14
 
@@ -17,7 +19,9 @@ describe GraphQL::StaticValidation::FragmentsAreFinite do
17
19
  }
18
20
  fragment flavorField on Cheese {
19
21
  flavor,
20
- ... sourceField
22
+ similarCheese {
23
+ ... sourceField
24
+ }
21
25
  }
22
26
  fragment idField on Cheese {
23
27
  id
@@ -32,12 +36,12 @@ describe GraphQL::StaticValidation::FragmentsAreFinite do
32
36
  expected = [
33
37
  {
34
38
  "message"=>"Fragment sourceField contains an infinite loop",
35
- "locations"=>[{"line"=>10, "column"=>5}],
39
+ "locations"=>[{"line"=>12, "column"=>5}],
36
40
  "path"=>["fragment sourceField"],
37
41
  },
38
42
  {
39
43
  "message"=>"Fragment flavorField contains an infinite loop",
40
- "locations"=>[{"line"=>15, "column"=>5}],
44
+ "locations"=>[{"line"=>17, "column"=>5}],
41
45
  "path"=>["fragment flavorField"],
42
46
  }
43
47
  ]
@@ -39,7 +39,9 @@ describe GraphQL::StaticValidation::Validator do
39
39
  }
40
40
  }
41
41
  fragment cheeseFields on Cheese {
42
- id, ... cheeseFields
42
+ ... on Cheese {
43
+ id, ... cheeseFields
44
+ }
43
45
  }
44
46
  |}
45
47
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.12
4
+ version: 0.18.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo