Tanka GraphQL

August 15, 2025 ยท View on GitHub

A comprehensive .NET GraphQL library providing a complete GraphQL implementation for .NET applications.

โœจ Features

  • ๐Ÿš€ Execute queries, mutations and subscriptions - Full GraphQL operation support
  • ๐Ÿ” Comprehensive validation - Built-in GraphQL specification compliance
  • โšก Source code generation - Generate schema types from C# classes with source generators
  • ๐Ÿ“ Modern GraphQL parser - Fast parser for executable and type system documents
  • ๐Ÿ”— Delegate-based resolvers - Clean resolver implementation with middleware support
  • ๐Ÿ—๏ธ Middleware pipeline architecture - Modular schema building with extensible middleware stages
  • ๐ŸŒ ASP.NET Core server - HTTP/WebSocket transport with real-time subscriptions
  • ๐Ÿ”„ Apollo Federation v2.3 - Full spec compliance with @link directive and type aliasing support
  • ๐Ÿ“ก Real-time subscriptions - graphql-ws compatible WebSocket server
  • โญ๏ธ Incremental delivery - @defer and @stream directives for progressive data loading
  • ๐ŸŽฏ @oneOf directive - Polymorphic input types support (Stage 3 RFC)
  • ๐Ÿ”— Schema composition - @link directive processing for modular schema development

๐Ÿ“– Documentation

๐Ÿ“ฆ Packages

Nuget Nuget (with prereleases)

PackageDescription
Tanka.GraphQLCore execution engine
Tanka.GraphQL.LanguageParser and AST
Tanka.GraphQL.ServerASP.NET Core server
Tanka.GraphQL.Server.SourceGeneratorsCode generation

๐ŸŽฏ Examples

Quick Server Setup:

var builder = WebApplication.CreateBuilder(args);

builder.AddTankaGraphQL()
    .AddHttp()
    .AddWebSockets()
    .AddSchema("MyAPI", schema => {
        schema.Add("Query", new FieldsWithResolvers {
            { "hello: String!", () => "Hello World!" }
        });
    });

var app = builder.Build();
app.UseWebSockets();
app.MapTankaGraphQL("/graphql", "MyAPI");
app.Run();

Advanced Examples:

๐Ÿš€ Quick Start

Installation

Essential packages:

dotnet add package Tanka.GraphQL          # Core GraphQL execution
dotnet add package Tanka.GraphQL.Server   # ASP.NET Core server

Optional packages:

dotnet add package Tanka.GraphQL.Server.SourceGenerators    # Code generation
dotnet add package Tanka.GraphQL.Extensions.ApolloFederation # Federation support

Basic Usage

  1. Create a simple GraphQL server:

    var builder = WebApplication.CreateBuilder(args);
    
    builder.AddTankaGraphQL()
        .AddHttp()
        .AddSchema("Demo", schema => {
            schema.Add("Query", new FieldsWithResolvers {
                { "greeting(name: String!): String!", (string name) => $"Hello, {name}!" }
            });
        });
    
    var app = builder.Build();
    app.MapTankaGraphQL("/graphql", "Demo");
    app.Run();
    
  2. Test your GraphQL endpoint:

    curl -X POST http://localhost:5000/graphql \
      -H "Content-Type: application/json" \
      -d '{"query": "{ greeting(name: \"World\") }"}'
    

๐Ÿ‹๏ธ Performance

Run benchmarks to see Tanka GraphQL performance:

cd benchmarks/GraphQL.Benchmarks
dotnet run --configuration Release --framework net9.0

๐Ÿ”ง Requirements

  • .NET 9.0 or later
  • ASP.NET Core 9.0 (for server features)

๐Ÿค Contributing

We welcome contributions! Please see our contribution guidelines for details.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.