Skip to main content

Data Provider System

The provider system in the @repo/data package offers a collection of data providers that implement the CrudProvider interface for various data sources. This allows you to interact with different backends using a consistent API.

Available Providers

The package includes providers for various data sources:
  • Supabase: For PostgreSQL databases with Supabase
  • Firebase: For Firebase Realtime Database and Firestore
  • REST API: For RESTful APIs
  • GraphQL: For GraphQL APIs
  • Mock: For testing and development

Supabase Provider

The Supabase provider allows you to connect to a PostgreSQL database using Supabase.

Configuration

Usage

Advanced Features

The Supabase provider supports advanced features like:
  • Relations: Automatically fetch related data
  • RLS Policies: Work with Row Level Security policies
  • Full-text Search: Use Supabase’s full-text search capabilities
  • Realtime: Subscribe to realtime updates

Firebase Provider

The Firebase provider allows you to connect to Firebase Realtime Database or Firestore.

Configuration

Usage

Advanced Features

The Firebase provider supports advanced features like:
  • Subcollections: Work with nested collections
  • Transactions: Perform atomic operations
  • Realtime Updates: Subscribe to realtime updates

REST API Provider

The REST API provider allows you to connect to a RESTful API.

Configuration

Usage

Custom Endpoints

The REST provider allows you to customize the endpoints for each operation:

Request Transformation

You can customize how requests are transformed:

GraphQL Provider

The GraphQL provider allows you to connect to a GraphQL API.

Configuration

Usage

Custom Queries

The GraphQL provider allows you to customize the queries for each operation:

Mock Provider

The Mock provider is useful for testing and development.

Configuration

Usage

Customizing Behavior

You can customize the behavior of the mock provider:

Creating Custom Providers

You can create custom providers by implementing the CrudProvider interface:

Provider Composition

You can compose multiple providers together to add cross-cutting concerns:

API Reference

For a complete API reference, please refer to the TypeScript definitions in the package.