forked from SimonCropp/GraphQL.EntityFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectionRootQuery.cs
More file actions
31 lines (26 loc) · 783 Bytes
/
ConnectionRootQuery.cs
File metadata and controls
31 lines (26 loc) · 783 Bytes
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
class ConnectionRootQuery
{
#region ConnectionRootQuery
public class Query :
QueryGraphType<MyDbContext>
{
public Query(IEfGraphQLService<MyDbContext> graphQlService)
:
base(graphQlService) =>
AddQueryConnectionField<Company>(
name: "companies",
resolve: _ => _.DbContext.Companies.OrderBy(_ => _.Name));
}
#endregion
public class Company
{
public string Name { get; set; } = null!;
}
class CompanyGraph(IEfGraphQLService<MyDbContext> efGraphQlService) :
EfObjectGraphType<MyDbContext, Company>(efGraphQlService);
public class MyDbContext :
DbContext
{
public DbSet<Company> Companies { get; set; } = null!;
}
}