2018-07-11 07:57:03 +03:00
|
|
|
# Contributing
|
|
|
|
|
2018-10-19 19:59:18 +03:00
|
|
|
This guide explains how to set up the graphql-engine server for development on your
|
|
|
|
own machine and how to contribute.
|
2018-07-11 13:34:29 +03:00
|
|
|
|
|
|
|
## Pre-requisites
|
|
|
|
|
|
|
|
- [stack](https://docs.haskellstack.org/en/stable/README/#how-to-install)
|
2019-07-12 06:59:29 +03:00
|
|
|
- [Node.js](https://nodejs.org/en/) (>= v8.9)
|
|
|
|
- npm >= 5.7
|
2019-09-19 15:54:40 +03:00
|
|
|
- brotli
|
2019-02-14 08:16:14 +03:00
|
|
|
- libpq-dev
|
2019-07-12 06:59:29 +03:00
|
|
|
- python >= 3.5 with pip3
|
2019-11-14 19:32:11 +03:00
|
|
|
- [pyenv](https://github.com/pyenv/pyenv) (Recommended, not required)
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-09-19 15:54:40 +03:00
|
|
|
The Brotli can be installed from source using `git`, `cmake` and `pkgconf` on Debian with:
|
|
|
|
|
|
|
|
$ apt-get -y update \
|
|
|
|
&& apt-get -y install git cmake pkgconf \
|
|
|
|
&& git clone https://github.com/google/brotli.git && cd brotli && mkdir out && cd out && ../configure-cmake \
|
|
|
|
&& make && make test && make install && ldconfig
|
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
The last two prerequisites can be installed on Debian with:
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
$ sudo apt install libpq-dev python3 python3-pip python3-venv
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
### Upgrading npm
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
If your npm is too old (>= 5.7 required):
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
$ npm install -g npm@latest # sudo may be required
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
or update your nodejs.
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2018-07-11 13:34:29 +03:00
|
|
|
|
|
|
|
## Development workflow
|
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
You should fork the repo on github and then `git clone https://github.com/<your-username>/graphql-engine`.
|
|
|
|
After making your changes
|
2018-07-11 13:34:29 +03:00
|
|
|
|
|
|
|
### Compile
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
...console assets:
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
$ cd console
|
|
|
|
$ npm ci
|
|
|
|
$ npm run server-build
|
|
|
|
$ cd ..
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
...and the server:
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
$ cd server
|
|
|
|
$ stack build --fast
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
### Run and Test
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
The easiest way to run `graphql-engine` locally for development is to first
|
|
|
|
launch a new postgres container with:
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
$ scripts/dev.sh postgres
|
2019-03-19 08:12:50 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
Then in a new terminal launch `graphql-engine` in dev mode with:
|
2018-07-11 13:34:29 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
$ scripts/dev.sh graphql-engine
|
2019-01-20 12:49:56 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
The `dev.sh` will print some helpful information and logs from both services
|
|
|
|
will be printed to screen.
|
2019-01-20 12:49:56 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
You can run the test suite with:
|
2019-01-20 12:49:56 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
$ scripts/dev.sh test
|
2019-01-20 12:49:56 +03:00
|
|
|
|
2019-07-12 06:59:29 +03:00
|
|
|
This should run in isolation.
|
2019-01-20 12:49:56 +03:00
|
|
|
|
2018-07-11 13:34:29 +03:00
|
|
|
|
|
|
|
### Create Pull Request
|
|
|
|
- Make sure your commit messages meet the [guidelines](../CONTRIBUTING.md).
|
|
|
|
- Create a pull request from your forked repo to the main repo.
|
|
|
|
- Every pull request will automatically build and run the tests.
|
|
|
|
|
|
|
|
## Code conventions
|
|
|
|
|
|
|
|
This helps enforce a uniform style for all committers.
|
|
|
|
|
|
|
|
- Compiler warnings are turned on, make sure your code has no warnings.
|
|
|
|
- Use [hlint](https://github.com/ndmitchell/hlint) to make sure your code has no warnings.
|
|
|
|
- Use [stylish-haskell](https://github.com/jaspervdj/stylish-haskell) to format your code.
|