# graphile-build-pg

> PostgreSQL plugins for Graphile Build - build a supercharged GraphQL schema by reflection over a PostgreSQL database and executed by Grafast.

Latest version **5.2.0** (published 2026-10-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install graphile-build-pg
pnpm add graphile-build-pg
yarn add graphile-build-pg
bun add graphile-build-pg
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.2.0 |
| Published | 2026-10-30 |
| First published | 2017-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 7 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 12934 |
| Author | Benjie Gillam |
| Maintainers | benjie |
| Keywords | graphile, graphql, engine, postgraphile, pg, postgres, postgresql, graphqljs, plugin, build, extension, graphite |

## Links

- npm: https://www.npmjs.com/package/graphile-build-pg
- Repository: https://github.com/graphile/crystal
- Homepage: https://graphile.org/graphile-build/
- Issues: https://github.com/graphile/crystal/issues
- npm.io page: https://npm.io/package/graphile-build-pg

## Dependencies (7)

- [debug](https://npm.io/package/debug.md) ^4.4.3
- [tslib](https://npm.io/package/tslib.md) ^2.8.1
- [pg-sql2](https://npm.io/package/pg-sql2.md) ^5.0.2
- [@types/node](https://npm.io/package/@types/node.md) ^22.19.1
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^9.0.2
- [graphile-config](https://npm.io/package/graphile-config.md) ^1.1.2
- [pg-introspection](https://npm.io/package/pg-introspection.md) ^1.0.2

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 5.2.0 (latest) — 2026-10-30
- 5.2.0-aardvark.next-20260928202932 (snapshot-next) — 2026-09-28
- 5.0.0-rc.8 (rc) — 2026-03-10
- 5.0.0-beta.47 (beta) — 2025-09-24
- 4.14.1 (next) — 2025-04-27
- 5.0.0-alpha.20 (alpha) — 2023-08-02
- 5.0.0-alpha.2 (prealpha) — 2023-05-03
- 4.3.2-beta.0 (ws) — 2019-02-19
- 4.1.1-canary.1 (canary) — 2018-12-11
- 5.1.5 — 2026-10-02
- 5.2.0-aardvark.next-20260925164249 — 2026-09-25
- 5.2.0-aardvark.next-20260922224416 — 2026-09-22
- 5.2.0-aardvark.next-20260919185130 — 2026-09-19
- 5.2.0-aardvark.next-20260918085327 — 2026-09-18
- 5.2.0-aardvark.next-20260910230054 — 2026-09-10
- … 251 more at https://npm.io/package/graphile-build-pg/versions

## README

# graphile-build-pg

[![GitHub Sponsors](https://img.shields.io/github/sponsors/benjie?color=ff69b4&label=github%20sponsors)](https://github.com/sponsors/benjie)
[![Discord chat room](https://img.shields.io/discord/489127045289476126.svg)](http://discord.gg/graphile)
[![Follow](https://img.shields.io/badge/BSky-@Graphile.org-006aff.svg)](https://bsky.app/profile/graphile.org)
[![Follow](https://img.shields.io/badge/Mastodon-@Graphile.fosstodon.org-6364ff.svg)](https://fosstodon.org/@graphile)

`graphile-build-pg` is a collection of [graphile-build][] plugins that extend
your GraphQL schema with types and fields based on the tables, views, functions
and other resources in your PostgreSQL database.

This is achieved by introspecting your database with [pg-introspection][] and
then building a [@dataplan/pg][] registry (composed of codecs, resources and
relations) for these entities. Then our plugins inspect this registry and
creates the relevant GraphQL types, fields, and [grafast][] plan resolver
functions. The result is a high-performance, powerful, auto-generated but highly
flexible GraphQL schema.

If you don't want to use your database introspection results to generate the
schema, you can instead build the registry yourself giving you full control over
what goes into your GraphQL API whilst still saving you significant effort
versus writing the schema without auto-generation.

`graphile-build-pg` is a core component of [PostGraphile][], a library that
helps you craft your ideal, incredibly performant, best practices GraphQL API
backed primarily by a PostgreSQL database with minimal developer effort.

<!-- SPONSORS_BEGIN -->

## Crowd-funded open-source software

To help us develop this software sustainably, we ask all individuals and
businesses that use it to help support its ongoing maintenance and development
via sponsorship.

### [Click here to find out more about sponsors and sponsorship.](https://www.graphile.org/sponsor/)

And please give some love to our featured sponsors 🤩:

<table><tr>
<td align="center"><a href="https://gosteelhead.com/"><img src="https://graphile.org/images/sponsors/steelhead.svg" width="90" height="90" alt="Steelhead" /><br />Steelhead</a> *</td>
</tr></table>

<em>\* Sponsors the entire Graphile suite</em>

<!-- SPONSORS_END -->

## About

Thanks to Gra*fast*'s query planning capabilities, the plugins in this package
do not exhibit the N+1 query problem common in many database-based GraphQL APIs;
for all but the flattest GraphQL queries these plugins typically significantly
outperform `DataLoader`-based solutions - and the more complex your GraphQL
query becomes the greater the benefit.

[postgraphile]: https://postgraphile.org
[graphile-build]: https://npmjs.com/package/graphile-build
[grafast]: https://grafast.org
[pg-introspection]: https://npmjs.com/package/pg-introspection
[@dataplan/pg]: https://grafast.org/grafast/step-library/dataplan-pg/

---
_Source: https://npm.io/package/graphile-build-pg · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
