hasura graphql-engine v1.0.0-alpha26 版本新功能试用
hasura graphql-engine v1.0.0-alpha26 已经发布了,有好多新的变动,测试使用docker 环境,同时pg 数据库使用了citus
citus 是一个方便扩展的pg 数据库扩展解决方案,很不错。
环境准备
docker-compose && citus
- docker-compose 文件
version: '2.1'
services:
graphql-engine:
image: hasura/graphql-engine:v1.0.0-alpha26
ports:
- "8080:8080"
command: >
/bin/sh -c "
graphql-engine --database-url postgres://postgres@master/postgres serve --enable-console;
"
master:
container_name: "${COMPOSE_PROJECT_NAME:-citus}_master"
image: 'citusdata/citus:7.5.1'
ports: ["${MASTER_EXTERNAL_PORT:-5432}:5432"]
labels: ['com.citusdata.role=Master']
worker:
image: 'citusdata/citus:7.5.1'
labels: ['com.citusdata.role=Worker']
depends_on: { manager: { condition: service_healthy } }
manager:
container_name: "${COMPOSE_PROJECT_NAME:-citus}_manager"
image: 'citusdata/membership-manager:0.2.0'
volumes: ['/var/run/docker.sock:/var/run/docker.sock']
depends_on: { master: { condition: service_healthy } }
- 启动
docker-compose up -d
- 测试数据表
-- DDL generated by Postico 1.4.2
-- Not all database features are supported. Do not use for backup.
-- Table Definition ----------------------------------------------
CREATE TABLE citus.userlogin (
id integer DEFAULT nextval('citus.userlogin_id_seq'::regclass) PRIMARY KEY,
username text NOT NULL,
userage integer NOT NULL
);
-- Indices -------------------------------------------------------
CREATE UNIQUE INDEX userlogin_pkey ON citus.userlogin(id int4_ops);
-- DDL generated by Postico 1.4.2
-- Not all database features are supported. Do not use for backup.
-- Table Definition ----------------------------------------------
CREATE TABLE citus.platformuser (
id integer DEFAULT nextval('citus.platformuser_id_seq'::regclass) PRIMARY KEY,
platformtype text NOT NULL,
loginuser integer NOT NULL DEFAULT nextval('citus.platformuser_loginuser_seq'::regclass),
platformname text NOT NULL
);
-- Indices -------------------------------------------------------
CREATE UNIQUE INDEX platformuser_pkey ON citus.platformuser(id int4_ops);
新功能测试
- order_by 查询
query {
citus_userlogin(order_by:{id:asc}) {
id
username
userage
}
}
- 聚合参数操作
query {
citus_userlogin_aggregate {
aggregate {
max {
userage
}
}
}
}
- 关系聚合
- event trigger
说明
测试只是一部分,实际上还有预设值的,都比较简单,hasura graphql-engine 是越来越方便了,hasura 团队很给力,
对于开发来说太方便了
参考资料
https://docs.hasura.io/1.0/graphql/manual/getting-started/index.html
https://github.com/hasura/graphql-engine/releases
https://www.citusdata.com/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)