To run locally, you should set up a PostgreSQL instance. Homebrew is the easiest way to do this.
To get Homebrew on Mac:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
To install PostgreSQL:
brew update
brew install postgresql
Check your version:
postgres --version
postgres (PostgreSQL) 13.0
Start and Stop PostgreSQL:
pg_ctl -D /usr/local/var/postgres start
pg_ctl -D /usr/local/var/postgres stop
Create and delete local DB instance:
createdb sampledatabase
dropdb sampledatabase
Interact with DB in PostgreSQL shell:
psql sampledatabase
# \list - List all of your actual databases.
# \c dbname - Connect to another database.
# \d - List the relations of your currently connected database.
# \d tablename - Shows information for a specific table.
# CMD + d to exit
To run the project you will need a local .env
file with the following contents relevant to your local DB:
# .env
PORT=8000
DATABASE=sampledatabase
DATABASE_USER=username
DATABASE_PASSWORD=username
Once PostgreSQL is set up and your DB is linked in .env
, simply run yarn start
.
{
users {
id
username
visits {
id
note
}
}
}
{
visits {
id
note
user {
id
username
}
}
}
Use the following variables in your request:
{
"userId": <number>,
"note": <string>
}
mutation CreateVisit($userId: ID!, $note: String!) {
createVisit(userId: $userId, note: $note) {
id
}
}
Use the following variables in your request:
{
"id": <number>,
}
mutation DeleteVisit($id: ID!) {
deleteVisit(id: $id)
}