A comprehensive .NET GraphQL library providing a complete GraphQL implementation for .NET applications.
- 🚀 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
Package | Description |
---|---|
Tanka.GraphQL |
Core execution engine |
Tanka.GraphQL.Language |
Parser and AST |
Tanka.GraphQL.Server |
ASP.NET Core server |
Tanka.GraphQL.Server.SourceGenerators |
Code generation |
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:
- HTTP & WebSocket Server - Complete server setup
- Source Generation - Code-first development
- Apollo Federation v2.3 - Federated subgraph with @link directives
- Incremental Delivery - @defer/@stream examples
- Tanka Chat - Real-world application
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
-
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();
-
Test your GraphQL endpoint:
curl -X POST http://localhost:5000/graphql \ -H "Content-Type: application/json" \ -d '{"query": "{ greeting(name: \"World\") }"}'
Run benchmarks to see Tanka GraphQL performance:
cd benchmarks/GraphQL.Benchmarks
dotnet run --configuration Release --framework net9.0
- .NET 9.0 or later
- ASP.NET Core 9.0 (for server features)
We welcome contributions! Please see our contribution guidelines for details.
This project is licensed under the MIT License - see the LICENSE file for details.