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:[email protected]: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

原文地址:https://www.cnblogs.com/rongfengliang/p/9519821.html

时间: 2024-08-29 18:11:14

streamsets rest api 转换 graphql的相关文章

harbor rest api 转graphql api

原理 实际上就是使用graphql 中的binding,首先基于swagger api 进行schema 生成,后边就是 使用binding 进行graphql 请求api 转换为rest api 请求,目前测试过两个开源的方案: prisma 的graphql-openapi-binding 以及swagger-graphql 类库 步骤 swagger 模型生成graphql schema 使用cli 工具 swagger-to-graphql npm install -g swagger-

swagger api 转graphql npm 包试用

graphql 比较方便的进行api 的查询,操作,swagger 是一个方便的open api 描述标准,当前我们有比较多的 restapi 但是转换为graphql 是有成本的,还好swagger-to-graphql 这个npm 包帮助我们简化了操作 基本项目 具体项目参考 https://github.com/rongfengliang/swagger-to-graphql-docker 项目结构 ├── Dockerfile ├── README.md ├── api │ └── s.

Delphi 编码转换 Unicode gbk big5(使用LCMapString设置区域后,再用API转换)

原文:http://blog.dream4dev.com/article.asp?id=17 function UnicodeEncode(Str: string; CodePage: integer): WideString;var Len: integer;begin Len := Length(Str) + 1; SetLength(Result, Len); Len := MultiByteToWideChar(CodePage, 0, PChar(Str), -1, PWideChar

stl中char 与wchar 的转换

学习记录: stl中 字符串 str自然对应的是string 宽字符串wchar 对应的是wstring 宽字符串占用两个字节 两者的转换有三种办法 1 windows 的api转换函数WideCharToMultiByte()与MultiByteToWideChar(). 不适合跨平台使用. 2 ATL中CA2W类与CW2A类.或者使用A2W宏与W2A宏.稍显累赘和麻烦 3 使用CRT库的函数 函数和使用方法见下列代码 #include <string> #include <iostr

DELPHI下API简述(1800个API)

DELPHI下API简述 http://zero.cnbct.org/show.asp?id=144 auxGetDevCaps API 获取附属设备容量 auxGetNumDevs API 返回附属设备数量 auxGetVolume API 获取当前卷设置 auxOutMessage API 向输出设备发送消息 auxSetVolume API 设置附属设备卷 AbortDoc API 终止一项打印作业 AbortPath API 终止或取消DC中的一切路径 AbortPrinter API

如何正确地在Spring Data JPA和Jackson中用上Java 8的时间相关API(即JSR 310也即java.time包下的众神器)

用过的肯定知道,JSR310的时间API真的是神器,极大的方便了在Java中对时间操作的过程. JSR 310规范领导者Stephen Colebourne就是joda-time作者,其主要思想也是借鉴了joda-time,而不是直接把joda-time移植到Java平台中,API是类似的,但做了改进,具体的改进请参考其2009年的一篇文章和InfoQ对他的采访: http://blog.joda.org/2009/11/why-jsr-310-isn-joda-time_4941.html h

Why GraphQL is Taking Over APIs

A few years ago, I managed a team at DocuSign that was tasked with re-writing the main DocuSign web app which was used by tens of millions of users. The APIs didn’t exist yet to support our new shiny front-end app because since the beginning the web

关于streamsets的相关问题总结

最近发现了一个很好用的工具streamsets工具.我将oracle数据库当中的数据增量的导入到hive当中.导入是按照唯一的主键ID将数据导入进来. 出现的问题如下: (1)数据精度的问题: 因为表是提前创建好的,我将id字段定义为int类型,但是在oracle数据库当中的数据类型是number类型.然后将number类型的数据转换为decimal类型的数据.decimal默认的精度为(1,38)位.所以这里的解决办法就是 在oracle导入数据和hive的元数据之间加上一个数据类型转化的操作

2019年的Vue发展

如果你是 Vue 开发新手,可能已经听过很多行话术语,比如单页面应用程序.异步组件.服务器端渲染,等等.你可能还听说过与 Vue 有关的一些工具和库,比如 Vuex.Webpack.Vue CLI 和 Nuxt. 浸没在术语和工具的浩瀚海洋中难免会令人感到沮丧,但其实并不是只有你一个人有这种感受,所有经验水平的开发人员都会持续感觉到这种莫名的压力. 一口气吃不成胖子,试图一下子学习所有东西可能是徒劳的,所以我将在这篇文章中展示一个高级“知识地图”,它包含了与 Vue 开发相关的关键领域,你可以使