hasura graphql 集成pipelinedb测试
实际上因为pipelinedb 是原生支持pg的,所以应该不存在太大的问题,以下为测试
使用doker-compose 运行
配置
- docker-compose 文件
version: '3.6'
services:
postgres:
image: tkanos/pipelinedb_kafka
ports:
- "5432:5432"
graphql-engine:
image: hasura/graphql-engine:v1.0.0-alpha06
ports:
- "8080:8080"
depends_on:
- "postgres"
environment:
- "POSTGRES_PASSWORD:pipeline"
command: >
/bin/sh -c "
graphql-engine --database-url postgres://pipeline:pipeline@postgres:5432/pipeline serve --enable-console;
"
volumes:
db_data:
- 说明
主要是进行pipelinedb 的添加以及graphql-engine 的连接pg的配置
启动&&运行
- 启动
docker-compose up -d
- 效果
添加pipelinedb 数据
stream 操作
- 创建stream
CREATE STREAM stream_test1 (x integer, y integer,z text);
- 创建 CONTINUOUS
CREATE CONTINUOUS VIEW v_sum as select sum( x + y ) FROM stream_test1;
CREATE CONTINUOUS VIEW V_GROUP AS SELECT count(*) as coun,x,y,z FROM stream_test1 GROUP BY x,y,z;
- 插入数据
INSERT INTO stream_test1(x,y,z) VALUES(1,2,'A'),(3,4,'B'),(5,6,'C'),(7,8,'D'),(1,2,'A');
- 查询
select * from v_sum;
select * from v_group;
添加graphql table
- 查看pipelinedb 系统创建的表
- 添加 graphql 支持
- 数据查询
说明
结合起来使用还是很方便的,即有hasura引擎的简单,同时集成了pipelinedb的stream 特性,很好很强大
参考资料
https://github.com/hasura/graphql-engine
http://docs.pipelinedb.com/installation.html