GraphQL with .NET: Hot Chocolate Library

Hot Chocolate is the most popular GraphQL library for .NET. Here’s a quick start.

Setup

services.AddGraphQLServer()
    .AddQueryType<Query>()
    .AddMutationType<Mutation>();

Query Type

public class Query
{
    public IQueryable<Book> GetBooks([Service] AppDbContext ctx) 
        => ctx.Books;
}

References


Discover more from C4: Container, Code, Cloud & Context

Subscribe to get the latest posts sent to your email.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.