toni
GraphQL

GraphQL Overview

Toni offers two official GraphQL integrations — choose based on your schema style.

Toni ships with two GraphQL integrations as separate crates. Both integrate fully with the DI system, lifecycle hooks, guards, and interceptors.

Choosing an integration

toni-async-graphqltoni-juniper
Libraryasync-graphqlJuniper
Context typeType-erased (Data container)Concrete, user-defined struct
Schema styleCode-first via macrosCode-first via macros
Best forFlexible context, large teamsType-safe context, smaller teams

Both support:

  • Schema-first execution (POST + GET /graphql)
  • Built-in GraphQL Playground (disable in production)
  • Guards and interceptors on the GraphQL endpoint
  • Injecting Toni services into resolvers via the DI container

Common architecture

Both integrations expose a GraphQLModule dynamic module that registers:

  • A GraphQLController handling /graphql (configurable path)
  • A GraphQLService for executing queries
  • Context building infrastructure

Your resolvers access services through the GraphQL context, which is populated by a ContextBuilder you provide.

Sections

On this page