新的hasura graphql-engine 代码仓库中已经包含了一个基于express 的简单graphql server,
可以用来测试模式拼接

graphql server 代码

  • 项目结构
├── Dockerfile
├── README.md
├── now.json
├── package.json
└── server.js
  • 代码说明
package.json: 依赖包
{
"name": "nodejs-express-gql-server",
"version": "1.0.0",
"description": "A GraphQL server boilerplate for NodeJS-Express using graphql-js library",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node -r esm server.js"
},
"author": "Hasura",
"license": "MIT",
"dependencies": {
"express": "^4.16.4",
"express-graphql": "^0.7.1",
"graphql": "^14.0.2"
},
"devDependencies": {
"esm": "^3.0.84"
}
}
server.js: 具体代码
const express = require('express');
const graphqlHTTP = require('express-graphql');
const { buildSchema } = require('graphql'); let count = 0;
const port = process.env.port || 3000; // Construct a schema, using GraphQL schema language
const schema = buildSchema(`
type Query {
hello: String!
count: Int!
} type Mutation {
increment_counter: count_mutation_response!
} type count_mutation_response {
new_count: Int!
}
`); // The root provides a resolver function for each API endpoint
const root = {
hello: () => {
return 'Hello world!';
},
count: () => {
return count;
},
increment_counter: () => {
return { new_count: ++count }
}
}; var app = express();
app.use('/graphql', graphqlHTTP({
schema: schema,
rootValue: root,
graphiql: true,
}));
app.listen(port);
console.log(`Running a GraphQL API server at localhost:${port}/graphql`);
Dockerfile: 代码的dockeer 运行
FROM node:8 WORKDIR /server COPY ./package.json /server/ RUN npm install COPY . /server/ CMD ["npm", "start"]

hasura graphql-engine 环境准备

graphql server 的我已经推送到dockerhub 了 镜像为:dalongrong/stitchmerge

  • docker-compose 文件
version: '3.6'
services:
postgres2:
image: postgres:9.6
ports:
- "5432:5432"
environment:
- "POSTGRES_PASSWORD:dalong"
volumes:
- ./db_data2:/var/lib/postgresql/data
postgres:
image: postgres:9.6
ports:
- "5435:5432"
environment:
- "POSTGRES_PASSWORD:dalong"
volumes:
- ./db_data:/var/lib/postgresql/data
benthos:
image: jeffail/benthos
volumes:
- "./configs/webhook.yaml:/benthos.yaml"
ports:
- "4195:4195"
node-exress:
image: dalongrong/stitchmerge
ports:
- "3000:3000"
graphql-engine2:
image: hasura/graphql-engine:v1.0.0-alpha30
ports:
- "8080:8080"
depends_on:
- "postgres"
environment:
- "POSTGRES_PASSWORD:dalong"
command: >
/bin/sh -c "
graphql-engine --database-url postgres://postgres:dalong@postgres2:5432/postgres serve --enable-console;
"
graphql-engine:
image: hasura/graphql-engine:v1.0.0-alpha29
ports:
- "8090: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;
"

试用模式拼接功能

  • 添加配置
  • schema 信息
  • 测试

    但是,进行混合的时候就有问题了,新版发布的说明里面也有提示,后期应该可以解决
  • 查看表结构

说明

这个功能还是很不错的,只是期待可以解决好多已知的问题

参考资料

https://github.com/hasura/graphql-engine
https://github.com/rongfengliang/hasura-graphql-event-benthos

 
 
 
 

