hasura 使用一个基于pg数据库的graphql引擎,他的设计比postgrpahql 有好多方便的地方,同时使用也比较简单
安装
docker && docker-compose
curl -L https://cli.hasura.io/install.sh | bash
hasura init --directory my-project
cd my-project/install-scripts
docker-compose up -d
生成结果
├── config.yaml
├── install-scripts
│ ├── docker-compose.yaml
│ └── docker-run.sh
└── migrations
代码说明
主要是docker-compose.yaml
version: '3.6'
services:
postgres:
image: postgres
ports:
- "5432:5432"
environment:
- "POSTGRES_PASSWORD:dalong"
volumes:
- db_data:/var/lib/postgresql/data
graphql-engine:
image: hasura/graphql-engine:v1.0.0-alpha06
ports:
- "8080:8080"
depends_on:
- "postgres"
environment:
- "POSTGRES_PASSWORD:dalong"
command: >
/bin/sh -c "
graphql-engine --database-url postgres://postgres:dalong@postgres:5432/postgres serve --enable-console;
"
volumes:
db_data:
操作界面
参考资料
https://github.com/hasura/graphql-engine
https://docs.hasura.io/1.0/graphql/manual/getting-started/docker-simple.html