Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (46 loc) · 1.57 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (46 loc) · 1.57 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
#:package HotChocolate.AspNetCore@16.1.3
#:package HotChocolate.Types.Analyzers@16.1.3
using HotChocolate;
using HotChocolate.Execution;
using HotChocolate.Types;
using HotChocolateBatchResolverBug;
using Microsoft.Extensions.DependencyInjection;
[assembly: Module("BugTypes")]
var executor = await new ServiceCollection()
.AddGraphQL()
.AddQueryType<Query>()
.AddBugTypes()
.BuildRequestExecutorAsync();
Console.WriteLine("Test 1: Sync parent");
await executor.ExecuteAsync("{ syncParents { children { computed } } }");
Console.WriteLine(" OK\n");
Console.WriteLine("Test 2: Async parent (1 item)");
await executor.ExecuteAsync("{ asyncParent { children { computed } } }");
Console.WriteLine(" OK\n");
Console.WriteLine("Test 3: Async parent (2 items) - will hang");
await executor.ExecuteAsync("{ asyncParents { children { computed } } }");
Console.WriteLine(" OK"); // Never reached
namespace HotChocolateBatchResolverBug
{
public class Query
{
public List<SyncParent> SyncParents => [new(), new()];
public AsyncParent AsyncParent => new();
public List<AsyncParent> AsyncParents => [new(), new()];
}
public record SyncParent
{
public List<Child> Children => [new()];
}
public record AsyncParent
{
public Task<List<Child>> Children => Task.FromResult<List<Child>>([new()]);
}
public record Child;
[ObjectType<Child>]
public static partial class ChildNode
{
[BatchResolver]
public static List<string> GetComputed([Parent] List<Child> c) => [.. c.Select(_ => "x")];
}
}