0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PostGraphile の使い方

Posted at

参考ページ
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 } } } }"}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?