• Stars
    star
    12,430
  • Rank 2,465 (Top 0.05 %)
  • Language
    TypeScript
  • License
    Other
  • Created about 8 years ago
  • Updated 4 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ”ฎ Graphile's Crystal Monorepo; home to Grafast, PostGraphile, pg-introspection, pg-sql2 and much more!

PostGraphile

GitHub Sponsors Patreon sponsor button Discord chat room Package on npm MIT license Follow

Instant lightning-fast GraphQL API backed primarily by your PostgreSQL database. Highly customisable and extensible thanks to incredibly powerful plugin system. Formerly "PostGraphQL".

Documentation: graphile.org/postgraphile

Crowd-funded open-source software

To help us develop this software sustainably under the MIT license, 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.

And please give some love to our featured sponsors ๐Ÿคฉ:

Surge
Surge
*
The Guild
The Guild
*
Dovetail
Dovetail
*
Qwick
Qwick
*
Netflix
Netflix
*
Chad Furman
Chad Furman
*
Enzuzo
Enzuzo
*
Stellate
Stellate
*
Politics Rewired
Politics Rewired

* Sponsors the entire Graphile suite

About

GraphQL is a new way of communicating with your server. It eliminates the problems of over- and under-fetching, incorporates strong data types, has built-in introspection, documentation and deprecation capabilities, and is implemented in many programming languages. This all leads to gloriously low-latency user experiences, better developer experiences, and much increased productivity. Because of all this, GraphQL is typically used as a replacement for (or companion to) RESTful API services.

PostgreSQL is the self-proclaimed โ€œworldโ€™s most advanced open source database,โ€ with each new release bringing more amazing features and performance gains. Thinking of your database as a plain CRUD store is now an archaic viewpoint as modern PostgreSQL can do so much for you โ€” from authorization with Row-Level Security (RLS, introduced in PG9.5), through Foreign Data Wrappers (FDW), to real time notifications with LISTEN/NOTIFY.

PostGraphile pairs these two incredible technologies together, helping you not only build applications more rapidly, but to build lightning-fast applications. PostGraphile allows you to access the power of PostgreSQL through a well designed, extensible, customisable and incredibly performant GraphQL server. It automatically detects tables, columns, indexes, relationships, views, types, functions, comments, and more - providing a GraphQL server that is highly intelligent about your data, and that automatically updates itself without restarting when you change your database schema.

With PostGraphile, a well designed database schema should serve the basis for a well thought out API. PostgreSQL already has amazing authorization and relationship infrastructure, why duplicate that logic in a custom API? A PostGraphile API is likely to provide a more performant and standards compliant GraphQL API than any created in-house, and can be built in a fraction of the time. Focus on your product and let PostGraphile worry about the API layer. Once you need to expand beyond this, we have a powerful plugin system including many community contributed plugins. For a critical evaluation of PostGraphile to determine if it fits in your tech stack, read evaluating PostGraphile for your project.

Introduction

Watch a talk by the original author Caleb at GraphQL Summit for a walk-through of building an application with PostGraphile in under 7 minutes. This was using v2 (then called PostGraphQL); we're now up to v4 which has many more bells and whistles!

PostGraphile at GraphQL Summit

Hear from the current maintainer Benjie at GraphQL Finland about the benefits of Database-Driven GraphQL Development:

Database Driven GraphQL Development at GraphQL Finland

Usage

Documentation: graphile.org/postgraphile

You can use PostGraphile via the CLI, as a Node.js middleware, or use the GraphQL schema directly. Make sure to check out the full usage instructions on the documentation website. We also have a PostgreSQL schema design guide you can follow to build a fully functional PostGraphile API.

CLI

To get started you can install PostGraphile globally:

npm install -g postgraphile

โ€ฆand then just run it! By default, PostGraphile will connect to your local database at postgres://localhost:5432 and introspect the public schema. See the available CLI flags with:

postgraphile --help

When you're ready to use PostGraphile for your own project, you're advised to install it locally with yarn, and run it with npx:

yarn add postgraphile
npx postgraphile --help

macOS users: PostGraphile has used port 5000 by default for 5+ years; recently Apple decided to bind the AirPlay service to port 5000 causing a conflict. Please use the --port option to bind to a different port.

Middleware

You can also use PostGraphile as native HTTP, Connect, Express, or Koa (experimental) middleware, e.g.:

yarn add postgraphile
import { createServer } from 'http';
import postgraphile from 'postgraphile';

createServer(postgraphile());

Check out hapi-postgraphile if you're interested in using PostGraphile as a hapi server plugin.

Docker

To run via Docker, simply pass the CLI options to the Docker container:

docker pull graphile/postgraphile
docker run --init graphile/postgraphile --help

E.g. you might run this command (substituting the relevant variables):

docker run --init -p 5000:5000 graphile/postgraphile --connection postgres://POSTGRES_USER:POSTGRES_PASSWORD@POSTGRES_HOST:POSTGRES_PORT/POSTGRES_DATABASE --schema app_public --watch

macOS users: Please use a different port to avoid conflict with AirPlay.

Read More

