-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stitch federation schemas via _entities. (#65)
- Loading branch information
Showing
5 changed files
with
403 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
require_relative "../../schemas/federation" | ||
|
||
describe "GraphQL::Stitching::Federation" do | ||
|
||
def test_federation_to_stitching | ||
@supergraph = compose_definitions({ | ||
"federation" => Schemas::Federation::Federation1, | ||
"stitching" => Schemas::Federation::Stitching, | ||
}) | ||
|
||
query = %| | ||
query { | ||
widgets(upcs: ["1"]) { | ||
megahertz | ||
model | ||
sprockets { | ||
cogs | ||
diameter | ||
} | ||
} | ||
} | ||
| | ||
|
||
expected = { | ||
"data" => { | ||
"widgets" => [{ | ||
"megahertz" => 3, | ||
"model" => "Basic", | ||
"sprockets" => [ | ||
{ "cogs" => 23, "diameter" => 77 }, | ||
{ "cogs" => 14, "diameter" => 20 }, | ||
], | ||
}], | ||
}, | ||
} | ||
|
||
result = plan_and_execute(@supergraph, query) do |plan| | ||
assert_equal ["stitching", "federation", "stitching"], plan.operations.map(&:location) | ||
end | ||
|
||
assert_equal expected, result | ||
end | ||
|
||
def test_federation_to_federation | ||
@supergraph = compose_definitions({ | ||
"federation1" => Schemas::Federation::Federation1, | ||
"federation2" => Schemas::Federation::Federation2, | ||
}) | ||
|
||
query = %| | ||
query { | ||
widget { | ||
megahertz | ||
model | ||
sprockets { | ||
cogs | ||
diameter | ||
} | ||
} | ||
} | ||
| | ||
|
||
expected = { | ||
"data" => { | ||
"widget" => { | ||
"megahertz" => 3, | ||
"model" => "Basic", | ||
"sprockets" => [ | ||
{ "cogs" => 23, "diameter" => 77 }, | ||
{ "cogs" => 14, "diameter" => 20 }, | ||
], | ||
}, | ||
}, | ||
} | ||
|
||
result = plan_and_execute(@supergraph, query) do |plan| | ||
assert_equal ["federation2", "federation1", "federation2"], plan.operations.map(&:location) | ||
end | ||
|
||
assert_equal expected, result | ||
end | ||
end |
Oops, something went wrong.