-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathTypedGraph.cs
More file actions
44 lines (37 loc) · 1.06 KB
/
TypedGraph.cs
File metadata and controls
44 lines (37 loc) · 1.06 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
using GraphQL.Types;
public class TypedGraph
{
#region typedGraph
public class CompanyGraph :
EfObjectGraphType<MyDbContext,Company>
{
public CompanyGraph(IEfGraphQLService<MyDbContext> graphQlService) :
base(graphQlService)
{
AddNavigationListField(
name: "employees",
projection: _ => _.Employees,
resolve: _ => _.Projection);
AddNavigationConnectionField(
name: "employeesConnection",
projection: _ => _.Employees,
resolve: _ => _.Projection);
AutoMap();
}
}
#endregion
public class Company
{
public object? Id { get; set; }
public object? Content { get; set; }
public List<Employee> Employees { get; set; } = null!;
}
public class Employee;
public class MyDbContext :
DbContext
{
public IQueryable<Company> Companies { get; set; } = null!;
}
public class EmployeeGraph :
ObjectGraphType<Employee>;
}