Getting started with
GraphQL on ASP.NET Core
Michael Staib
14:00 Hello, Intro, Tech Check
14:25 What is GraphQL?
14:50 BREAK (10 minutes)
15:00 GraphQL Queries
15:50 BREAK (10 minutes)
16:00 Building a GraphQL Server
16:50 BREAK (10 minutes)
17:00 Building a GtaphQL Client
18:00 FINISH
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
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
DDC Workshop - Getting started with GraphQL on ASP.NET Core and Hot Chocolate
By Michael Ingmar Staib
DDC Workshop - Getting started with GraphQL on ASP.NET Core and Hot Chocolate
- 619