Start pg server
sudo brew services start postgresql
Make postgres as default user
export PGUSER=postgres
Create pg database
createdb test
Connect to database
psql test
Create users table for testing by pasting the following code in the pg console
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TABLE users (
id uuid PRIMARY KEY DEFAULT uuid_generate_v1(),
createdAt TIMESTAMP DEFAULT NOW(),
last_name TEXT,
first_name TEXT,
address TEXT,
city TEXT
);
INSERT INTO users (last_name, first_name, address, city) VALUES ('alex', 'and', 'St 07', 'Focsani');
INSERT INTO users (last_name, first_name, address, city) VALUES ('well', 'dan', 'St 43', 'Bucuresti');
INSERT INTO users (last_name, first_name, address, city) VALUES ('radu', 'man', 'St 65', 'Brasov');
INSERT INTO users (last_name, first_name, address, city) VALUES ('cosmin', 'dum', 'St 03', 'Bucuresti');
INSERT INTO users (last_name, first_name, address, city) VALUES ('serban', 'coc', 'St 21', 'Roman');
Install postgraphile
sudo npm i -g postgraphile
Run the graphql server
postgraphile -c "postgres://localhost:5432/test" --watch --cors