streamsets rest api 转换 graphql
原理很简单,就是使用swagger api 生成schema 然后代理请求处理api 调用
参考项目 https://github.com/rongfengliang/streamsets-graphql-api
streamsets restapi

使用的npm 包
package.json:
{
"name": "restapi",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"babel-polyfill": "^6.26.0",
"compression": "^1.7.3",
"express": "^4.16.3",
"express-graphql": "^0.6.12",
"graphql": "^0.13.2",
"swagger-to-graphql": "^1.4.0"
},
"scripts": {
"start":"node app"
}
}
app.js
require('babel-polyfill');
const express = require('express');
const app = express();
const graphqlHTTP = require('express-graphql');
const graphQLSchema = require('./lib');
const compression = require('compression');
app.use(compression());
// 修改为对应的server 用户以及地址
const proxyUrl = 'http://admin:admin@localhost:18630/rest';
const pathToSwaggerSchema = `${__dirname}/api/swagger.json`;
// 此处比较重要因为接口是gzip 可以进行内容协商,不使用gzip
const customHeaders = {
"accept-encoding": "identity"
};
graphQLSchema(pathToSwaggerSchema, proxyUrl, customHeaders).then(schema => {
app.use('/graphql', graphqlHTTP(() => {
return {
schema,
graphiql: true
};
}));
app.listen(3009, '0.0.0.0', () => {
console.info('http://localhost:3009/graphql');
});
}).catch(e => {
console.log(e);
});
效果

参考资料
https://github.com/rongfengliang/streamsets-graphql-api
streamsets rest api 转换 graphql的更多相关文章
- harbor rest api 转graphql api
原理 实际上就是使用graphql 中的binding,首先基于swagger api 进行schema 生成,后边就是 使用binding 进行graphql 请求api 转换为rest api 请 ...
- 人人都是 API 设计师:我对 RESTful API、GraphQL、RPC API 的思考
原文地址:梁桂钊的博客 博客地址:http://blog.720ui.com 欢迎关注公众号:「服务端思维」.一群同频者,一起成长,一起精进,打破认知的局限性. 有一段时间没怎么写文章了,今天提笔写一 ...
- swagger api 转graphql npm 包试用
graphql 比较方便的进行api 的查询,操作,swagger 是一个方便的open api 描述标准,当前我们有比较多的 restapi 但是转换为graphql 是有成本的,还好swagger ...
- haproxy 2.0 dataplaneapi rest api 转为graphql docker 镜像
为了方便直接使用haproxy dataplaneapi graphql 格式的查询,制作了一个简单的docker 镜像 基于dotenv 进行配置管理,可以直接通过环境变量传入参数,处理不同hapr ...
- haproxy 2.0 dataplaneapi rest api 转为graphql
haproxy 2.0 dataplaneapi rest api 是比较全的,以下是一个简单的集成graphql,通过swagger-to-graphql 转换为graphql api 方便使用 环 ...
- Delphi 编码转换 Unicode gbk big5(使用LCMapString设置区域后,再用API转换)
原文:http://blog.dream4dev.com/article.asp?id=17 function UnicodeEncode(Str: string; CodePage: integer ...
- 如何使用 window api 转换字符集?
//宽字符转多字节 std::string W2A(const std::wstring& utf8) { int buffSize = WideCharToMultiByte(CP_ACP, ...
- 如何使用 window api 转换字符集?(std::string与std::wstring的相互转换)
//宽字符转多字节 std::string W2A(const std::wstring& utf8) { int buffSize = WideCharToMultiByte(CP_ACP, ...
- normalizr api 转换类库使用
1. 项目初始化 yarn init yarn add normalizr 项目结构 app.js package.json user.json 2. 使用 a. app.js const userj ...
随机推荐
- Spring Boot 系统要求
Spring Boot 2.1.0.RELEASE 方需要 Java 8 or 9 的支持和 Spring Framework 5.1.2.RELEASE 以上的版本. 明确的构建工具的支持,请参考下 ...
- Jersey 2.x 服务器端应用支持的容器
基于 JAX-RS Servlet-based 部署的一部分标准,能运行在任何支持 Servlet 2.5 和更高标准的的容器上.Jersey 提供支持程序化部署在下面的容器中:Grizzly 2 ( ...
- Anton and School - 2 CodeForces - 785D (组合计数,括号匹配)
大意: 给定括号字符串, 求多少个子序列是RSGS. RSGS定义如下: It is not empty (that is n ≠ 0). The length of the sequence is ...
- Mac搭建个人服务器开发微信公众号
个人电脑搭建小型服务器面临的一个重要问题就是网络问题,我把解决的过程简单记录一下,准备以后参考. 1. 内网穿透 由于个人所在网络是一个局域网,没有公网的IP,因此在公网是不能直接访问个人电脑的服务器 ...
- c++中的new和delete
对于计算机程序设计而言,变量和对象在内存中的分配都是编译器在编译程序时安排好的,这带来了极大的不便,如数组必须大开小用,指针必须指向一个已经存在的变量或对象.对于不能确定需要占用多少内存的情况,动态内 ...
- 关于InputStream类的available()方法
要一次读取多个字节时,经常用到InputStream.available()方法,这个方法可以在读写操作前先得知数据流里有多少个字节可以读取.需要注意的是,如果这个方法用在从本地文件读取数据时,一般不 ...
- 42. Trapping Rain Water *HARD*
Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...
- quartz---的SimpleTrigger
quartz---的SimpleTrigger package com.imooc.demo.helloQuartz; import java.text.SimpleDateFormat; impor ...
- Data Guard Wait Events
This note describes the wait events that monitor the performance of the log transport modes that wer ...
- redis写入数据被转义问题
1.phpredis扩展写入redis的数据发现“ \ 会被自动转义成\" \\. 如: 写入 dadaf"daf\dad 在redis命令行读出为 dadaf\"da ...