|
52 | 52 | }
|
53 | 53 | |}
|
54 | 54 | it "the error is inserted into the errors key and the rest of the query is fulfilled" do
|
55 |
| - expected_result = { |
56 |
| - "data"=>{ |
57 |
| - "cheese"=>{ |
58 |
| - "id" => 1, |
59 |
| - "error1"=> nil, |
60 |
| - "error2"=> nil, |
61 |
| - "nonError"=> { |
62 |
| - "id" => 3, |
63 |
| - "flavor" => "Manchego", |
64 |
| - }, |
65 |
| - "flavor" => "Brie", |
66 |
| - }, |
67 |
| - "allDairy" => [ |
68 |
| - { "flavor" => "Brie" }, |
69 |
| - { "flavor" => "Gouda" }, |
70 |
| - { "flavor" => "Manchego" }, |
71 |
| - { "source" => "COW", "executionError" => nil }, |
72 |
| - { "source" => "COW", "executionError" => nil }, |
73 |
| - ], |
74 |
| - "dairyErrors" => [ |
75 |
| - { "__typename" => "Cheese" }, |
76 |
| - nil, |
77 |
| - { "__typename" => "Cheese" }, |
78 |
| - { "__typename" => "Milk" }, |
79 |
| - { "__typename" => "Milk" }, |
80 |
| - ], |
81 |
| - "dairy" => { |
82 |
| - "milks" => [ |
83 |
| - { |
84 |
| - "source" => "COW", |
85 |
| - "executionError" => nil, |
86 |
| - "allDairy" => [ |
87 |
| - { "__typename" => "Cheese" }, |
88 |
| - { "__typename" => "Cheese" }, |
89 |
| - { "__typename" => "Cheese" }, |
90 |
| - { "__typename" => "Milk", "origin" => "Antiquity", "executionError" => nil }, |
91 |
| - { "__typename" => "Milk", "origin" => "Modernity", "executionError" => nil }, |
92 |
| - ] |
93 |
| - } |
94 |
| - ] |
95 |
| - }, |
96 |
| - "executionError" => nil, |
97 |
| - "valueWithExecutionError" => 0 |
| 55 | + expected_data = { |
| 56 | + "cheese"=>{ |
| 57 | + "id" => 1, |
| 58 | + "error1"=> nil, |
| 59 | + "error2"=> nil, |
| 60 | + "nonError"=> { |
| 61 | + "id" => 3, |
| 62 | + "flavor" => "Manchego", |
98 | 63 | },
|
99 |
| - "errors"=>[ |
100 |
| - { |
101 |
| - "message"=>"No cheeses are made from Yak milk!", |
102 |
| - "locations"=>[{"line"=>5, "column"=>9}], |
103 |
| - "path"=>["cheese", "error1"] |
104 |
| - }, |
105 |
| - { |
106 |
| - "message"=>"No cheeses are made from Yak milk!", |
107 |
| - "locations"=>[{"line"=>8, "column"=>9}], |
108 |
| - "path"=>["cheese", "error2"] |
109 |
| - }, |
110 |
| - { |
111 |
| - "message"=>"There was an execution error", |
112 |
| - "locations"=>[{"line"=>22, "column"=>11}], |
113 |
| - "path"=>["allDairy", 3, "executionError"] |
114 |
| - }, |
115 |
| - { |
116 |
| - "message"=>"There was an execution error", |
117 |
| - "locations"=>[{"line"=>22, "column"=>11}], |
118 |
| - "path"=>["allDairy", 4, "executionError"] |
119 |
| - }, |
120 |
| - { |
121 |
| - "message"=>"missing dairy", |
122 |
| - "locations"=>[{"line"=>25, "column"=>7}], |
123 |
| - "path"=>["dairyErrors", 1] |
124 |
| - }, |
125 |
| - { |
126 |
| - "message"=>"There was an execution error", |
127 |
| - "locations"=>[{"line"=>31, "column"=>11}], |
128 |
| - "path"=>["dairy", "milks", 0, "executionError"] |
129 |
| - }, |
130 |
| - { |
131 |
| - "message"=>"There was an execution error", |
132 |
| - "locations"=>[{"line"=>36, "column"=>15}], |
133 |
| - "path"=>["dairy", "milks", 0, "allDairy", 3, "executionError"] |
134 |
| - }, |
135 |
| - { |
136 |
| - "message"=>"There was an execution error", |
137 |
| - "locations"=>[{"line"=>36, "column"=>15}], |
138 |
| - "path"=>["dairy", "milks", 0, "allDairy", 4, "executionError"] |
139 |
| - }, |
140 |
| - { |
141 |
| - "message"=>"There was an execution error", |
142 |
| - "locations"=>[{"line"=>41, "column"=>7}], |
143 |
| - "path"=>["executionError"] |
144 |
| - }, |
145 |
| - { |
146 |
| - "message"=>"Could not fetch latest value", |
147 |
| - "locations"=>[{"line"=>42, "column"=>7}], |
148 |
| - "path"=>["valueWithExecutionError"] |
149 |
| - }, |
150 |
| - ] |
| 64 | + "flavor" => "Brie", |
| 65 | + }, |
| 66 | + "allDairy" => [ |
| 67 | + { "flavor" => "Brie" }, |
| 68 | + { "flavor" => "Gouda" }, |
| 69 | + { "flavor" => "Manchego" }, |
| 70 | + { "source" => "COW", "executionError" => nil }, |
| 71 | + { "source" => "COW", "executionError" => nil }, |
| 72 | + ], |
| 73 | + "dairyErrors" => [ |
| 74 | + { "__typename" => "Cheese" }, |
| 75 | + nil, |
| 76 | + { "__typename" => "Cheese" }, |
| 77 | + { "__typename" => "Milk" }, |
| 78 | + { "__typename" => "Milk" }, |
| 79 | + ], |
| 80 | + "dairy" => { |
| 81 | + "milks" => [ |
| 82 | + { |
| 83 | + "source" => "COW", |
| 84 | + "executionError" => nil, |
| 85 | + "allDairy" => [ |
| 86 | + { "__typename" => "Cheese" }, |
| 87 | + { "__typename" => "Cheese" }, |
| 88 | + { "__typename" => "Cheese" }, |
| 89 | + { "__typename" => "Milk", "origin" => "Antiquity", "executionError" => nil }, |
| 90 | + { "__typename" => "Milk", "origin" => "Modernity", "executionError" => nil }, |
| 91 | + ] |
| 92 | + } |
| 93 | + ] |
| 94 | + }, |
| 95 | + "executionError" => nil, |
| 96 | + "valueWithExecutionError" => 0 |
151 | 97 | }
|
152 |
| - assert_equal(expected_result, result) |
| 98 | + |
| 99 | + expected_errors = [ |
| 100 | + { |
| 101 | + "message"=>"Could not fetch latest value", |
| 102 | + "locations"=>[{"line"=>42, "column"=>7}], |
| 103 | + "path"=>["valueWithExecutionError"] |
| 104 | + }, |
| 105 | + { |
| 106 | + "message"=>"No cheeses are made from Yak milk!", |
| 107 | + "locations"=>[{"line"=>5, "column"=>9}], |
| 108 | + "path"=>["cheese", "error1"] |
| 109 | + }, |
| 110 | + { |
| 111 | + "message"=>"No cheeses are made from Yak milk!", |
| 112 | + "locations"=>[{"line"=>8, "column"=>9}], |
| 113 | + "path"=>["cheese", "error2"] |
| 114 | + }, |
| 115 | + { |
| 116 | + "message"=>"There was an execution error", |
| 117 | + "locations"=>[{"line"=>22, "column"=>11}], |
| 118 | + "path"=>["allDairy", 3, "executionError"] |
| 119 | + }, |
| 120 | + { |
| 121 | + "message"=>"There was an execution error", |
| 122 | + "locations"=>[{"line"=>22, "column"=>11}], |
| 123 | + "path"=>["allDairy", 4, "executionError"] |
| 124 | + }, |
| 125 | + { |
| 126 | + "message"=>"missing dairy", |
| 127 | + "locations"=>[{"line"=>25, "column"=>7}], |
| 128 | + "path"=>["dairyErrors", 1] |
| 129 | + }, |
| 130 | + { |
| 131 | + "message"=>"There was an execution error", |
| 132 | + "locations"=>[{"line"=>31, "column"=>11}], |
| 133 | + "path"=>["dairy", "milks", 0, "executionError"] |
| 134 | + }, |
| 135 | + { |
| 136 | + "message"=>"There was an execution error", |
| 137 | + "locations"=>[{"line"=>36, "column"=>15}], |
| 138 | + "path"=>["dairy", "milks", 0, "allDairy", 3, "executionError"] |
| 139 | + }, |
| 140 | + { |
| 141 | + "message"=>"There was an execution error", |
| 142 | + "locations"=>[{"line"=>36, "column"=>15}], |
| 143 | + "path"=>["dairy", "milks", 0, "allDairy", 4, "executionError"] |
| 144 | + }, |
| 145 | + { |
| 146 | + "message"=>"There was an execution error", |
| 147 | + "locations"=>[{"line"=>41, "column"=>7}], |
| 148 | + "path"=>["executionError"] |
| 149 | + }, |
| 150 | + ] |
| 151 | + assert_equal(expected_data, result["data"]) |
| 152 | + # Different exec strategies may order errors differently: |
| 153 | + assert_equal( |
| 154 | + expected_errors.sort_by { |e| e["locations"].first.values }, |
| 155 | + result["errors"].sort_by { |e| e["locations"].first.values} |
| 156 | + ) |
153 | 157 | end
|
154 | 158 | end
|
155 | 159 |
|
|
0 commit comments