explaingit

graphile/crystal

12,923TypeScriptAudience · developerComplexity · 4/5Setup · moderate

TLDR

A monorepo of TypeScript tools for building GraphQL APIs, featuring PostGraphile which auto-generates a full GraphQL API from your PostgreSQL database schema.

Mindmap

mindmap
  root((graphile crystal))
    What it does
      GraphQL API builder
      Auto-gen from Postgres
      Efficient execution
    Key packages
      PostGraphile
      Grafast engine
      pg-sql2
      pg-introspection
    Tech stack
      TypeScript
      PostgreSQL
      GraphQL
    Use cases
      Auto-gen API
      Safe SQL queries
      Plugin extensions
    Audience
      Backend developers
      API engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Automatically generate a full GraphQL API from your existing PostgreSQL database with minimal setup.

USE CASE 2

Build high-performance GraphQL APIs that plan and batch database queries for efficiency.

USE CASE 3

Write SQL queries safely in Node.js without SQL injection risk using the pg-sql2 package.

Tech stack

TypeScriptGraphQLPostgreSQLNode.js

Getting it running

Difficulty · moderate Time to first run · 1h+

Requires a running PostgreSQL database, install specific packages from the monorepo rather than the whole repo.

In plain English

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.

Copy-paste prompts

Prompt 1
I have a PostgreSQL database with a users and posts table. Show me how to set up PostGraphile to generate a GraphQL API from it and run it locally.
Prompt 2
I'm using PostGraphile and want to add a custom mutation that isn't auto-generated from my schema. How do I extend the API with a plugin?
Prompt 3
How do I use pg-sql2 from the graphile/crystal monorepo to safely build a dynamic SQL query with user-provided filter values?
Prompt 4
I want to add row-level security to my PostGraphile API so users can only see their own data. Show me how to configure PostgreSQL RLS and wire it up.
Open on GitHub → Explain another repo

← graphile on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.