· 7 years ago · Dec 21, 2018, 03:40 AM
1Start pg server
2
3`sudo brew services start postgresql`
4
5Make postgres as default user
6
7`export PGUSER=postgres`
8
9Create pg database
10
11`createdb test`
12
13Connect to database
14
15`psql test`
16
17Create users table for testing
18
19 CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
20
21 CREATE TABLE users (
22 id uuid PRIMARY KEY DEFAULT uuid_generate_v1(),
23 createdAt TIMESTAMP DEFAULT NOW(),
24 last_name TEXT,
25 first_name TEXT,
26 address TEXT,
27 city TEXT
28 );
29
30 INSERT INTO users (last_name, first_name, address, city) VALUES ('alex', 'and', 'St 07', 'Focsani');
31 INSERT INTO users (last_name, first_name, address, city) VALUES ('well', 'dan', 'St 43', 'Bucuresti');
32 INSERT INTO users (last_name, first_name, address, city) VALUES ('radu', 'man', 'St 65', 'Brasov');
33 INSERT INTO users (last_name, first_name, address, city) VALUES ('cosmin', 'dum', 'St 03', 'Bucuresti');
34 INSERT INTO users (last_name, first_name, address, city) VALUES ('serban', 'coc', 'St 21', 'Roman');
35
36
37Install postgraphile
38
39`sudo npm i -g postgraphile`
40
41Run the graphql server
42
43`postgraphile -c "postgres://localhost:5432/test" --watch --cors`