Getting started with
GraphQL on ASP.NET Core
Michael Staib
09:00 Hello, Intro, Tech Check
09:25 What is GraphQL?
09:50 BREAK (10 minutes)
10:00 GraphQL Queries
10:50 BREAK (20 minutes)
11:10 Building a GraphQL Server
12:00 BREAK (10 minutes)
12:10 DataLoader
13:00 LUNCH
14:00 Schema Design
14:50 BREAK (10 minutes)
15:00 Middleware, Pagination and Filtering
15:50 BREAK (20 minutes)
16:10 GraphQL Subscriptions
16:30 Putting GraphQL to Production
17:00 FINISH
Let us get our machines ready.
https://bit.ly/30Vtjdq
{
me {
name
}
}
{
"me": {
"name": "Michael Staib"
}
}
{
me {
name
}
}
{
me {
name
image {
width
height
url
}
}
}
{
"me": {
"name": "Michael Staib",
"image": {
"width": 200,
"height": 300,
"url": "http://some/images/123.png"
}
}
}
{
me {
name
image {
width
height
url
}
}
}
{
me {
name
lastSeen
friends {
name
lastSeen
}
}
}
{
"me": {
"name": "Michael Staib",
"lastSeen": "2018-05-19T18:45",
"friends": [
{
"name": "Rafael Staib",
"lastSeen": "2018-05-24T12:37"
},
{
"name": "Pascal Senn",
"lastSeen": "2018-06-07T17:13"
}
]
}
}
{
me {
name
lastSeen
friends {
name
lastSeen
}
}
}
{
"me": {
"name": "Michael Staib",
"lastSeen": "2018-05-19T18:45",
"friends": [
{
"name": "Rafael Staib",
"lastSeen": "2018-05-24T12:37"
},
{
"name": "Pascal Senn",
"lastSeen": "2018-06-07T17:13"
}
]
}
}
{
me {
... PersonInfo
friends {
... PersonInfo
}
}
}
fragment PersonInfo on Person {
name
lastSeen
}
- One Endpoint
- One Request
- No over- or under-fetching
- Type System
- Predictable
DataLoader
Understanding Field Middleware
[UseApplicationDbContext]
[UsePaging]
public IQueryable<Attendee> GetAttendees(
[ScopedService] ApplicationDbContext context) =>
context.Attendees;
protected override void Configure(
IObjectTypeDescriptor<Query> descriptor)
{
descriptor
.Field(t => t.GetSessions())
.UsePaging();
}
descriptor.Use(next => async context =>
{
// logic
await next(context);
// more logic
})
https://chillicream.com
https://github.com/chillicream/hotchocolate
Workshop - Getting started with GraphQL on ASP.NET Core and Hot Chocolate
By Michael Ingmar Staib
Workshop - Getting started with GraphQL on ASP.NET Core and Hot Chocolate
- 750