-
-
Notifications
You must be signed in to change notification settings - Fork 804
Expand file tree
/
Copy pathQueryDocumentRewriterTests.cs
More file actions
64 lines (54 loc) · 1.64 KB
/
QueryDocumentRewriterTests.cs
File metadata and controls
64 lines (54 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using HotChocolate.Execution;
using HotChocolate.Language;
using HotChocolate.Language.Utilities;
using HotChocolate.StarWars;
using Microsoft.Extensions.DependencyInjection;
namespace StrawberryShake.CodeGeneration.Utilities;
public class QueryDocumentRewriterTests
{
[Fact]
public async Task GetReturnTypeName()
{
// arrange
var schema =
await new ServiceCollection()
.AddStarWarsRepositories()
.AddGraphQL()
.AddStarWars()
.BuildSchemaAsync();
schema =
SchemaHelper.Load(
[
new(schema.ToSyntaxNode()),
new(Utf8GraphQLParser.Parse("extend schema @key(fields: \"id\")"))
]);
var document =
Utf8GraphQLParser.Parse(
"""
query GetHero {
hero(episode: NEW_HOPE) @returns(fragment: "Hero") {
... Characters
}
}
fragment Characters on Character {
... Human
... Droid
}
fragment Hero on Character {
name
}
fragment Human on Human {
... Hero
homePlanet
}
fragment Droid on Droid {
... Hero
primaryFunction
}
""");
// act
document = QueryDocumentRewriter.Rewrite(document, schema);
// assert
document.Print().MatchSnapshot();
}
}