Skip to content

Feature Request: Add Support for Bun SQL Driver in PostGraphile #2828

@zuohuadong

Description

@zuohuadong

Feature description

Add support for Bun's native SQL driver (Bun.SQL) in PostGraphile. This would allow PostGraphile to leverage Bun's high-performance database connectivity when running in the Bun runtime environment.

Bun.SQL is a unified SQL API introduced in Bun 1.2+ that provides native database connectivity for PostgreSQL, MySQL, and SQLite with significantly better performance than traditional Node.js database drivers.

Key aspects of this feature:

  • Integration of Bun.SQL as an alternative database driver option in PostGraphile
  • Support for PostgreSQL through Bun's native implementation
  • Leverage Bun's performance advantages for database operations
  • Maintain compatibility with existing PostGraphile features while using the Bun driver

Motivating example

Performance Benefits:
According to Bun's benchmarks, Bun.SQL demonstrates substantial performance improvements:

  • Up to 6x faster than Node.js postgres package for high-concurrency workloads
  • Lower latency and higher throughput in database operations
  • More efficient memory usage compared to traditional drivers

Development Experience:

  • Unified development stack when using Bun as the runtime
  • Simplified dependency management by using Bun's built-in capabilities
  • Better integration with Bun's tooling ecosystem

Use Cases:

  1. High-performance applications that require maximum database throughput
  2. Bun-based projects seeking to leverage native capabilities
  3. New greenfield projects using modern JavaScript runtimes

Breaking changes

This feature should not introduce breaking changes to existing PostGraphile installations. It would be implemented as:

  • An optional driver that only activates when explicitly configured
  • Additional configuration option for the database connection
  • Fallback to existing drivers when not using Bun runtime

Potential considerations:

  • Feature parity verification between Bun.SQL and existing PostgreSQL drivers
  • Testing across different Bun versions to ensure compatibility
  • Handling of Bun-specific connection parameters and configuration

https://bun.com/docs/runtime/sql

Supporting development

I [tick all that apply]:

  • am interested in building this feature myself
  • am interested in collaborating on building this feature
  • am willing to help testing this feature before it's released
  • am willing to write a test-driven test suite for this feature (before it exists)
  • am a Graphile sponsor ❤️
  • have an active support or consultancy contract with Graphile

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions