crystal
🔮 Graphile's Crystal Monorepo; home to Grafast, PostGraphile, pg-introspection, pg-sql2 and much more!
A monorepo of TypeScript tools for building GraphQL APIs, featuring PostGraphile which auto-generates a full GraphQL API from your PostgreSQL database schema.
This is a monorepo, which means it is a single code repository that contains many individual packages. All of them are connected by a shared theme: they help developers build GraphQL APIs, which are a way for software applications to request and send data in a structured manner. The repository is maintained by the Graphile project and written primarily in TypeScript.
The two most prominent packages here are Grafast and PostGraphile. Grafast is an execution engine for GraphQL, meaning it handles the job of running GraphQL queries as efficiently as possible. Instead of using the standard approach, Grafast lets developers describe what data their code needs in advance so the engine can plan the most efficient way to fetch it, which reduces unnecessary work on the server.
PostGraphile is the other headline tool. If you have a PostgreSQL database (a widely used type of database for storing structured data), PostGraphile can automatically generate a full GraphQL API on top of it with very little setup. The idea is that your database schema already defines your data structure, so PostGraphile reads that structure and builds the API for you. You can still customize and extend what it generates.
Beyond those two, the monorepo includes a range of supporting packages. Some help build database queries safely, some handle configuration and plugins shared across Graphile tools, and others assist with testing and code export. A package called pg-sql2 helps write PostgreSQL queries using a pattern that prevents a common security problem called SQL injection. Another, pg-introspection, reads the internal structure of a PostgreSQL database programmatically.
The project is crowd-funded and supported by sponsors. It is open source and targeted at developers building data-heavy applications where API performance and database integration matter. If you are a non-developer, this repository would mainly be relevant as background context for why a technical team might adopt these tools.
Where it fits
- Automatically generate a full GraphQL API from your existing PostgreSQL database with minimal setup.
- Build high-performance GraphQL APIs that plan and batch database queries for efficiency.
- Write SQL queries safely in Node.js without SQL injection risk using the pg-sql2 package.