hasura graphql-engine v1.0.0-alpha30 remote schema stitch 试用的更多相关文章

  1. hasura graphql-engine v1.2.0 beta 版本

    hasura graphql-engine v1.2.0 提供了一个很不错的功能action,这个也是目前其他graphql 没有hasura 强大的 地方,使用action 我们可以更好的扩展has ...

  2. 二进制搭建Kubernetes集群(最新v1.16.0版本)

    目录 1.生产环境k8s平台架构 2.官方提供三种部署方式 3.服务器规划 4.系统初始化 5.Etcd集群部署 5.1.安装cfssl工具 5.2.生成etcd证书 5.2.1 创建用来生成 CA ...

  3. Gitea v1.17.0 正式发布 | 集成软件包管理器、容器镜像仓库

    我们自豪地宣布 Gitea v1.17.0 发布了.本次发布带来了诸多新特性和累积的更新,我们强烈建议用户在更新到最新版本之前仔细阅读发行注记. 在 1.17.0 版本的开发中我们一共合并了 645 ...

  4. Kubeadm搭建高可用(k8s)Kubernetes v1.24.0集群

    文章转载自:https://i4t.com/5451.html 背景 Kubernetes 1.24新特性 从kubelet中移除dockershim,自1.20版本被弃用之后,dockershim组 ...

  5. FineUI(专业版)v1.2.0 和 FineUI(开源版)v4.1.1 同时发布!

    FineUI(开源版)v4.1.1 (建议所有 v4.x 升级到此版本):http://fineui.com/demo/ +2014-08-15 v4.1.1        -修正Form中表单字段设 ...

  6. RapidJSON v1.1.0 发布简介

    时隔 15.6 个月,终于发布了一个新版本 v1.1.0. 新版本除了包含了这些日子收集到的无数的小改进及 bug fixes,也有一些新功能.本文尝试从使用者的角度,简单介绍一下这些功能和沿由. P ...

  7. 使用Advanced Installer 自动部署 Arcgis Engine Runtime 10.0

    原文:使用Advanced Installer 自动部署 Arcgis Engine Runtime 10.0 目前采用Arcgis9.2 + c#(vs2008)作为程序开发平台,是一个不错的搭配. ...

  8. 读阿里巴巴Java开发手册v1.2.0之工程结构有感【架构篇】

    首先,把昨天那俩条sql语句的优化原因给大家补充一下,第一条效率极低,第二条优化后的,sql语句截图如下: 经过几个高手的评论和个人的分析: 第一条sql语句查询很慢是因为它首先使用了in关键字查询, ...

  9. 读阿里巴巴Java开发手册v1.2.0之编程规约有感【架构篇】

     不为过去蹉跎,改变当下. 为什么开篇就送这么一句话给大家,我相信很多处于1-3年码龄的哥们儿们,在平时的编码历程中编码的个性可能是多彩的,每个人都有每个人特定的风格,但是我们现在这么随意写,以后这么 ...

随机推荐

  1. 软件设计基础-C/S系统

    在软件设计开发过程中,逐渐形成了一些针对特定应用领域的软件系统组织方式的惯用模式 如经典的C/S(client/server,客户/服务器)模式和B/S(browser/server,浏览器/服务器) ...

  2. linux 清空文件

    将Linux文件清空的几种方法 1.使用重定向的方法 [root@centos7 ~]# du -h test.txt 4.0K test.txt [root@centos7 ~]# > tes ...

  3. <Spark><Spark Streaming><作业分析><JobHistory>

    Intro 这篇是对一个Spark (Streaming)作业的log进行分析.用来加深对Spark application运行过程,优化空间的各种理解. Here to Start 从我这个初学者写 ...

  4. React 高阶组价详解

    这个教程还是不错的...

  5. Python 深度递归

    class A: pass class B(A): pass class C(A): pass class D(B, C): pass class E: pass class F(D, E): pas ...

  6. 【转载】 Pytorch(0)降低学习率torch.optim.lr_scheduler.ReduceLROnPlateau类

    原文地址: https://blog.csdn.net/weixin_40100431/article/details/84311430 ------------------------------- ...

  7. Java简单双向链表实现 @version 1.0

    package com.list; /** * 数据结构和算法Java表示 双向链表 * * @version 1.0 * @author 小明 * */ public class MyDoublel ...

  8. golang 3des/ecb/cbc/pkcs5 加解密

    本人新手,参考文档: http://blog.studygolang.com/2013/01/go%E5%8A%A0%E5%AF%86%E8%A7%A3%E5%AF%86%E4%B9%8Bdes/ h ...

  9. ubuntu上安装boost库

    只需一条命令: sudo apt install libboost-dev

  10. maven 构建 war文件&&Glassfish运行+部署war文件+访问(命令行模式)

    Glassfish常用命令 asadmin  start-domain  --verbose                 #启动Glassfish服务器(默认domain1) ,并在终端显示相关信 ...