Skip to content

Contributing

pg_graphql is OSS. PR and issues are welcome.

Development

Requirements:

Testing

Tests are located in ./test/sql with expected output in ./test/expected

To run tests locally, execute:

1
$ cargo pgrx install; ./bin/installcheck

Interactive PSQL Development

To reduce the iteration cycle, you may want to launch a psql prompt with pg_graphql installed to experiment

1
cargo pgrx run pg14

Try out the commands below to spin up a database with the extension installed & query a table using GraphQL. Experiment with aliasing field/table names and filtering on different columns.

1
2
3
4
5
6
7
8
graphqldb= create extension pg_graphql cascade;
CREATE EXTENSION

graphqldb= create table book(id int primary key, title text);
CREATE TABLE

graphqldb= insert into book(id, title) values (1, 'book 1');
INSERT 0 1

Finally, execute some graphql queries against the table.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
graphqldb= select graphql.resolve($$
query {
  bookCollection {
    edges {
      node {
        id
      }
    }
  }
}
$$);

             resolve
----------------------------------------------------------------------
{"data": {"bookCollection": {"edges": [{"node": {"id": 1}}]}}, "errors": []}

Documentation

All public API must be documented. Building documentation requires python 3.6+

Install Dependencies

Install mkdocs, themes, and extensions.

1
pip install -r docs/requirements_docs.txt

Serving

To serve the documentation locally run

1
mkdocs serve

and visit the docs at http://127.0.0.1:8000/pg_graphql/