GraphQL API and database interface for Gardenbuilder
Made with Typescript, TypeORM, Postgres and GraphQL
You'll need to also set up a postgresql database. I would follow the directions here.
Alternatively, you could run postgresql locally using docker: docker run -e POSTGRES_USER=root -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=gardenbuilder -p 127.0.0.1:5432:5432/tcp library/postgres
Once you have postgresql set up, follow these steps:
- while logged in as root, make a table with the same name as your desired username. If your username is
coolUser
, for example, name your tablecoolUser
- make a
main
table and atest
table - give your user privileges to those tables with
GRANT ALL PRIVILEGES ON DATABASE main TO coolUser;
andGRANT ALL PRIVILEGES ON DATABASE test TO coolUser
;
Finally, you'll need to add the following into the .env
file at the root of the project:
LOCAL_DATABASE_HOST=localhost
LOCAL_DATABASE_USER=yourUserName
LOCAL_DATABASE_PASSWORD=yourPassword
JWT_HASH_KEY=key
PORT=8000
At project root, type npm run start:dev
. This will start the API. You'll want to open up a second terminal at root and type npm run watch
so that your code changes are compiled from typescript to javascript as you save them.
Then navigate to localhost:8000/graphql. You should see the graphiQL editor and be able to write queries like
query {
gardens {
name
}
}
Run npm test
or npm run test
. Tests also automatically run each time you try to make a git commit
To Contribute, read our Contribution Guidelines