graphql 0.18.12 → 0.18.13
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ede8bf16e041625d9150b4a02ca1203e5f77f67
|
4
|
+
data.tar.gz: be963dcb88acc294fd826798a1d1e480d3abb8f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/graphql/version.rb
CHANGED
@@ -6,7 +6,9 @@ describe GraphQL::StaticValidation::FragmentsAreFinite do
|
|
6
6
|
cheese(id: 1) {
|
7
7
|
... idField
|
8
8
|
... sourceField
|
9
|
-
|
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
|
-
|
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"=>
|
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"=>
|
44
|
+
"locations"=>[{"line"=>17, "column"=>5}],
|
41
45
|
"path"=>["fragment flavorField"],
|
42
46
|
}
|
43
47
|
]
|