-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueries.cs
More file actions
61 lines (53 loc) · 1.42 KB
/
Queries.cs
File metadata and controls
61 lines (53 loc) · 1.42 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
using System.Collections.Generic;
using HotChocolate;
using HotChocolate.Data;
using HotChocolate.Types;
using System.Linq;
namespace ProjectionBug;
[ExtendObjectType(OperationTypeNames.Query)]
public class Queries
{
public class Base
{
public string C { get; set; }
}
public class ChildA : Base
{
public string A { get; set; }
}
public class ChildB : Base
{
public string B { get; set; }
}
public class ChildAType : ObjectType<ChildA>
{
protected override void Configure(IObjectTypeDescriptor<ChildA> descriptor)
{
descriptor.Field(_ => _.A).Type<NonNullType<StringType>>();
}
}
public class ChildBType : ObjectType<ChildB>
{
protected override void Configure(IObjectTypeDescriptor<ChildB> descriptor)
{
descriptor.Field(_ => _.B).Type<NonNullType<StringType>>();
}
}
public class UnionTestType : UnionType
{
protected override void Configure(IUnionTypeDescriptor descriptor)
{
base.Configure(descriptor);
descriptor.Name("UnionTestType");
descriptor.Type<ChildAType>();
descriptor.Type<ChildBType>();
}
}
[UseProjection]
[GraphQLType(typeof(ListType<UnionTestType>))]
public IQueryable<Base> GetUnionTest()
{
var types = new List<Base>();
return types.AsQueryable();
}
}