Configuration
All configuration is done through baeta.ts using defineConfig.
Resolvers
Baeta provides a modular, type-safe approach to defining GraphQL resolvers. Let's look at how to implement User and Query resolvers.
Scalars
Baeta provides support for custom GraphQL scalars, allowing you to define any data type beyond the built-in primitives.
Custom Types
Baeta generates a src/modules/types.ts file that lets you customize the TypeScript types used throughout your resolvers. This file acts as the bridge between your application's types and the generated GraphQL types.
Middlewares
Baeta provides a middleware system that lets you run logic before and after resolvers. Middlewares use a builder pattern — you chain $use calls onto a field, follow with .resolve(), and then pass the result into $fields to register it on the type.
Context
Baeta allows you to define a shared context that's available throughout your resolvers and middlewares.
Application
This guide explains how to set up a Baeta application and integrate it with a GraphQL server.
Error Handling
Baeta provides a set of predefined GraphQL errors to handle common error scenarios in your application through the @baeta/errors package.
Subscriptions
Baeta provides type-safe real-time functionality through GraphQL subscriptions.
Interfaces & Unions
Baeta supports both GraphQL Interfaces and Unions. Interfaces allow you to define common fields that multiple types can share, while Unions let you combine different types into a single field.
Context Store
Context Store is a feature in Baeta that provides a pattern for managing request-scoped data with lazy loading and caching capabilities. It allows you to define values that can be loaded on-demand and cached throughout the request lifecycle, while maintaining full type safety.
Directives
Directives in Baeta allow you to modify the execution behavior of your GraphQL schema. They can be applied to various parts of your schema and provide a way to add metadata or transform data.
Input Directives
While GraphQL doesn't natively support modifying query arguments and inputs through directives, Baeta provides a utility called Input Directives that enables this functionality.
Typed PubSub
Baeta provides a type-safe wrapper around graphql-subscriptions PubSub system. This utility ensures that your subscription channels and their payloads are properly typed, helping catch potential errors at compile time.
Environment
Baeta provides a type-safe environment variable parser that helps you validate and transform environment variables at runtime while maintaining full type safety.