• Stars
    star
    1,090
  • Rank 42,497 (Top 0.9 %)
  • Language PLpgSQL
  • License
    Other
  • Created over 9 years ago
  • Updated over 7 years ago

Reviews

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

Repository Details

GraphQL for Postgres

GraphpostgresQL -- a graph interface to relational data

GraphpostgresQL is inspired by Facebook's graphql. By using table introspection, GraphpostgresQL is able to follow foreign keys and index into complex datatypes like json, jsonb and hstore.

A Proof of Concept

GraphpostgresQL is alpha quality and has undergone neither extensive optimization nor comprehensive testing. To use it for production workloads would needlessly tempt fate.

Install GraphpostgresQL

Using psql, load the graphql schema file:

\i graphql.sql

All definitions are created under the graphql schema. GraphpostgresQL doesn't load any extensions or alter the search_path. If an older version of GraphpostgresQL is loaded, the new installation will overwrite it.

Using GraphpostgresQL

To generate a query, use graphql.to_sql(text):

SELECT graphql.to_sql($$
  user("f3411edc-e1d0-452a-bc19-b42c0d5a0e36") {
    full_name,
    friendship
  }
$$);

Which should result in something like:

SELECT to_json("sub/2") AS "user"
  FROM "user",
       LATERAL (
         SELECT json_agg("user") AS friendship
           FROM "user"
           JOIN friendship ON (("user".id) = (friendship.second))
          WHERE (friendship.first)
              = ('f3411edc-e1d0-452a-bc19-b42c0d5a0e36'::uuid)
       ) AS "sub/1",
       LATERAL (
         SELECT "user".full_name, "sub/1".friendship
       ) AS "sub/2"
 WHERE (("user".id) = ('f3411edc-e1d0-452a-bc19-b42c0d5a0e36'::uuid))

To run a query, use graphql.run(text) instead of graphql.to_sql(text).

Removing GraphpostgresQL

It's easy to remove GraphpostgresQL:

DROP SCHEMA IF EXISTS graphql CASCADE;

Roadmap

In GraphpostgresQL64, we'll introduce expanded selectors (nested selection in JSON columns, for example), an interface that accepts keyword parameters, and the ability to store and re-execute queries.

In GraphpostgresQL3D, we'll introduce a PL/V8 implementation, with extensible parsing, hooks and overall more modular implementation.

More Repositories

1

arx

Bundles code and a job to run for local or remote execution.
Shell
169
star
2

pglite

A tiny script to manage ephemeral Postgres databases.
Shell
110
star
3

pg-sql-variants

Variants types for PostgreSQL
PLpgSQL
30
star
4

bash

Haskell
19
star
5

macaroon

Postgres introspection and macros
PLpgSQL
16
star
6

JSONb

Parses JSON from byte strings (instead of character strings).
Haskell
12
star
7

maccatcher

Obtain the host MAC on Windows and *NIX in Haskell.
Haskell
9
star
8

shell-escape

Shell escaping library.
Haskell
8
star
9

tsv

A simple, line-oriented tabular data format
Python
8
star
10

system-uuid

Haskell bindings for the native UUID generator.
Haskell
7
star
11

drdns

Dynamic DNS for AWS EC2
Python
7
star
12

wcwidth

Haskell bindings for WCWidth.
Haskell
6
star
13

taskl

Haskell
5
star
14

query-selector

Organize app queries in an annotated SQL file
Python
4
star
15

logl

Haskell
4
star
16

hso

Haskell shared libs -- notes and examples.
C
3
star
17

hpath

Obtain source code for a given qualified name.
Haskell
3
star
18

agda-tutorial

Problems from "Dependently Typed Programming in Agda".
3
star
19

annotext

Format-preserving conversion of plaintext to HTML.
3
star
20

bytestring-nums

Haskell package to convert ByteStrings to numbers.
Haskell
2
star
21

rust-postgres-named-parameters

Rust
2
star
22

es6-react-nodewebkit-clock

As cool as it sounds
JavaScript
2
star
23

cols

Column width of Unicode chars for Haskell.
Haskell
2
star
24

todeb

Specify Debian packages to install users, filesystem heirarchies and collections of packages.
Ruby
2
star
25

CAdir

CA management utility.
Shell
2
star
26

cfgcc

Haskell
2
star
27

pretext

Haskell
2
star
28

shuffle

Shuffler for NB's FMOF Bingo.
Haskell
2
star
29

email-list-tools

Python
2
star
30

coproc

Coroutine interfaces for interpreters, like Bash and Sh.
Haskell
2
star
31

UniDB

Unicode character properties database.
Haskell
2
star
32

cloudsat

Ruby
1
star
33

timesheet

Invoicing system
PLpgSQL
1
star
34

root_transfer

RSync filter files for syncing system images of my Ubuntu laptops.
Shell
1
star
35

countdown-sleep

Sleep with a countdown
Rust
1
star
36

CLibPQ

Porting libpq to Mac
Swift
1
star
37

lark

Gem for managing distributed state in a redis cluster
Ruby
1
star
38

tMask

Time/scheduling specs that can mask one another.
1
star
39

colog

Haskell
1
star
40

evening-rain-59

Simple Heroku app I use for testing.
Ruby
1
star
41

encrypted-chat

1
star
42

statl

Is the system as you want it to be?
1
star
43

trippy-waves

Haskell investigations of Mitch Altman's Trippy Waves RGB device/firmware.
C
1
star
44

bash-remoting

Shell
1
star
45

DispatchPQ

Swift concurrent Postgres API, using Grand Central
Swift
1
star
46

nbr

Noisebridge Boot Record
1
star
47

homo_faber

Translation of Frisch's famous novel.
1
star
48

Gittar

Makes a nicely named tarball from a Git repository, incorporating the tag and the number of intermediate commits.
Shell
1
star
49

bikes-on-bart

Determine whether or not bikes can run on BART.
Ruby
1
star
50

confit

An object-oriented DSL for system automation
Python
1
star
51

shuttercat

Haskell
1
star
52

retainer

Archiving for append-only collections of files like /var/log, Pidgin logs and mail using Git.
Shell
1
star
53

sqlmod

Provides support for sharing SQL queries across projects and avoiding those long and confusing, un-highlighted, embedded SQLs that often grow out of analytics and optimization projects.
Rust
1
star