Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions spec/graphql/execution_error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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