From 3498d90d46f352d685a70b2a02202009e9556de3 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 1 Nov 2016 17:57:46 -0700 Subject: [PATCH] Add failing test for fragment execution error path --- spec/graphql/execution_error_spec.rb | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/spec/graphql/execution_error_spec.rb b/spec/graphql/execution_error_spec.rb index 5119f50320..5c7331aaf4 100644 --- a/spec/graphql/execution_error_spec.rb +++ b/spec/graphql/execution_error_spec.rb @@ -185,4 +185,63 @@ assert_equal(expected_result, result) end end + + describe "fragment query when returned from a field" do + let(:query_string) {%| + query MilkQuery { + dairy { + ...Dairy + } + } + + fragment Dairy on Dairy { + milks { + source + executionError + allDairy { + __typename + ...Milk + } + } + } + + fragment Milk on Milk { + origin + executionError + } + |} + it "the error is inserted into the errors key and the rest of the query is fulfilled" do + expected_result = { + "data"=>{ + "dairy" => { + "milks" => [ + { + "source" => "COW", + "executionError" => nil, + "allDairy" => [ + { "__typename" => "Cheese" }, + { "__typename" => "Cheese" }, + { "__typename" => "Cheese" }, + { "__typename" => "Milk", "origin" => "Antiquity", "executionError" => nil } + ] + } + ] + } + }, + "errors"=>[ + { + "message"=>"There was an execution error", + "locations"=>[{"line"=>6, "column"=>11}], + "path"=>["dairy", "milks", 0, "executionError"] + }, + { + "message"=>"There was an execution error", + "locations"=>[{"line"=>11, "column"=>15}], + "path"=>["dairy", "milks", 0, "allDairy", 3, "executionError"] + } + ] + } + assert_equal(expected_result, result) + end + end end