Postrust vs PostGraphile
PostGraphile generates a GraphQL API from a PostgreSQL schema and puts most of its effort into the quality of that schema and the plan behind it. V5's Gra*fast* engine plans a query once and executes it with far fewer round trips than a naive resolver tree.
It is also the most customisable of these tools. If you want to reshape the generated schema, PostGraphile expects that and has a plugin system built for it.
- PostGraphile is written in
- TypeScript / Node.js
- Licence
- MIT
- Version compared
- V5
- Their site
- postgraphile.org
Feature comparison
Where a capability has a condition attached, the condition is in the cell.
| Feature | Postrust | PostGraphile |
|---|---|---|
| GraphQL from the schema | Yes | Yes |
| REST API | Yes, PostgREST-compatible | Not supported |
| Subscriptions | Over LISTEN/NOTIFY | Built in over LISTEN/NOTIFY; you define the fields |
| Schema customisation | Not extensible at runtime | Plugin system, the main design goal |
| Relay support | No | Yes |
| Permissions | PostgreSQL roles and RLS | PostgreSQL roles and RLS |
| Runtime | Single static binary | Node.js |
| Custom logic | Rust handlers, or SQL functions | TypeScript plugins, or SQL functions |
| License | MIT | MIT |
When PostGraphile is the better choice
- You want to shape the GraphQL schema rather than accept what was generated. This is PostGraphile's central strength and Postrust has no answer to it.
- Your team writes TypeScript and wants API extensions in the same language as the rest of the stack.
- You want a Relay-compliant schema, or the connection and node-id conventions that come with it.
- GraphQL is the API and REST is not needed.
When Postrust fits better
- You want one process serving both REST and GraphQL.
- You would rather deploy a static binary than a Node runtime.
- The generated schema is fine as generated and extensibility is not what you are paying for.
Questions
Why do the GraphQL queries differ between the two in the benchmark?
Field names are inflected differently: Postrust exposes bench_items where PostGraphile exposes allBenchItems with a nodes wrapper. The request asks PostgreSQL for the same rows either way, and both queries are in the benchmark script.
Is Gra*fast* faster than what Postrust does?
Look at the measured table on this page rather than taking either project's word for it. Gra*fast* is a serious piece of engineering and the numbers are the numbers.
Try it against your own schema
Point it at a database and see what it generates. That is a shorter path than reading a comparison table.