Baeta Documentation

website·Indexed 31 days ago

https://baeta.io

Documentation for Baeta (Version Next 2.x), a framework for building type-safe GraphQL APIs. It features a module-based system for bundling schemas and generated TypeScript types, support for Apollo Federation, Relay-style pagination, Prisma integration, and a typed PubSub system for subscriptions.

Tokens
175.3K
Snippets
1.3K
Records
1.6K
Agent score
52%

What's inside Baeta

  1. Overview of Baeta Context Stores

    A context store is a typed, request-scoped slot on the context that loads its value lazily and memoizes the result for the duration of a single request. It is used to share per-request data (e.g., current user, active organization, tenant config) between resolvers without polluting the Context type with optional fields or executing expensive queries for every request.
  2. Overview of Baeta GraphQL Framework

    Baeta is a schema-first, type-safe GraphQL framework for building modular APIs. It allows developers to describe APIs using GraphQL SDL and implement resolvers against generated types. Key architectural features include:

    • Modular Design: Large schemas can be split across modules, where each module manages its own types, resolvers, and tests.
    • Opt-in Features: Advanced functionality such as authorization, complexity limits, caching, federation, and pagination are provided as separate, optional packages.
    • Runtime Agnostic: The runtime is small and environment-agnostic, producing a standard GraphQLSchema compatible with servers like Yoga, Apollo, and Mercurius.
  3. Overview of the Baeta GraphQL Framework

    Baeta is a modular, open-source GraphQL framework designed for building scalable APIs with minimal boilerplate. It utilizes a schema-first approach and a granular architecture, allowing developers to start with a core API and progressively add functionality via official extensions. Key features include automatic code generation for type safety, middleware/directive support, and a modular organization system.
  4. Overview of @baeta/cache

    @baeta/cache is a typed cache layer for resolvers. It allows developers to declare queries using defineQuery and connect them to a storage adapter. The library handles serialization, key derivation, and automatic invalidation/reconciliation when underlying data is mutated.
  5. Overview of Baeta Context Store

    Context Store is a feature in Baeta (v1.x) designed to manage request-scoped data. It solves common GraphQL API problems by providing:

    1. Improved Type Safety: Allows distinct types for authenticated vs. public routes (e.g., avoiding constant null checks for users).
    2. Lazy Loading: Data is only fetched from the database when explicitly requested in a resolver.
    3. Request-Scoped Caching: Results are cached for the duration of a single request, preventing redundant database queries for the same data.
  6. Use the Box component for CLI layout

    The <Box> component is a fundamental layout primitive in Ink. It functions similarly to a <div> with display: flex in a web browser, allowing developers to structure and align elements within a command-line interface.
    import {Box} from 'ink';
    
    const MyComponent = () => (
    	<Box>
    		{/* Layout content goes here */}
    	</Box>
    );
  7. Understand how the Gitignore plugin manages files

    The Gitignore plugin automates repository maintenance by performing the following actions:

    1. Detects all files generated by other Baeta plugins.
    2. Adds the appropriate entries to the .gitignore file.
    3. Updates the .gitignore file automatically whenever the configuration changes.
  8. Use ResolveOptions to configure esbuild module resolution

    The ResolveOptions interface defines the properties available when implementing a resolve plugin in esbuild. These properties provide context about the file being resolved, such as the importer's path, the type of import, and plugin-specific data.
    interface ResolveOptions {
      importer?: string;           // The path to the file that is importing the module
      kind?: ImportKind;           // The kind of import (e.g., 'js', 'json')
      namespace?: string;          // The namespace of the module
      pluginData?: any;            // Data passed from a previous plugin
      pluginName?: string;         // The name of the plugin that triggered the resolution
      resolveDir?: string;        // The directory where the resolution is taking place
      with?: Record<string, string>; // Additional metadata associated with the import
    }
  9. CacheClient Base Class Overview

    The CacheClient is an abstract base class used for implementing cache clients. It defines the standard interface for saving and deleting items and queries. It is extended by several specific implementations including CloudflareCacheClient, RedisCacheClient, ValkeyCacheClient, and UpstashCacheClient.
  10. Understand the esbuild ServeResult interface properties

    When using the esbuild serve API, the resulting ServeResult object contains information about the running development server, specifically the network addresses and the port it is listening on.
    interface ServeResult {
      hosts: string[]; // The list of hostnames/IPs the server is listening on
      port: number;    // The port number the server is using
    }
  11. Use ConfigProviderBase for configuration providing

    In Baeta SDK version 1.x, ConfigProviderBase is a type defined as a ProviderWrapped wrapper around ConfigProps. It is used to provide configuration properties within the SDK's provider architecture.
    // ConfigProviderBase is defined as:
    ProviderWrapped<ConfigProps>