Skip to content

Commit

Permalink
test error repathing.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmac committed Feb 11, 2024
1 parent 84098df commit 0f618a3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/graphql/stitching/integration/nested_root_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,25 @@ def test_nested_root_scopes_with_complex_paths
result = plan_and_execute(@supergraph, source)
assert_equal expected, result["data"]
end

def test_nested_root_scopes_repath_errors
source = %|
mutation {
doThing {
query {
errorA
errorB
}
}
}
|

expected = [
{ "message" => "a", "path" => ["doThing", "query", "errorA"] },
{ "message" => "b", "path" => ["doThing", "query", "errorB"] },
]

result = plan_and_execute(@supergraph, source)
assert_equal expected, result["errors"]
end
end
16 changes: 16 additions & 0 deletions test/schemas/nested_root.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ module NestedRoot
class Alpha < GraphQL::Schema
class Query < GraphQL::Schema::Object
field :apple, String, null: false
field :error_a, String, null: false

def apple
"red"
end

def error_a
raise GraphQL::ExecutionError.new("a")
end
end

class Thing < GraphQL::Schema::Object
Expand All @@ -26,6 +31,12 @@ def do_stuff
{}
end

field :do_thing, Thing, null: false

def do_thing
{}
end

field :do_things, [Thing], null: false

def do_things
Expand All @@ -40,10 +51,15 @@ def do_things
class Bravo < GraphQL::Schema
class Query < GraphQL::Schema::Object
field :banana, String, null: false
field :error_b, String, null: false

def banana
"yellow"
end

def error_b
raise GraphQL::ExecutionError.new("b")
end
end

query Query
Expand Down

0 comments on commit 0f618a3

Please sign in to comment.