参考ページ
PostGraphile Introduction
前提条件
$ psql -U scott city
psql (15.2)
"help"でヘルプを表示します。
city=> select * from cities;
id | name | population | date_mod
-------+--------+------------+------------
t3461 | 広島 | 72814 | 2001-09-14
t3462 | 福山 | 41738 | 2001-07-21
t3463 | 東広島 | 92513 | 2001-06-12
t3464 | 呉 | 93167 | 2001-09-29
t3465 | 尾道 | 95419 | 2001-03-18
t3466 | 竹原 | 82314 | 2001-02-21
t3467 | 三次 | 76152 | 2001-08-16
t3468 | 大竹 | 37541 | 2001-07-07
t3469 | 府中 | 46518 | 2001-10-09
(9 行)
インストール
sudo npm install -g postgraphile
サーバーの起動
npx postgraphile -c \
'postgres://scott:tiger123@localhost:5432/city' \
--watch --enhance-graphiql --dynamic-json
クライアント
curl_get.sh
URL="http://localhost:5000/graphql"
#
curl -X POST \
-H "Content-Type: application/json" \
-d@query.json ${URL}
http_get.sh
URL="http://localhost:5000/graphql"
#
http ${URL} < query.json
query.json
{"query": "query MyQuery { allCities { edges { node { id name population } } } }"}