-
-
Notifications
You must be signed in to change notification settings - Fork 761
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fusion] Migrated MergeSelectionSetRewriter Tests (#8040)
- Loading branch information
1 parent
31edeac
commit 39dc1ab
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...late/Fusion-vnext/test/Fusion.Utilities.Tests/Rewriters/MergeSelectionSetRewriterTests.cs
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,55 @@ | ||
using HotChocolate.Language; | ||
using HotChocolate.Types; | ||
using HotChocolate.Types.Mutable.Serialization; | ||
|
||
namespace HotChocolate.Fusion.Rewriters; | ||
|
||
public class MergeSelectionSetRewriterTests | ||
{ | ||
[Fact] | ||
public void Merge_Two_SelectionSets() | ||
{ | ||
// arrange | ||
var sourceText = FileResource.Open("schema1.graphql"); | ||
var schemaDefinition = SchemaParser.Parse(sourceText); | ||
var productType = (IObjectTypeDefinition)schemaDefinition.Types["Product"]; | ||
|
||
var selectionSet1 = Utf8GraphQLParser.Syntax.ParseSelectionSet( | ||
""" | ||
{ | ||
id | ||
name | ||
reviews { | ||
id | ||
} | ||
} | ||
"""); | ||
|
||
var selectionSet2 = Utf8GraphQLParser.Syntax.ParseSelectionSet( | ||
""" | ||
{ | ||
reviews { | ||
body | ||
} | ||
name | ||
} | ||
"""); | ||
|
||
// act | ||
var rewriter = new MergeSelectionSetRewriter(schemaDefinition); | ||
var rewritten = rewriter.Merge([selectionSet1, selectionSet2], productType); | ||
|
||
// assert | ||
rewritten.MatchInlineSnapshot( | ||
""" | ||
{ | ||
id | ||
name | ||
reviews { | ||
id | ||
body | ||
} | ||
} | ||
"""); | ||
} | ||
} |