Skip to content

Commit ce49df9

Browse files
authored
Merge pull request #560 from supabase/contributing-docs
Expand contributing guide
2 parents 8c8ef69 + ea5ee39 commit ce49df9

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

Diff for: docs/contributing.md

+31-7
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,53 @@ pg_graphql is OSS. PR and issues are welcome.
22

33
## Development
44

5-
Requirements:
5+
To start developing `pg_graphql`:
66

7-
- rust
8-
- cargo
9-
- [pgrx](https://github.com/tcdi/pgrx)
7+
1. [Install Rust](https://www.rust-lang.org/tools/install).
8+
2. [Install pgrx](https://github.com/pgcentralfoundation/pgrx)
109

1110
### Testing
1211

13-
Tests are located in `./test/sql` with expected output in `./test/expected`
12+
Tests are located in sql files in the `./test/sql` folder. Each sql file has a corresponding expected output file in `./test/expected` folder. For example, `./test/sql/aliases.sql`'s expected output is in `./tests/expected/aliases.out`. When a test runs, its actual output is saved in the `./results` folder. If the file in `./results` folder matches the corresponding file in the `./test/expected` folder, the test passes, otherwise it fails.
1413

15-
To run tests locally, execute:
14+
To run tests locally, first execute:
15+
16+
```bash
17+
cargo pgrx install
18+
```
19+
20+
to build `pg_graphql` from source and install it in the Postgres instance specified by `pg_config`. This step must be run when you have made any changes in the Rust code. It can be skipped if there are no Rust code changes since the last time the command was run. The skipping is expecially useful when you are only modifying the test sql files.
21+
22+
Next, run all the tests by executing:
23+
24+
```bash
25+
./bin/installcheck
26+
```
27+
28+
You can combine the last two steps to build and install `pg_graphql` and run all the tests:
1629

1730
```bash
1831
$ cargo pgrx install; ./bin/installcheck
1932
```
2033

34+
You can run a single test by passing its name to the `installcheck` command. For example, the following runs the test in `./test/sql/aliases.sql`.
35+
36+
```bash
37+
./bin/installcheck aliases
38+
```
39+
40+
When writing a new test, or editing an existing one, the file in `./result` should be inspected manually and then copied over to the `./test/expected` folder to make the test pass.
41+
42+
### Debugging
43+
44+
You can print to the output by using the `pgrx_pg_sys::submodules::elog::info!` macro in the Rust code. Lines printed with this macro will show in the .out file in the `./results` folder.
2145

2246
### Interactive PSQL Development
2347

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

2650
```bash
27-
cargo pgrx run pg14
51+
cargo pgrx run pg16
2852
```
2953

3054
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.

0 commit comments

Comments
 (0)