Full documentation for PostGraphile is located at graphile.org/postgraphile.

PostGraphile features include:

Requirements

Full requirements are on the website, but a basic summary is:

  • Node v8.6+
  • PostgreSQL 9.6+ (officially; but currently works with 9.4+)
  • Linux, macOS or Windows

Caveats:

  • PostGraphile does not have automated tests on Windows, if you notice any issues please file them (or send a PR!)

Supporting PostGraphile

The fastest and easiest way you can help PostGraphile thrive is by sponsoring ongoing development and maintenance.

Want to help testing and developing PostGraphile? Check out the contributing document to get started quickly!

Commercial support, consultancy and development services are available direct from the maintainer; see Professional Services for more information, or get in touch!

The maintainer of this project is @Benjie - follow him on Twitter!

Thanks

Huge thanks to the individuals and companies who sponsor PostGraphile's development - their financial contributions enable more time to be spent on the project: from bug fixes, to code review, to new features! If you want to help the project advance more rapidly, please join them in supporting this project ๐Ÿ™

A humongous, heart-felt, thank you to the original author of PostGraphile - Caleb Meredith - for everything he put into PostGraphile! He's now graduated from the project and we all wish him the best for his future ventures!

Thanks also to the people working on PostgREST which was a huge inspiration for this project!

Thanks and enjoy ๐Ÿ‘

More Repositories

1

starter

Opinionated SaaS quick-start with pre-built user account and organization system for full-stack application development in React, Node.js, GraphQL and PostgreSQL. Powered by PostGraphile, TypeScript, Apollo Client, Graphile Worker, Graphile Migrate, GraphQL Code Generator, Ant Design and Next.js
TypeScript
1,715
star
2

worker

High performance Node.js/PostgreSQL job queue (also suitable for getting jobs generated by PostgreSQL triggers/functions out into a different work queue)
TypeScript
1,622
star
3

graphile-engine

Monorepo home of graphile-build, graphile-build-pg, graphile-utils, postgraphile-core and graphql-parse-resolve-info. Build a high-performance easily-extensible GraphQL schema by combining plugins!
JavaScript
752
star
4

migrate

Opinionated SQL-powered productive roll-forward migration tool for PostgreSQL.
TypeScript
703
star
5

postgraphile-lambda-example

Simple serverless / Lambda example with caching and lightweight bundle
PLpgSQL
139
star
6

postgis

PostGIS support for PostGraphile
TypeScript
90
star
7

pg-simplify-inflector

Simplifies the graphile-build-pg inflector to trim the `ByFooIdAndBarId` from relations
JavaScript
86
star
8

pg-aggregates

Aggregates for PostGraphile connections
TypeScript
73
star
9

examples

Examples of using PostGraphile with various servers and clients [WIP]
PLpgSQL
70
star
10

bootstrap-react-apollo

[WIP] A bootstrap for using PostGraphile with React and Apollo.
JavaScript
52
star
11

pg-sql2

Repository has moved:
TypeScript
48
star
12

operation-hooks

Register asynchronous callbacks before/after operations; uses include: validation, authorization, notification
TypeScript
42
star
13

federation

Apollo federation support for PostGraphile [UNMAINTAINED]
TypeScript
42
star
14

postgraphile-apollo-server

JavaScript
41
star
15

crystal-pre-merge

Repository moved
39
star
16

persisted-operations

Persisted operations (aka "persisted queries") support for PostGraphile
TypeScript
39
star
17

gatsby-source-pg

PostgreSQL source for Gatsby, powered by PostGraphile
JavaScript
35
star
18

graphile.github.io

PostGraphile (PostGraphQL) and Graphile-Build website - contributions very welcome!
SCSS
24
star
19

cookbook

Small examples to answer specific questions.
JavaScript
21
star
20

gatsby-source-pg-example

Example of using gatsby-plugin-pg
CSS
18
star
21

livesotope

Simple demo of using PostGraphile live queries
JavaScript
16
star
22

jest-time-helpers

Helpers you can use in tests that relate to the passage of time (i.e. code that involves setTimeout, setInterval, new Date(), Date.now(), etc)
TypeScript
11
star
23

global-ids

[EXPERIMENTAL] Allows you to use Relay global object identifiers in more places.
TypeScript
9
star
24

smart-tags-table

Enables retrieving PostGraphile smart tags from a database table.
TypeScript
8
star
25

postgraphile-log-consola

Use consola for PostGraphile logging
JavaScript
7
star
26

logger

An extremely lightweight log abstraction for libraries that can be used in place of `console.log`/etc, allowing users to optionally log through other log providers (`winston`, `bunyan`, etc)
TypeScript
7
star
27

postgraphile-example-apollo-server

[WIP] An example of using PostGraphile with Apollo Server (using the new lifecycle hooks functionality)
JavaScript
5
star
28

operation-hooks-example

Example of running @graphile/operation-hooks with Express
JavaScript
2
star
29

postgraphile_changes

Repository to help check for performance improvements/regressions
PLpgSQL
1
star
30

delauney

JavaScript
1
star
31

issues

Issue management for supporter/pro plugins, etc
1
star